babylon.d.ts 2.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. let Epsilon: number;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Color3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */
  1821. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1822. /**
  1823. * Unproject from screen space to object space
  1824. * @param source defines the screen space Vector3 to use
  1825. * @param viewportWidth defines the current width of the viewport
  1826. * @param viewportHeight defines the current height of the viewport
  1827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1828. * @param transform defines the transform (view x projection) matrix to use
  1829. * @returns the new Vector3
  1830. */
  1831. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1832. /**
  1833. * Unproject from screen space to object space
  1834. * @param source defines the screen space Vector3 to use
  1835. * @param viewportWidth defines the current width of the viewport
  1836. * @param viewportHeight defines the current height of the viewport
  1837. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1838. * @param view defines the view matrix to use
  1839. * @param projection defines the projection matrix to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1843. /**
  1844. * Unproject from screen space to object space
  1845. * @param source defines the screen space Vector3 to use
  1846. * @param viewportWidth defines the current width of the viewport
  1847. * @param viewportHeight defines the current height of the viewport
  1848. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1849. * @param view defines the view matrix to use
  1850. * @param projection defines the projection matrix to use
  1851. * @param result defines the Vector3 where to store the result
  1852. */
  1853. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param sourceX defines the screen space x coordinate to use
  1857. * @param sourceY defines the screen space y coordinate to use
  1858. * @param sourceZ defines the screen space z coordinate to use
  1859. * @param viewportWidth defines the current width of the viewport
  1860. * @param viewportHeight defines the current height of the viewport
  1861. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1862. * @param view defines the view matrix to use
  1863. * @param projection defines the projection matrix to use
  1864. * @param result defines the Vector3 where to store the result
  1865. */
  1866. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1867. /**
  1868. * Gets the minimal coordinate values between two Vector3
  1869. * @param left defines the first operand
  1870. * @param right defines the second operand
  1871. * @returns the new Vector3
  1872. */
  1873. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1874. /**
  1875. * Gets the maximal coordinate values between two Vector3
  1876. * @param left defines the first operand
  1877. * @param right defines the second operand
  1878. * @returns the new Vector3
  1879. */
  1880. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1881. /**
  1882. * Returns the distance between the vectors "value1" and "value2"
  1883. * @param value1 defines the first operand
  1884. * @param value2 defines the second operand
  1885. * @returns the distance
  1886. */
  1887. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1888. /**
  1889. * Returns the squared distance between the vectors "value1" and "value2"
  1890. * @param value1 defines the first operand
  1891. * @param value2 defines the second operand
  1892. * @returns the squared distance
  1893. */
  1894. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1895. /**
  1896. * Returns a new Vector3 located at the center between "value1" and "value2"
  1897. * @param value1 defines the first operand
  1898. * @param value2 defines the second operand
  1899. * @returns the new Vector3
  1900. */
  1901. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1902. /**
  1903. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1904. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1905. * to something in order to rotate it from its local system to the given target system
  1906. * Note: axis1, axis2 and axis3 are normalized during this operation
  1907. * @param axis1 defines the first axis
  1908. * @param axis2 defines the second axis
  1909. * @param axis3 defines the third axis
  1910. * @returns a new Vector3
  1911. */
  1912. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1913. /**
  1914. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1915. * @param axis1 defines the first axis
  1916. * @param axis2 defines the second axis
  1917. * @param axis3 defines the third axis
  1918. * @param ref defines the Vector3 where to store the result
  1919. */
  1920. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1921. }
  1922. /**
  1923. * Vector4 class created for EulerAngle class conversion to Quaternion
  1924. */
  1925. export class Vector4 {
  1926. /** x value of the vector */
  1927. x: number;
  1928. /** y value of the vector */
  1929. y: number;
  1930. /** z value of the vector */
  1931. z: number;
  1932. /** w value of the vector */
  1933. w: number;
  1934. /**
  1935. * Creates a Vector4 object from the given floats.
  1936. * @param x x value of the vector
  1937. * @param y y value of the vector
  1938. * @param z z value of the vector
  1939. * @param w w value of the vector
  1940. */
  1941. constructor(
  1942. /** x value of the vector */
  1943. x: number,
  1944. /** y value of the vector */
  1945. y: number,
  1946. /** z value of the vector */
  1947. z: number,
  1948. /** w value of the vector */
  1949. w: number);
  1950. /**
  1951. * Returns the string with the Vector4 coordinates.
  1952. * @returns a string containing all the vector values
  1953. */
  1954. toString(): string;
  1955. /**
  1956. * Returns the string "Vector4".
  1957. * @returns "Vector4"
  1958. */
  1959. getClassName(): string;
  1960. /**
  1961. * Returns the Vector4 hash code.
  1962. * @returns a unique hash code
  1963. */
  1964. getHashCode(): number;
  1965. /**
  1966. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1967. * @returns the resulting array
  1968. */
  1969. asArray(): number[];
  1970. /**
  1971. * Populates the given array from the given index with the Vector4 coordinates.
  1972. * @param array array to populate
  1973. * @param index index of the array to start at (default: 0)
  1974. * @returns the Vector4.
  1975. */
  1976. toArray(array: FloatArray, index?: number): Vector4;
  1977. /**
  1978. * Adds the given vector to the current Vector4.
  1979. * @param otherVector the vector to add
  1980. * @returns the updated Vector4.
  1981. */
  1982. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1983. /**
  1984. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1985. * @param otherVector the vector to add
  1986. * @returns the resulting vector
  1987. */
  1988. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1989. /**
  1990. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1991. * @param otherVector the vector to add
  1992. * @param result the vector to store the result
  1993. * @returns the current Vector4.
  1994. */
  1995. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1996. /**
  1997. * Subtract in place the given vector from the current Vector4.
  1998. * @param otherVector the vector to subtract
  1999. * @returns the updated Vector4.
  2000. */
  2001. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2002. /**
  2003. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the new vector with the result
  2006. */
  2007. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2010. * @param otherVector the vector to subtract
  2011. * @param result the vector to store the result
  2012. * @returns the current Vector4.
  2013. */
  2014. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2015. /**
  2016. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2017. */
  2018. /**
  2019. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2020. * @param x value to subtract
  2021. * @param y value to subtract
  2022. * @param z value to subtract
  2023. * @param w value to subtract
  2024. * @returns new vector containing the result
  2025. */
  2026. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2027. /**
  2028. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2029. * @param x value to subtract
  2030. * @param y value to subtract
  2031. * @param z value to subtract
  2032. * @param w value to subtract
  2033. * @param result the vector to store the result in
  2034. * @returns the current Vector4.
  2035. */
  2036. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2037. /**
  2038. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2039. * @returns a new vector with the negated values
  2040. */
  2041. negate(): Vector4;
  2042. /**
  2043. * Multiplies the current Vector4 coordinates by scale (float).
  2044. * @param scale the number to scale with
  2045. * @returns the updated Vector4.
  2046. */
  2047. scaleInPlace(scale: number): Vector4;
  2048. /**
  2049. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2050. * @param scale the number to scale with
  2051. * @returns a new vector with the result
  2052. */
  2053. scale(scale: number): Vector4;
  2054. /**
  2055. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2056. * @param scale the number to scale with
  2057. * @param result a vector to store the result in
  2058. * @returns the current Vector4.
  2059. */
  2060. scaleToRef(scale: number, result: Vector4): Vector4;
  2061. /**
  2062. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2063. * @param scale defines the scale factor
  2064. * @param result defines the Vector4 object where to store the result
  2065. * @returns the unmodified current Vector4
  2066. */
  2067. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2068. /**
  2069. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2070. * @param otherVector the vector to compare against
  2071. * @returns true if they are equal
  2072. */
  2073. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2074. /**
  2075. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2076. * @param otherVector vector to compare against
  2077. * @param epsilon (Default: very small number)
  2078. * @returns true if they are equal
  2079. */
  2080. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2081. /**
  2082. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2083. * @param x x value to compare against
  2084. * @param y y value to compare against
  2085. * @param z z value to compare against
  2086. * @param w w value to compare against
  2087. * @returns true if equal
  2088. */
  2089. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2090. /**
  2091. * Multiplies in place the current Vector4 by the given one.
  2092. * @param otherVector vector to multiple with
  2093. * @returns the updated Vector4.
  2094. */
  2095. multiplyInPlace(otherVector: Vector4): Vector4;
  2096. /**
  2097. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2098. * @param otherVector vector to multiple with
  2099. * @returns resulting new vector
  2100. */
  2101. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2102. /**
  2103. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2104. * @param otherVector vector to multiple with
  2105. * @param result vector to store the result
  2106. * @returns the current Vector4.
  2107. */
  2108. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2109. /**
  2110. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2111. * @param x x value multiply with
  2112. * @param y y value multiply with
  2113. * @param z z value multiply with
  2114. * @param w w value multiply with
  2115. * @returns resulting new vector
  2116. */
  2117. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2118. /**
  2119. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2120. * @param otherVector vector to devide with
  2121. * @returns resulting new vector
  2122. */
  2123. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2124. /**
  2125. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2126. * @param otherVector vector to devide with
  2127. * @param result vector to store the result
  2128. * @returns the current Vector4.
  2129. */
  2130. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2131. /**
  2132. * Divides the current Vector3 coordinates by the given ones.
  2133. * @param otherVector vector to devide with
  2134. * @returns the updated Vector3.
  2135. */
  2136. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2137. /**
  2138. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2139. * @param other defines the second operand
  2140. * @returns the current updated Vector4
  2141. */
  2142. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2143. /**
  2144. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2145. * @param other defines the second operand
  2146. * @returns the current updated Vector4
  2147. */
  2148. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Gets a new Vector4 from current Vector4 floored values
  2151. * @returns a new Vector4
  2152. */
  2153. floor(): Vector4;
  2154. /**
  2155. * Gets a new Vector4 from current Vector3 floored values
  2156. * @returns a new Vector4
  2157. */
  2158. fract(): Vector4;
  2159. /**
  2160. * Returns the Vector4 length (float).
  2161. * @returns the length
  2162. */
  2163. length(): number;
  2164. /**
  2165. * Returns the Vector4 squared length (float).
  2166. * @returns the length squared
  2167. */
  2168. lengthSquared(): number;
  2169. /**
  2170. * Normalizes in place the Vector4.
  2171. * @returns the updated Vector4.
  2172. */
  2173. normalize(): Vector4;
  2174. /**
  2175. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2176. * @returns this converted to a new vector3
  2177. */
  2178. toVector3(): Vector3;
  2179. /**
  2180. * Returns a new Vector4 copied from the current one.
  2181. * @returns the new cloned vector
  2182. */
  2183. clone(): Vector4;
  2184. /**
  2185. * Updates the current Vector4 with the given one coordinates.
  2186. * @param source the source vector to copy from
  2187. * @returns the updated Vector4.
  2188. */
  2189. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2190. /**
  2191. * Updates the current Vector4 coordinates with the given floats.
  2192. * @param x float to copy from
  2193. * @param y float to copy from
  2194. * @param z float to copy from
  2195. * @param w float to copy from
  2196. * @returns the updated Vector4.
  2197. */
  2198. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2199. /**
  2200. * Updates the current Vector4 coordinates with the given floats.
  2201. * @param x float to set from
  2202. * @param y float to set from
  2203. * @param z float to set from
  2204. * @param w float to set from
  2205. * @returns the updated Vector4.
  2206. */
  2207. set(x: number, y: number, z: number, w: number): Vector4;
  2208. /**
  2209. * Copies the given float to the current Vector3 coordinates
  2210. * @param v defines the x, y, z and w coordinates of the operand
  2211. * @returns the current updated Vector3
  2212. */
  2213. setAll(v: number): Vector4;
  2214. /**
  2215. * Returns a new Vector4 set from the starting index of the given array.
  2216. * @param array the array to pull values from
  2217. * @param offset the offset into the array to start at
  2218. * @returns the new vector
  2219. */
  2220. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2221. /**
  2222. * Updates the given vector "result" from the starting index of the given array.
  2223. * @param array the array to pull values from
  2224. * @param offset the offset into the array to start at
  2225. * @param result the vector to store the result in
  2226. */
  2227. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2228. /**
  2229. * Updates the given vector "result" from the starting index of the given Float32Array.
  2230. * @param array the array to pull values from
  2231. * @param offset the offset into the array to start at
  2232. * @param result the vector to store the result in
  2233. */
  2234. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2235. /**
  2236. * Updates the given vector "result" coordinates from the given floats.
  2237. * @param x float to set from
  2238. * @param y float to set from
  2239. * @param z float to set from
  2240. * @param w float to set from
  2241. * @param result the vector to the floats in
  2242. */
  2243. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2244. /**
  2245. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2246. * @returns the new vector
  2247. */
  2248. static Zero(): Vector4;
  2249. /**
  2250. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2251. * @returns the new vector
  2252. */
  2253. static One(): Vector4;
  2254. /**
  2255. * Returns a new normalized Vector4 from the given one.
  2256. * @param vector the vector to normalize
  2257. * @returns the vector
  2258. */
  2259. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2260. /**
  2261. * Updates the given vector "result" from the normalization of the given one.
  2262. * @param vector the vector to normalize
  2263. * @param result the vector to store the result in
  2264. */
  2265. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2266. /**
  2267. * Returns a vector with the minimum values from the left and right vectors
  2268. * @param left left vector to minimize
  2269. * @param right right vector to minimize
  2270. * @returns a new vector with the minimum of the left and right vector values
  2271. */
  2272. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2273. /**
  2274. * Returns a vector with the maximum values from the left and right vectors
  2275. * @param left left vector to maximize
  2276. * @param right right vector to maximize
  2277. * @returns a new vector with the maximum of the left and right vector values
  2278. */
  2279. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2280. /**
  2281. * Returns the distance (float) between the vectors "value1" and "value2".
  2282. * @param value1 value to calulate the distance between
  2283. * @param value2 value to calulate the distance between
  2284. * @return the distance between the two vectors
  2285. */
  2286. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2287. /**
  2288. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2289. * @param value1 value to calulate the distance between
  2290. * @param value2 value to calulate the distance between
  2291. * @return the distance between the two vectors squared
  2292. */
  2293. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2294. /**
  2295. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2296. * @param value1 value to calulate the center between
  2297. * @param value2 value to calulate the center between
  2298. * @return the center between the two vectors
  2299. */
  2300. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2301. /**
  2302. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2303. * This methods computes transformed normalized direction vectors only.
  2304. * @param vector the vector to transform
  2305. * @param transformation the transformation matrix to apply
  2306. * @returns the new vector
  2307. */
  2308. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2309. /**
  2310. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2311. * This methods computes transformed normalized direction vectors only.
  2312. * @param vector the vector to transform
  2313. * @param transformation the transformation matrix to apply
  2314. * @param result the vector to store the result in
  2315. */
  2316. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2317. /**
  2318. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2319. * This methods computes transformed normalized direction vectors only.
  2320. * @param x value to transform
  2321. * @param y value to transform
  2322. * @param z value to transform
  2323. * @param w value to transform
  2324. * @param transformation the transformation matrix to apply
  2325. * @param result the vector to store the results in
  2326. */
  2327. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2328. /**
  2329. * Creates a new Vector4 from a Vector3
  2330. * @param source defines the source data
  2331. * @param w defines the 4th component (default is 0)
  2332. * @returns a new Vector4
  2333. */
  2334. static FromVector3(source: Vector3, w?: number): Vector4;
  2335. }
  2336. /**
  2337. * Interface for the size containing width and height
  2338. */
  2339. export interface ISize {
  2340. /**
  2341. * Width
  2342. */
  2343. width: number;
  2344. /**
  2345. * Heighht
  2346. */
  2347. height: number;
  2348. }
  2349. /**
  2350. * Size containing widht and height
  2351. */
  2352. export class Size implements ISize {
  2353. /**
  2354. * Width
  2355. */
  2356. width: number;
  2357. /**
  2358. * Height
  2359. */
  2360. height: number;
  2361. /**
  2362. * Creates a Size object from the given width and height (floats).
  2363. * @param width width of the new size
  2364. * @param height height of the new size
  2365. */
  2366. constructor(width: number, height: number);
  2367. /**
  2368. * Returns a string with the Size width and height
  2369. * @returns a string with the Size width and height
  2370. */
  2371. toString(): string;
  2372. /**
  2373. * "Size"
  2374. * @returns the string "Size"
  2375. */
  2376. getClassName(): string;
  2377. /**
  2378. * Returns the Size hash code.
  2379. * @returns a hash code for a unique width and height
  2380. */
  2381. getHashCode(): number;
  2382. /**
  2383. * Updates the current size from the given one.
  2384. * @param src the given size
  2385. */
  2386. copyFrom(src: Size): void;
  2387. /**
  2388. * Updates in place the current Size from the given floats.
  2389. * @param width width of the new size
  2390. * @param height height of the new size
  2391. * @returns the updated Size.
  2392. */
  2393. copyFromFloats(width: number, height: number): Size;
  2394. /**
  2395. * Updates in place the current Size from the given floats.
  2396. * @param width width to set
  2397. * @param height height to set
  2398. * @returns the updated Size.
  2399. */
  2400. set(width: number, height: number): Size;
  2401. /**
  2402. * Multiplies the width and height by numbers
  2403. * @param w factor to multiple the width by
  2404. * @param h factor to multiple the height by
  2405. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2406. */
  2407. multiplyByFloats(w: number, h: number): Size;
  2408. /**
  2409. * Clones the size
  2410. * @returns a new Size copied from the given one.
  2411. */
  2412. clone(): Size;
  2413. /**
  2414. * True if the current Size and the given one width and height are strictly equal.
  2415. * @param other the other size to compare against
  2416. * @returns True if the current Size and the given one width and height are strictly equal.
  2417. */
  2418. equals(other: Size): boolean;
  2419. /**
  2420. * The surface of the Size : width * height (float).
  2421. */
  2422. readonly surface: number;
  2423. /**
  2424. * Create a new size of zero
  2425. * @returns a new Size set to (0.0, 0.0)
  2426. */
  2427. static Zero(): Size;
  2428. /**
  2429. * Sums the width and height of two sizes
  2430. * @param otherSize size to add to this size
  2431. * @returns a new Size set as the addition result of the current Size and the given one.
  2432. */
  2433. add(otherSize: Size): Size;
  2434. /**
  2435. * Subtracts the width and height of two
  2436. * @param otherSize size to subtract to this size
  2437. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2438. */
  2439. subtract(otherSize: Size): Size;
  2440. /**
  2441. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2442. * @param start starting size to lerp between
  2443. * @param end end size to lerp between
  2444. * @param amount amount to lerp between the start and end values
  2445. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2446. */
  2447. static Lerp(start: Size, end: Size, amount: number): Size;
  2448. }
  2449. /**
  2450. * Class used to store quaternion data
  2451. * @see https://en.wikipedia.org/wiki/Quaternion
  2452. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2453. */
  2454. export class Quaternion {
  2455. /** defines the first component (0 by default) */
  2456. x: number;
  2457. /** defines the second component (0 by default) */
  2458. y: number;
  2459. /** defines the third component (0 by default) */
  2460. z: number;
  2461. /** defines the fourth component (1.0 by default) */
  2462. w: number;
  2463. /**
  2464. * Creates a new Quaternion from the given floats
  2465. * @param x defines the first component (0 by default)
  2466. * @param y defines the second component (0 by default)
  2467. * @param z defines the third component (0 by default)
  2468. * @param w defines the fourth component (1.0 by default)
  2469. */
  2470. constructor(
  2471. /** defines the first component (0 by default) */
  2472. x?: number,
  2473. /** defines the second component (0 by default) */
  2474. y?: number,
  2475. /** defines the third component (0 by default) */
  2476. z?: number,
  2477. /** defines the fourth component (1.0 by default) */
  2478. w?: number);
  2479. /**
  2480. * Gets a string representation for the current quaternion
  2481. * @returns a string with the Quaternion coordinates
  2482. */
  2483. toString(): string;
  2484. /**
  2485. * Gets the class name of the quaternion
  2486. * @returns the string "Quaternion"
  2487. */
  2488. getClassName(): string;
  2489. /**
  2490. * Gets a hash code for this quaternion
  2491. * @returns the quaternion hash code
  2492. */
  2493. getHashCode(): number;
  2494. /**
  2495. * Copy the quaternion to an array
  2496. * @returns a new array populated with 4 elements from the quaternion coordinates
  2497. */
  2498. asArray(): number[];
  2499. /**
  2500. * Check if two quaternions are equals
  2501. * @param otherQuaternion defines the second operand
  2502. * @return true if the current quaternion and the given one coordinates are strictly equals
  2503. */
  2504. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2505. /**
  2506. * Clone the current quaternion
  2507. * @returns a new quaternion copied from the current one
  2508. */
  2509. clone(): Quaternion;
  2510. /**
  2511. * Copy a quaternion to the current one
  2512. * @param other defines the other quaternion
  2513. * @returns the updated current quaternion
  2514. */
  2515. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2516. /**
  2517. * Updates the current quaternion with the given float coordinates
  2518. * @param x defines the x coordinate
  2519. * @param y defines the y coordinate
  2520. * @param z defines the z coordinate
  2521. * @param w defines the w coordinate
  2522. * @returns the updated current quaternion
  2523. */
  2524. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2525. /**
  2526. * Updates the current quaternion from the given float coordinates
  2527. * @param x defines the x coordinate
  2528. * @param y defines the y coordinate
  2529. * @param z defines the z coordinate
  2530. * @param w defines the w coordinate
  2531. * @returns the updated current quaternion
  2532. */
  2533. set(x: number, y: number, z: number, w: number): Quaternion;
  2534. /**
  2535. * Adds two quaternions
  2536. * @param other defines the second operand
  2537. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2538. */
  2539. add(other: DeepImmutable<Quaternion>): Quaternion;
  2540. /**
  2541. * Add a quaternion to the current one
  2542. * @param other defines the quaternion to add
  2543. * @returns the current quaternion
  2544. */
  2545. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2546. /**
  2547. * Subtract two quaternions
  2548. * @param other defines the second operand
  2549. * @returns a new quaternion as the subtraction result of the given one from the current one
  2550. */
  2551. subtract(other: Quaternion): Quaternion;
  2552. /**
  2553. * Multiplies the current quaternion by a scale factor
  2554. * @param value defines the scale factor
  2555. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2556. */
  2557. scale(value: number): Quaternion;
  2558. /**
  2559. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2560. * @param scale defines the scale factor
  2561. * @param result defines the Quaternion object where to store the result
  2562. * @returns the unmodified current quaternion
  2563. */
  2564. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2565. /**
  2566. * Multiplies in place the current quaternion by a scale factor
  2567. * @param value defines the scale factor
  2568. * @returns the current modified quaternion
  2569. */
  2570. scaleInPlace(value: number): Quaternion;
  2571. /**
  2572. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2573. * @param scale defines the scale factor
  2574. * @param result defines the Quaternion object where to store the result
  2575. * @returns the unmodified current quaternion
  2576. */
  2577. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2578. /**
  2579. * Multiplies two quaternions
  2580. * @param q1 defines the second operand
  2581. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2582. */
  2583. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2584. /**
  2585. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2586. * @param q1 defines the second operand
  2587. * @param result defines the target quaternion
  2588. * @returns the current quaternion
  2589. */
  2590. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2591. /**
  2592. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2593. * @param q1 defines the second operand
  2594. * @returns the currentupdated quaternion
  2595. */
  2596. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2597. /**
  2598. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2599. * @param ref defines the target quaternion
  2600. * @returns the current quaternion
  2601. */
  2602. conjugateToRef(ref: Quaternion): Quaternion;
  2603. /**
  2604. * Conjugates in place (1-q) the current quaternion
  2605. * @returns the current updated quaternion
  2606. */
  2607. conjugateInPlace(): Quaternion;
  2608. /**
  2609. * Conjugates in place (1-q) the current quaternion
  2610. * @returns a new quaternion
  2611. */
  2612. conjugate(): Quaternion;
  2613. /**
  2614. * Gets length of current quaternion
  2615. * @returns the quaternion length (float)
  2616. */
  2617. length(): number;
  2618. /**
  2619. * Normalize in place the current quaternion
  2620. * @returns the current updated quaternion
  2621. */
  2622. normalize(): Quaternion;
  2623. /**
  2624. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2625. * @param order is a reserved parameter and is ignore for now
  2626. * @returns a new Vector3 containing the Euler angles
  2627. */
  2628. toEulerAngles(order?: string): Vector3;
  2629. /**
  2630. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2631. * @param result defines the vector which will be filled with the Euler angles
  2632. * @param order is a reserved parameter and is ignore for now
  2633. * @returns the current unchanged quaternion
  2634. */
  2635. toEulerAnglesToRef(result: Vector3): Quaternion;
  2636. /**
  2637. * Updates the given rotation matrix with the current quaternion values
  2638. * @param result defines the target matrix
  2639. * @returns the current unchanged quaternion
  2640. */
  2641. toRotationMatrix(result: Matrix): Quaternion;
  2642. /**
  2643. * Updates the current quaternion from the given rotation matrix values
  2644. * @param matrix defines the source matrix
  2645. * @returns the current updated quaternion
  2646. */
  2647. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2648. /**
  2649. * Creates a new quaternion from a rotation matrix
  2650. * @param matrix defines the source matrix
  2651. * @returns a new quaternion created from the given rotation matrix values
  2652. */
  2653. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2654. /**
  2655. * Updates the given quaternion with the given rotation matrix values
  2656. * @param matrix defines the source matrix
  2657. * @param result defines the target quaternion
  2658. */
  2659. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2660. /**
  2661. * Returns the dot product (float) between the quaternions "left" and "right"
  2662. * @param left defines the left operand
  2663. * @param right defines the right operand
  2664. * @returns the dot product
  2665. */
  2666. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2667. /**
  2668. * Checks if the two quaternions are close to each other
  2669. * @param quat0 defines the first quaternion to check
  2670. * @param quat1 defines the second quaternion to check
  2671. * @returns true if the two quaternions are close to each other
  2672. */
  2673. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2674. /**
  2675. * Creates an empty quaternion
  2676. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2677. */
  2678. static Zero(): Quaternion;
  2679. /**
  2680. * Inverse a given quaternion
  2681. * @param q defines the source quaternion
  2682. * @returns a new quaternion as the inverted current quaternion
  2683. */
  2684. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2685. /**
  2686. * Inverse a given quaternion
  2687. * @param q defines the source quaternion
  2688. * @param result the quaternion the result will be stored in
  2689. * @returns the result quaternion
  2690. */
  2691. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2692. /**
  2693. * Creates an identity quaternion
  2694. * @returns the identity quaternion
  2695. */
  2696. static Identity(): Quaternion;
  2697. /**
  2698. * Gets a boolean indicating if the given quaternion is identity
  2699. * @param quaternion defines the quaternion to check
  2700. * @returns true if the quaternion is identity
  2701. */
  2702. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2703. /**
  2704. * Creates a quaternion from a rotation around an axis
  2705. * @param axis defines the axis to use
  2706. * @param angle defines the angle to use
  2707. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2708. */
  2709. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2710. /**
  2711. * Creates a rotation around an axis and stores it into the given quaternion
  2712. * @param axis defines the axis to use
  2713. * @param angle defines the angle to use
  2714. * @param result defines the target quaternion
  2715. * @returns the target quaternion
  2716. */
  2717. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2718. /**
  2719. * Creates a new quaternion from data stored into an array
  2720. * @param array defines the data source
  2721. * @param offset defines the offset in the source array where the data starts
  2722. * @returns a new quaternion
  2723. */
  2724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2725. /**
  2726. * Create a quaternion from Euler rotation angles
  2727. * @param x Pitch
  2728. * @param y Yaw
  2729. * @param z Roll
  2730. * @returns the new Quaternion
  2731. */
  2732. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2733. /**
  2734. * Updates a quaternion from Euler rotation angles
  2735. * @param x Pitch
  2736. * @param y Yaw
  2737. * @param z Roll
  2738. * @param result the quaternion to store the result
  2739. * @returns the updated quaternion
  2740. */
  2741. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2742. /**
  2743. * Create a quaternion from Euler rotation vector
  2744. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2745. * @returns the new Quaternion
  2746. */
  2747. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2748. /**
  2749. * Updates a quaternion from Euler rotation vector
  2750. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2751. * @param result the quaternion to store the result
  2752. * @returns the updated quaternion
  2753. */
  2754. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2755. /**
  2756. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2757. * @param yaw defines the rotation around Y axis
  2758. * @param pitch defines the rotation around X axis
  2759. * @param roll defines the rotation around Z axis
  2760. * @returns the new quaternion
  2761. */
  2762. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2763. /**
  2764. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2765. * @param yaw defines the rotation around Y axis
  2766. * @param pitch defines the rotation around X axis
  2767. * @param roll defines the rotation around Z axis
  2768. * @param result defines the target quaternion
  2769. */
  2770. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2771. /**
  2772. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2773. * @param alpha defines the rotation around first axis
  2774. * @param beta defines the rotation around second axis
  2775. * @param gamma defines the rotation around third axis
  2776. * @returns the new quaternion
  2777. */
  2778. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2779. /**
  2780. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2781. * @param alpha defines the rotation around first axis
  2782. * @param beta defines the rotation around second axis
  2783. * @param gamma defines the rotation around third axis
  2784. * @param result defines the target quaternion
  2785. */
  2786. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2787. /**
  2788. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2789. * @param axis1 defines the first axis
  2790. * @param axis2 defines the second axis
  2791. * @param axis3 defines the third axis
  2792. * @returns the new quaternion
  2793. */
  2794. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2795. /**
  2796. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2797. * @param axis1 defines the first axis
  2798. * @param axis2 defines the second axis
  2799. * @param axis3 defines the third axis
  2800. * @param ref defines the target quaternion
  2801. */
  2802. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2803. /**
  2804. * Interpolates between two quaternions
  2805. * @param left defines first quaternion
  2806. * @param right defines second quaternion
  2807. * @param amount defines the gradient to use
  2808. * @returns the new interpolated quaternion
  2809. */
  2810. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2811. /**
  2812. * Interpolates between two quaternions and stores it into a target quaternion
  2813. * @param left defines first quaternion
  2814. * @param right defines second quaternion
  2815. * @param amount defines the gradient to use
  2816. * @param result defines the target quaternion
  2817. */
  2818. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2819. /**
  2820. * Interpolate between two quaternions using Hermite interpolation
  2821. * @param value1 defines first quaternion
  2822. * @param tangent1 defines the incoming tangent
  2823. * @param value2 defines second quaternion
  2824. * @param tangent2 defines the outgoing tangent
  2825. * @param amount defines the target quaternion
  2826. * @returns the new interpolated quaternion
  2827. */
  2828. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2829. }
  2830. /**
  2831. * Class used to store matrix data (4x4)
  2832. */
  2833. export class Matrix {
  2834. private static _updateFlagSeed;
  2835. private static _identityReadOnly;
  2836. private _isIdentity;
  2837. private _isIdentityDirty;
  2838. private _isIdentity3x2;
  2839. private _isIdentity3x2Dirty;
  2840. /**
  2841. * Gets the update flag of the matrix which is an unique number for the matrix.
  2842. * It will be incremented every time the matrix data change.
  2843. * You can use it to speed the comparison between two versions of the same matrix.
  2844. */
  2845. updateFlag: number;
  2846. private readonly _m;
  2847. /**
  2848. * Gets the internal data of the matrix
  2849. */
  2850. readonly m: DeepImmutable<Float32Array>;
  2851. /** @hidden */
  2852. _markAsUpdated(): void;
  2853. /** @hidden */
  2854. private _updateIdentityStatus;
  2855. /**
  2856. * Creates an empty matrix (filled with zeros)
  2857. */
  2858. constructor();
  2859. /**
  2860. * Check if the current matrix is identity
  2861. * @returns true is the matrix is the identity matrix
  2862. */
  2863. isIdentity(): boolean;
  2864. /**
  2865. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2866. * @returns true is the matrix is the identity matrix
  2867. */
  2868. isIdentityAs3x2(): boolean;
  2869. /**
  2870. * Gets the determinant of the matrix
  2871. * @returns the matrix determinant
  2872. */
  2873. determinant(): number;
  2874. /**
  2875. * Returns the matrix as a Float32Array
  2876. * @returns the matrix underlying array
  2877. */
  2878. toArray(): DeepImmutable<Float32Array>;
  2879. /**
  2880. * Returns the matrix as a Float32Array
  2881. * @returns the matrix underlying array.
  2882. */
  2883. asArray(): DeepImmutable<Float32Array>;
  2884. /**
  2885. * Inverts the current matrix in place
  2886. * @returns the current inverted matrix
  2887. */
  2888. invert(): Matrix;
  2889. /**
  2890. * Sets all the matrix elements to zero
  2891. * @returns the current matrix
  2892. */
  2893. reset(): Matrix;
  2894. /**
  2895. * Adds the current matrix with a second one
  2896. * @param other defines the matrix to add
  2897. * @returns a new matrix as the addition of the current matrix and the given one
  2898. */
  2899. add(other: DeepImmutable<Matrix>): Matrix;
  2900. /**
  2901. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2902. * @param other defines the matrix to add
  2903. * @param result defines the target matrix
  2904. * @returns the current matrix
  2905. */
  2906. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2907. /**
  2908. * Adds in place the given matrix to the current matrix
  2909. * @param other defines the second operand
  2910. * @returns the current updated matrix
  2911. */
  2912. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2913. /**
  2914. * Sets the given matrix to the current inverted Matrix
  2915. * @param other defines the target matrix
  2916. * @returns the unmodified current matrix
  2917. */
  2918. invertToRef(other: Matrix): Matrix;
  2919. /**
  2920. * add a value at the specified position in the current Matrix
  2921. * @param index the index of the value within the matrix. between 0 and 15.
  2922. * @param value the value to be added
  2923. * @returns the current updated matrix
  2924. */
  2925. addAtIndex(index: number, value: number): Matrix;
  2926. /**
  2927. * mutiply the specified position in the current Matrix by a value
  2928. * @param index the index of the value within the matrix. between 0 and 15.
  2929. * @param value the value to be added
  2930. * @returns the current updated matrix
  2931. */
  2932. multiplyAtIndex(index: number, value: number): Matrix;
  2933. /**
  2934. * Inserts the translation vector (using 3 floats) in the current matrix
  2935. * @param x defines the 1st component of the translation
  2936. * @param y defines the 2nd component of the translation
  2937. * @param z defines the 3rd component of the translation
  2938. * @returns the current updated matrix
  2939. */
  2940. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2941. /**
  2942. * Adds the translation vector (using 3 floats) in the current matrix
  2943. * @param x defines the 1st component of the translation
  2944. * @param y defines the 2nd component of the translation
  2945. * @param z defines the 3rd component of the translation
  2946. * @returns the current updated matrix
  2947. */
  2948. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2949. /**
  2950. * Inserts the translation vector in the current matrix
  2951. * @param vector3 defines the translation to insert
  2952. * @returns the current updated matrix
  2953. */
  2954. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2955. /**
  2956. * Gets the translation value of the current matrix
  2957. * @returns a new Vector3 as the extracted translation from the matrix
  2958. */
  2959. getTranslation(): Vector3;
  2960. /**
  2961. * Fill a Vector3 with the extracted translation from the matrix
  2962. * @param result defines the Vector3 where to store the translation
  2963. * @returns the current matrix
  2964. */
  2965. getTranslationToRef(result: Vector3): Matrix;
  2966. /**
  2967. * Remove rotation and scaling part from the matrix
  2968. * @returns the updated matrix
  2969. */
  2970. removeRotationAndScaling(): Matrix;
  2971. /**
  2972. * Multiply two matrices
  2973. * @param other defines the second operand
  2974. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2975. */
  2976. multiply(other: DeepImmutable<Matrix>): Matrix;
  2977. /**
  2978. * Copy the current matrix from the given one
  2979. * @param other defines the source matrix
  2980. * @returns the current updated matrix
  2981. */
  2982. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2983. /**
  2984. * Populates the given array from the starting index with the current matrix values
  2985. * @param array defines the target array
  2986. * @param offset defines the offset in the target array where to start storing values
  2987. * @returns the current matrix
  2988. */
  2989. copyToArray(array: Float32Array, offset?: number): Matrix;
  2990. /**
  2991. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the matrix where to store the multiplication
  2994. * @returns the current matrix
  2995. */
  2996. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2997. /**
  2998. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2999. * @param other defines the second operand
  3000. * @param result defines the array where to store the multiplication
  3001. * @param offset defines the offset in the target array where to start storing values
  3002. * @returns the current matrix
  3003. */
  3004. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3005. /**
  3006. * Check equality between this matrix and a second one
  3007. * @param value defines the second matrix to compare
  3008. * @returns true is the current matrix and the given one values are strictly equal
  3009. */
  3010. equals(value: DeepImmutable<Matrix>): boolean;
  3011. /**
  3012. * Clone the current matrix
  3013. * @returns a new matrix from the current matrix
  3014. */
  3015. clone(): Matrix;
  3016. /**
  3017. * Returns the name of the current matrix class
  3018. * @returns the string "Matrix"
  3019. */
  3020. getClassName(): string;
  3021. /**
  3022. * Gets the hash code of the current matrix
  3023. * @returns the hash code
  3024. */
  3025. getHashCode(): number;
  3026. /**
  3027. * Decomposes the current Matrix into a translation, rotation and scaling components
  3028. * @param scale defines the scale vector3 given as a reference to update
  3029. * @param rotation defines the rotation quaternion given as a reference to update
  3030. * @param translation defines the translation vector3 given as a reference to update
  3031. * @returns true if operation was successful
  3032. */
  3033. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3034. /**
  3035. * Gets specific row of the matrix
  3036. * @param index defines the number of the row to get
  3037. * @returns the index-th row of the current matrix as a new Vector4
  3038. */
  3039. getRow(index: number): Nullable<Vector4>;
  3040. /**
  3041. * Sets the index-th row of the current matrix to the vector4 values
  3042. * @param index defines the number of the row to set
  3043. * @param row defines the target vector4
  3044. * @returns the updated current matrix
  3045. */
  3046. setRow(index: number, row: Vector4): Matrix;
  3047. /**
  3048. * Compute the transpose of the matrix
  3049. * @returns the new transposed matrix
  3050. */
  3051. transpose(): Matrix;
  3052. /**
  3053. * Compute the transpose of the matrix and store it in a given matrix
  3054. * @param result defines the target matrix
  3055. * @returns the current matrix
  3056. */
  3057. transposeToRef(result: Matrix): Matrix;
  3058. /**
  3059. * Sets the index-th row of the current matrix with the given 4 x float values
  3060. * @param index defines the row index
  3061. * @param x defines the x component to set
  3062. * @param y defines the y component to set
  3063. * @param z defines the z component to set
  3064. * @param w defines the w component to set
  3065. * @returns the updated current matrix
  3066. */
  3067. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3068. /**
  3069. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3070. * @param scale defines the scale factor
  3071. * @returns a new matrix
  3072. */
  3073. scale(scale: number): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor to a given result matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Scale the current matrix values by a factor and add the result to a given matrix
  3083. * @param scale defines the scale factor
  3084. * @param result defines the Matrix to store the result
  3085. * @returns the current matrix
  3086. */
  3087. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3088. /**
  3089. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3090. * @param ref matrix to store the result
  3091. */
  3092. toNormalMatrix(ref: Matrix): void;
  3093. /**
  3094. * Gets only rotation part of the current matrix
  3095. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3096. */
  3097. getRotationMatrix(): Matrix;
  3098. /**
  3099. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3100. * @param result defines the target matrix to store data to
  3101. * @returns the current matrix
  3102. */
  3103. getRotationMatrixToRef(result: Matrix): Matrix;
  3104. /**
  3105. * Toggles model matrix from being right handed to left handed in place and vice versa
  3106. */
  3107. toggleModelMatrixHandInPlace(): void;
  3108. /**
  3109. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3110. */
  3111. toggleProjectionMatrixHandInPlace(): void;
  3112. /**
  3113. * Creates a matrix from an array
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @returns a new Matrix set from the starting index of the given array
  3117. */
  3118. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3119. /**
  3120. * Copy the content of an array into a given matrix
  3121. * @param array defines the source array
  3122. * @param offset defines an offset in the source array
  3123. * @param result defines the target matrix
  3124. */
  3125. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3126. /**
  3127. * Stores an array into a matrix after having multiplied each component by a given factor
  3128. * @param array defines the source array
  3129. * @param offset defines the offset in the source array
  3130. * @param scale defines the scaling factor
  3131. * @param result defines the target matrix
  3132. */
  3133. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3134. /**
  3135. * Gets an identity matrix that must not be updated
  3136. */
  3137. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3138. /**
  3139. * Stores a list of values (16) inside a given matrix
  3140. * @param initialM11 defines 1st value of 1st row
  3141. * @param initialM12 defines 2nd value of 1st row
  3142. * @param initialM13 defines 3rd value of 1st row
  3143. * @param initialM14 defines 4th value of 1st row
  3144. * @param initialM21 defines 1st value of 2nd row
  3145. * @param initialM22 defines 2nd value of 2nd row
  3146. * @param initialM23 defines 3rd value of 2nd row
  3147. * @param initialM24 defines 4th value of 2nd row
  3148. * @param initialM31 defines 1st value of 3rd row
  3149. * @param initialM32 defines 2nd value of 3rd row
  3150. * @param initialM33 defines 3rd value of 3rd row
  3151. * @param initialM34 defines 4th value of 3rd row
  3152. * @param initialM41 defines 1st value of 4th row
  3153. * @param initialM42 defines 2nd value of 4th row
  3154. * @param initialM43 defines 3rd value of 4th row
  3155. * @param initialM44 defines 4th value of 4th row
  3156. * @param result defines the target matrix
  3157. */
  3158. 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;
  3159. /**
  3160. * Creates new matrix from a list of values (16)
  3161. * @param initialM11 defines 1st value of 1st row
  3162. * @param initialM12 defines 2nd value of 1st row
  3163. * @param initialM13 defines 3rd value of 1st row
  3164. * @param initialM14 defines 4th value of 1st row
  3165. * @param initialM21 defines 1st value of 2nd row
  3166. * @param initialM22 defines 2nd value of 2nd row
  3167. * @param initialM23 defines 3rd value of 2nd row
  3168. * @param initialM24 defines 4th value of 2nd row
  3169. * @param initialM31 defines 1st value of 3rd row
  3170. * @param initialM32 defines 2nd value of 3rd row
  3171. * @param initialM33 defines 3rd value of 3rd row
  3172. * @param initialM34 defines 4th value of 3rd row
  3173. * @param initialM41 defines 1st value of 4th row
  3174. * @param initialM42 defines 2nd value of 4th row
  3175. * @param initialM43 defines 3rd value of 4th row
  3176. * @param initialM44 defines 4th value of 4th row
  3177. * @returns the new matrix
  3178. */
  3179. 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;
  3180. /**
  3181. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3182. * @param scale defines the scale vector3
  3183. * @param rotation defines the rotation quaternion
  3184. * @param translation defines the translation vector3
  3185. * @returns a new matrix
  3186. */
  3187. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3188. /**
  3189. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3190. * @param scale defines the scale vector3
  3191. * @param rotation defines the rotation quaternion
  3192. * @param translation defines the translation vector3
  3193. * @param result defines the target matrix
  3194. */
  3195. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3196. /**
  3197. * Creates a new identity matrix
  3198. * @returns a new identity matrix
  3199. */
  3200. static Identity(): Matrix;
  3201. /**
  3202. * Creates a new identity matrix and stores the result in a given matrix
  3203. * @param result defines the target matrix
  3204. */
  3205. static IdentityToRef(result: Matrix): void;
  3206. /**
  3207. * Creates a new zero matrix
  3208. * @returns a new zero matrix
  3209. */
  3210. static Zero(): Matrix;
  3211. /**
  3212. * Creates a new rotation matrix for "angle" radians around the X axis
  3213. * @param angle defines the angle (in radians) to use
  3214. * @return the new matrix
  3215. */
  3216. static RotationX(angle: number): Matrix;
  3217. /**
  3218. * Creates a new matrix as the invert of a given matrix
  3219. * @param source defines the source matrix
  3220. * @returns the new matrix
  3221. */
  3222. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3223. /**
  3224. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3225. * @param angle defines the angle (in radians) to use
  3226. * @param result defines the target matrix
  3227. */
  3228. static RotationXToRef(angle: number, result: Matrix): void;
  3229. /**
  3230. * Creates a new rotation matrix for "angle" radians around the Y axis
  3231. * @param angle defines the angle (in radians) to use
  3232. * @return the new matrix
  3233. */
  3234. static RotationY(angle: number): Matrix;
  3235. /**
  3236. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3237. * @param angle defines the angle (in radians) to use
  3238. * @param result defines the target matrix
  3239. */
  3240. static RotationYToRef(angle: number, result: Matrix): void;
  3241. /**
  3242. * Creates a new rotation matrix for "angle" radians around the Z axis
  3243. * @param angle defines the angle (in radians) to use
  3244. * @return the new matrix
  3245. */
  3246. static RotationZ(angle: number): Matrix;
  3247. /**
  3248. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3249. * @param angle defines the angle (in radians) to use
  3250. * @param result defines the target matrix
  3251. */
  3252. static RotationZToRef(angle: number, result: Matrix): void;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3262. * @param axis defines the axis to use
  3263. * @param angle defines the angle (in radians) to use
  3264. * @param result defines the target matrix
  3265. */
  3266. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3267. /**
  3268. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3269. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3270. * @param from defines the vector to align
  3271. * @param to defines the vector to align to
  3272. * @param result defines the target matrix
  3273. */
  3274. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3275. /**
  3276. * Creates a rotation matrix
  3277. * @param yaw defines the yaw angle in radians (Y axis)
  3278. * @param pitch defines the pitch angle in radians (X axis)
  3279. * @param roll defines the roll angle in radians (X axis)
  3280. * @returns the new rotation matrix
  3281. */
  3282. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3283. /**
  3284. * Creates a rotation matrix and stores it in a given matrix
  3285. * @param yaw defines the yaw angle in radians (Y axis)
  3286. * @param pitch defines the pitch angle in radians (X axis)
  3287. * @param roll defines the roll angle in radians (X axis)
  3288. * @param result defines the target matrix
  3289. */
  3290. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3291. /**
  3292. * Creates a scaling matrix
  3293. * @param x defines the scale factor on X axis
  3294. * @param y defines the scale factor on Y axis
  3295. * @param z defines the scale factor on Z axis
  3296. * @returns the new matrix
  3297. */
  3298. static Scaling(x: number, y: number, z: number): Matrix;
  3299. /**
  3300. * Creates a scaling matrix and stores it in a given matrix
  3301. * @param x defines the scale factor on X axis
  3302. * @param y defines the scale factor on Y axis
  3303. * @param z defines the scale factor on Z axis
  3304. * @param result defines the target matrix
  3305. */
  3306. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3307. /**
  3308. * Creates a translation matrix
  3309. * @param x defines the translation on X axis
  3310. * @param y defines the translation on Y axis
  3311. * @param z defines the translationon Z axis
  3312. * @returns the new matrix
  3313. */
  3314. static Translation(x: number, y: number, z: number): Matrix;
  3315. /**
  3316. * Creates a translation matrix and stores it in a given matrix
  3317. * @param x defines the translation on X axis
  3318. * @param y defines the translation on Y axis
  3319. * @param z defines the translationon Z axis
  3320. * @param result defines the target matrix
  3321. */
  3322. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3323. /**
  3324. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3325. * @param startValue defines the start value
  3326. * @param endValue defines the end value
  3327. * @param gradient defines the gradient factor
  3328. * @returns the new matrix
  3329. */
  3330. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3331. /**
  3332. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3333. * @param startValue defines the start value
  3334. * @param endValue defines the end value
  3335. * @param gradient defines the gradient factor
  3336. * @param result defines the Matrix object where to store data
  3337. */
  3338. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3339. /**
  3340. * Builds a new matrix whose values are computed by:
  3341. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3342. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3343. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3344. * @param startValue defines the first matrix
  3345. * @param endValue defines the second matrix
  3346. * @param gradient defines the gradient between the two matrices
  3347. * @returns the new matrix
  3348. */
  3349. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3350. /**
  3351. * Update a matrix to values which are computed by:
  3352. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3353. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3354. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3355. * @param startValue defines the first matrix
  3356. * @param endValue defines the second matrix
  3357. * @param gradient defines the gradient between the two matrices
  3358. * @param result defines the target matrix
  3359. */
  3360. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3361. /**
  3362. * 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"
  3363. * This function works in left handed mode
  3364. * @param eye defines the final position of the entity
  3365. * @param target defines where the entity should look at
  3366. * @param up defines the up vector for the entity
  3367. * @returns the new matrix
  3368. */
  3369. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3370. /**
  3371. * 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".
  3372. * This function works in left handed mode
  3373. * @param eye defines the final position of the entity
  3374. * @param target defines where the entity should look at
  3375. * @param up defines the up vector for the entity
  3376. * @param result defines the target matrix
  3377. */
  3378. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3379. /**
  3380. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3381. * This function works in right handed mode
  3382. * @param eye defines the final position of the entity
  3383. * @param target defines where the entity should look at
  3384. * @param up defines the up vector for the entity
  3385. * @returns the new matrix
  3386. */
  3387. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3388. /**
  3389. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3390. * This function works in right handed mode
  3391. * @param eye defines the final position of the entity
  3392. * @param target defines where the entity should look at
  3393. * @param up defines the up vector for the entity
  3394. * @param result defines the target matrix
  3395. */
  3396. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3397. /**
  3398. * Create a left-handed orthographic projection matrix
  3399. * @param width defines the viewport width
  3400. * @param height defines the viewport height
  3401. * @param znear defines the near clip plane
  3402. * @param zfar defines the far clip plane
  3403. * @returns a new matrix as a left-handed orthographic projection matrix
  3404. */
  3405. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3406. /**
  3407. * Store a left-handed orthographic projection to a given matrix
  3408. * @param width defines the viewport width
  3409. * @param height defines the viewport height
  3410. * @param znear defines the near clip plane
  3411. * @param zfar defines the far clip plane
  3412. * @param result defines the target matrix
  3413. */
  3414. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3415. /**
  3416. * Create a left-handed orthographic projection matrix
  3417. * @param left defines the viewport left coordinate
  3418. * @param right defines the viewport right coordinate
  3419. * @param bottom defines the viewport bottom coordinate
  3420. * @param top defines the viewport top coordinate
  3421. * @param znear defines the near clip plane
  3422. * @param zfar defines the far clip plane
  3423. * @returns a new matrix as a left-handed orthographic projection matrix
  3424. */
  3425. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3426. /**
  3427. * Stores a left-handed orthographic projection into a given matrix
  3428. * @param left defines the viewport left coordinate
  3429. * @param right defines the viewport right coordinate
  3430. * @param bottom defines the viewport bottom coordinate
  3431. * @param top defines the viewport top coordinate
  3432. * @param znear defines the near clip plane
  3433. * @param zfar defines the far clip plane
  3434. * @param result defines the target matrix
  3435. */
  3436. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3437. /**
  3438. * Creates a right-handed orthographic projection matrix
  3439. * @param left defines the viewport left coordinate
  3440. * @param right defines the viewport right coordinate
  3441. * @param bottom defines the viewport bottom coordinate
  3442. * @param top defines the viewport top coordinate
  3443. * @param znear defines the near clip plane
  3444. * @param zfar defines the far clip plane
  3445. * @returns a new matrix as a right-handed orthographic projection matrix
  3446. */
  3447. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3448. /**
  3449. * Stores a right-handed orthographic projection into a given matrix
  3450. * @param left defines the viewport left coordinate
  3451. * @param right defines the viewport right coordinate
  3452. * @param bottom defines the viewport bottom coordinate
  3453. * @param top defines the viewport top coordinate
  3454. * @param znear defines the near clip plane
  3455. * @param zfar defines the far clip plane
  3456. * @param result defines the target matrix
  3457. */
  3458. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3459. /**
  3460. * Creates a left-handed perspective projection matrix
  3461. * @param width defines the viewport width
  3462. * @param height defines the viewport height
  3463. * @param znear defines the near clip plane
  3464. * @param zfar defines the far clip plane
  3465. * @returns a new matrix as a left-handed perspective projection matrix
  3466. */
  3467. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3468. /**
  3469. * Creates a left-handed perspective projection matrix
  3470. * @param fov defines the horizontal field of view
  3471. * @param aspect defines the aspect ratio
  3472. * @param znear defines the near clip plane
  3473. * @param zfar defines the far clip plane
  3474. * @returns a new matrix as a left-handed perspective projection matrix
  3475. */
  3476. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3477. /**
  3478. * Stores a left-handed perspective projection into a given matrix
  3479. * @param fov defines the horizontal field of view
  3480. * @param aspect defines the aspect ratio
  3481. * @param znear defines the near clip plane
  3482. * @param zfar defines the far clip plane
  3483. * @param result defines the target matrix
  3484. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3485. */
  3486. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3487. /**
  3488. * Creates a right-handed perspective projection matrix
  3489. * @param fov defines the horizontal field of view
  3490. * @param aspect defines the aspect ratio
  3491. * @param znear defines the near clip plane
  3492. * @param zfar defines the far clip plane
  3493. * @returns a new matrix as a right-handed perspective projection matrix
  3494. */
  3495. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3496. /**
  3497. * Stores a right-handed perspective projection into a given matrix
  3498. * @param fov defines the horizontal field of view
  3499. * @param aspect defines the aspect ratio
  3500. * @param znear defines the near clip plane
  3501. * @param zfar defines the far clip plane
  3502. * @param result defines the target matrix
  3503. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3504. */
  3505. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3506. /**
  3507. * Stores a perspective projection for WebVR info a given matrix
  3508. * @param fov defines the field of view
  3509. * @param znear defines the near clip plane
  3510. * @param zfar defines the far clip plane
  3511. * @param result defines the target matrix
  3512. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3513. */
  3514. static PerspectiveFovWebVRToRef(fov: {
  3515. upDegrees: number;
  3516. downDegrees: number;
  3517. leftDegrees: number;
  3518. rightDegrees: number;
  3519. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3520. /**
  3521. * Computes a complete transformation matrix
  3522. * @param viewport defines the viewport to use
  3523. * @param world defines the world matrix
  3524. * @param view defines the view matrix
  3525. * @param projection defines the projection matrix
  3526. * @param zmin defines the near clip plane
  3527. * @param zmax defines the far clip plane
  3528. * @returns the transformation matrix
  3529. */
  3530. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3531. /**
  3532. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3533. * @param matrix defines the matrix to use
  3534. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3535. */
  3536. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3537. /**
  3538. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3539. * @param matrix defines the matrix to use
  3540. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3541. */
  3542. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3543. /**
  3544. * Compute the transpose of a given matrix
  3545. * @param matrix defines the matrix to transpose
  3546. * @returns the new matrix
  3547. */
  3548. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3549. /**
  3550. * Compute the transpose of a matrix and store it in a target matrix
  3551. * @param matrix defines the matrix to transpose
  3552. * @param result defines the target matrix
  3553. */
  3554. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3555. /**
  3556. * Computes a reflection matrix from a plane
  3557. * @param plane defines the reflection plane
  3558. * @returns a new matrix
  3559. */
  3560. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3561. /**
  3562. * Computes a reflection matrix from a plane
  3563. * @param plane defines the reflection plane
  3564. * @param result defines the target matrix
  3565. */
  3566. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3567. /**
  3568. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3569. * @param xaxis defines the value of the 1st axis
  3570. * @param yaxis defines the value of the 2nd axis
  3571. * @param zaxis defines the value of the 3rd axis
  3572. * @param result defines the target matrix
  3573. */
  3574. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3575. /**
  3576. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3577. * @param quat defines the quaternion to use
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3581. }
  3582. /**
  3583. * Represens a plane by the equation ax + by + cz + d = 0
  3584. */
  3585. export class Plane {
  3586. /**
  3587. * Normal of the plane (a,b,c)
  3588. */
  3589. normal: Vector3;
  3590. /**
  3591. * d component of the plane
  3592. */
  3593. d: number;
  3594. /**
  3595. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3596. * @param a a component of the plane
  3597. * @param b b component of the plane
  3598. * @param c c component of the plane
  3599. * @param d d component of the plane
  3600. */
  3601. constructor(a: number, b: number, c: number, d: number);
  3602. /**
  3603. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3604. */
  3605. asArray(): number[];
  3606. /**
  3607. * @returns a new plane copied from the current Plane.
  3608. */
  3609. clone(): Plane;
  3610. /**
  3611. * @returns the string "Plane".
  3612. */
  3613. getClassName(): string;
  3614. /**
  3615. * @returns the Plane hash code.
  3616. */
  3617. getHashCode(): number;
  3618. /**
  3619. * Normalize the current Plane in place.
  3620. * @returns the updated Plane.
  3621. */
  3622. normalize(): Plane;
  3623. /**
  3624. * Applies a transformation the plane and returns the result
  3625. * @param transformation the transformation matrix to be applied to the plane
  3626. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3627. */
  3628. transform(transformation: DeepImmutable<Matrix>): Plane;
  3629. /**
  3630. * Calcualtte the dot product between the point and the plane normal
  3631. * @param point point to calculate the dot product with
  3632. * @returns the dot product (float) of the point coordinates and the plane normal.
  3633. */
  3634. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3635. /**
  3636. * Updates the current Plane from the plane defined by the three given points.
  3637. * @param point1 one of the points used to contruct the plane
  3638. * @param point2 one of the points used to contruct the plane
  3639. * @param point3 one of the points used to contruct the plane
  3640. * @returns the updated Plane.
  3641. */
  3642. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3643. /**
  3644. * Checks if the plane is facing a given direction
  3645. * @param direction the direction to check if the plane is facing
  3646. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3647. * @returns True is the vector "direction" is the same side than the plane normal.
  3648. */
  3649. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3650. /**
  3651. * Calculates the distance to a point
  3652. * @param point point to calculate distance to
  3653. * @returns the signed distance (float) from the given point to the Plane.
  3654. */
  3655. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3656. /**
  3657. * Creates a plane from an array
  3658. * @param array the array to create a plane from
  3659. * @returns a new Plane from the given array.
  3660. */
  3661. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3662. /**
  3663. * Creates a plane from three points
  3664. * @param point1 point used to create the plane
  3665. * @param point2 point used to create the plane
  3666. * @param point3 point used to create the plane
  3667. * @returns a new Plane defined by the three given points.
  3668. */
  3669. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3670. /**
  3671. * Creates a plane from an origin point and a normal
  3672. * @param origin origin of the plane to be constructed
  3673. * @param normal normal of the plane to be constructed
  3674. * @returns a new Plane the normal vector to this plane at the given origin point.
  3675. * Note : the vector "normal" is updated because normalized.
  3676. */
  3677. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3678. /**
  3679. * Calculates the distance from a plane and a point
  3680. * @param origin origin of the plane to be constructed
  3681. * @param normal normal of the plane to be constructed
  3682. * @param point point to calculate distance to
  3683. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3684. */
  3685. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3686. }
  3687. /**
  3688. * Class used to represent a viewport on screen
  3689. */
  3690. export class Viewport {
  3691. /** viewport left coordinate */
  3692. x: number;
  3693. /** viewport top coordinate */
  3694. y: number;
  3695. /**viewport width */
  3696. width: number;
  3697. /** viewport height */
  3698. height: number;
  3699. /**
  3700. * Creates a Viewport object located at (x, y) and sized (width, height)
  3701. * @param x defines viewport left coordinate
  3702. * @param y defines viewport top coordinate
  3703. * @param width defines the viewport width
  3704. * @param height defines the viewport height
  3705. */
  3706. constructor(
  3707. /** viewport left coordinate */
  3708. x: number,
  3709. /** viewport top coordinate */
  3710. y: number,
  3711. /**viewport width */
  3712. width: number,
  3713. /** viewport height */
  3714. height: number);
  3715. /**
  3716. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3717. * @param renderWidth defines the rendering width
  3718. * @param renderHeight defines the rendering height
  3719. * @returns a new Viewport
  3720. */
  3721. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3722. /**
  3723. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3724. * @param renderWidth defines the rendering width
  3725. * @param renderHeight defines the rendering height
  3726. * @param ref defines the target viewport
  3727. * @returns the current viewport
  3728. */
  3729. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3730. /**
  3731. * Returns a new Viewport copied from the current one
  3732. * @returns a new Viewport
  3733. */
  3734. clone(): Viewport;
  3735. }
  3736. /**
  3737. * Reprasents a camera frustum
  3738. */
  3739. export class Frustum {
  3740. /**
  3741. * Gets the planes representing the frustum
  3742. * @param transform matrix to be applied to the returned planes
  3743. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3744. */
  3745. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3746. /**
  3747. * Gets the near frustum plane transformed by the transform matrix
  3748. * @param transform transformation matrix to be applied to the resulting frustum plane
  3749. * @param frustumPlane the resuling frustum plane
  3750. */
  3751. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3752. /**
  3753. * Gets the far frustum plane transformed by the transform matrix
  3754. * @param transform transformation matrix to be applied to the resulting frustum plane
  3755. * @param frustumPlane the resuling frustum plane
  3756. */
  3757. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3758. /**
  3759. * Gets the left frustum plane transformed by the transform matrix
  3760. * @param transform transformation matrix to be applied to the resulting frustum plane
  3761. * @param frustumPlane the resuling frustum plane
  3762. */
  3763. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3764. /**
  3765. * Gets the right frustum plane transformed by the transform matrix
  3766. * @param transform transformation matrix to be applied to the resulting frustum plane
  3767. * @param frustumPlane the resuling frustum plane
  3768. */
  3769. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3770. /**
  3771. * Gets the top frustum plane transformed by the transform matrix
  3772. * @param transform transformation matrix to be applied to the resulting frustum plane
  3773. * @param frustumPlane the resuling frustum plane
  3774. */
  3775. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3776. /**
  3777. * Gets the bottom frustum plane transformed by the transform matrix
  3778. * @param transform transformation matrix to be applied to the resulting frustum plane
  3779. * @param frustumPlane the resuling frustum plane
  3780. */
  3781. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3782. /**
  3783. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3784. * @param transform transformation matrix to be applied to the resulting frustum planes
  3785. * @param frustumPlanes the resuling frustum planes
  3786. */
  3787. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3788. }
  3789. /** Defines supported spaces */
  3790. export enum Space {
  3791. /** Local (object) space */
  3792. LOCAL = 0,
  3793. /** World space */
  3794. WORLD = 1,
  3795. /** Bone space */
  3796. BONE = 2
  3797. }
  3798. /** Defines the 3 main axes */
  3799. export class Axis {
  3800. /** X axis */
  3801. static X: Vector3;
  3802. /** Y axis */
  3803. static Y: Vector3;
  3804. /** Z axis */
  3805. static Z: Vector3;
  3806. }
  3807. /** Class used to represent a Bezier curve */
  3808. export class BezierCurve {
  3809. /**
  3810. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3811. * @param t defines the time
  3812. * @param x1 defines the left coordinate on X axis
  3813. * @param y1 defines the left coordinate on Y axis
  3814. * @param x2 defines the right coordinate on X axis
  3815. * @param y2 defines the right coordinate on Y axis
  3816. * @returns the interpolated value
  3817. */
  3818. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3819. }
  3820. /**
  3821. * Defines potential orientation for back face culling
  3822. */
  3823. export enum Orientation {
  3824. /**
  3825. * Clockwise
  3826. */
  3827. CW = 0,
  3828. /** Counter clockwise */
  3829. CCW = 1
  3830. }
  3831. /**
  3832. * Defines angle representation
  3833. */
  3834. export class Angle {
  3835. private _radians;
  3836. /**
  3837. * Creates an Angle object of "radians" radians (float).
  3838. * @param radians the angle in radians
  3839. */
  3840. constructor(radians: number);
  3841. /**
  3842. * Get value in degrees
  3843. * @returns the Angle value in degrees (float)
  3844. */
  3845. degrees(): number;
  3846. /**
  3847. * Get value in radians
  3848. * @returns the Angle value in radians (float)
  3849. */
  3850. radians(): number;
  3851. /**
  3852. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3853. * @param a defines first vector
  3854. * @param b defines second vector
  3855. * @returns a new Angle
  3856. */
  3857. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3858. /**
  3859. * Gets a new Angle object from the given float in radians
  3860. * @param radians defines the angle value in radians
  3861. * @returns a new Angle
  3862. */
  3863. static FromRadians(radians: number): Angle;
  3864. /**
  3865. * Gets a new Angle object from the given float in degrees
  3866. * @param degrees defines the angle value in degrees
  3867. * @returns a new Angle
  3868. */
  3869. static FromDegrees(degrees: number): Angle;
  3870. }
  3871. /**
  3872. * This represents an arc in a 2d space.
  3873. */
  3874. export class Arc2 {
  3875. /** Defines the start point of the arc */
  3876. startPoint: Vector2;
  3877. /** Defines the mid point of the arc */
  3878. midPoint: Vector2;
  3879. /** Defines the end point of the arc */
  3880. endPoint: Vector2;
  3881. /**
  3882. * Defines the center point of the arc.
  3883. */
  3884. centerPoint: Vector2;
  3885. /**
  3886. * Defines the radius of the arc.
  3887. */
  3888. radius: number;
  3889. /**
  3890. * Defines the angle of the arc (from mid point to end point).
  3891. */
  3892. angle: Angle;
  3893. /**
  3894. * Defines the start angle of the arc (from start point to middle point).
  3895. */
  3896. startAngle: Angle;
  3897. /**
  3898. * Defines the orientation of the arc (clock wise/counter clock wise).
  3899. */
  3900. orientation: Orientation;
  3901. /**
  3902. * Creates an Arc object from the three given points : start, middle and end.
  3903. * @param startPoint Defines the start point of the arc
  3904. * @param midPoint Defines the midlle point of the arc
  3905. * @param endPoint Defines the end point of the arc
  3906. */
  3907. constructor(
  3908. /** Defines the start point of the arc */
  3909. startPoint: Vector2,
  3910. /** Defines the mid point of the arc */
  3911. midPoint: Vector2,
  3912. /** Defines the end point of the arc */
  3913. endPoint: Vector2);
  3914. }
  3915. /**
  3916. * Represents a 2D path made up of multiple 2D points
  3917. */
  3918. export class Path2 {
  3919. private _points;
  3920. private _length;
  3921. /**
  3922. * If the path start and end point are the same
  3923. */
  3924. closed: boolean;
  3925. /**
  3926. * Creates a Path2 object from the starting 2D coordinates x and y.
  3927. * @param x the starting points x value
  3928. * @param y the starting points y value
  3929. */
  3930. constructor(x: number, y: number);
  3931. /**
  3932. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3933. * @param x the added points x value
  3934. * @param y the added points y value
  3935. * @returns the updated Path2.
  3936. */
  3937. addLineTo(x: number, y: number): Path2;
  3938. /**
  3939. * 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.
  3940. * @param midX middle point x value
  3941. * @param midY middle point y value
  3942. * @param endX end point x value
  3943. * @param endY end point y value
  3944. * @param numberOfSegments (default: 36)
  3945. * @returns the updated Path2.
  3946. */
  3947. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3948. /**
  3949. * Closes the Path2.
  3950. * @returns the Path2.
  3951. */
  3952. close(): Path2;
  3953. /**
  3954. * Gets the sum of the distance between each sequential point in the path
  3955. * @returns the Path2 total length (float).
  3956. */
  3957. length(): number;
  3958. /**
  3959. * Gets the points which construct the path
  3960. * @returns the Path2 internal array of points.
  3961. */
  3962. getPoints(): Vector2[];
  3963. /**
  3964. * Retreives the point at the distance aways from the starting point
  3965. * @param normalizedLengthPosition the length along the path to retreive the point from
  3966. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3967. */
  3968. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3969. /**
  3970. * Creates a new path starting from an x and y position
  3971. * @param x starting x value
  3972. * @param y starting y value
  3973. * @returns a new Path2 starting at the coordinates (x, y).
  3974. */
  3975. static StartingAt(x: number, y: number): Path2;
  3976. }
  3977. /**
  3978. * Represents a 3D path made up of multiple 3D points
  3979. */
  3980. export class Path3D {
  3981. /**
  3982. * an array of Vector3, the curve axis of the Path3D
  3983. */
  3984. path: Vector3[];
  3985. private _curve;
  3986. private _distances;
  3987. private _tangents;
  3988. private _normals;
  3989. private _binormals;
  3990. private _raw;
  3991. /**
  3992. * new Path3D(path, normal, raw)
  3993. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3994. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3995. * @param path an array of Vector3, the curve axis of the Path3D
  3996. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3997. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3998. */
  3999. constructor(
  4000. /**
  4001. * an array of Vector3, the curve axis of the Path3D
  4002. */
  4003. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4004. /**
  4005. * Returns the Path3D array of successive Vector3 designing its curve.
  4006. * @returns the Path3D array of successive Vector3 designing its curve.
  4007. */
  4008. getCurve(): Vector3[];
  4009. /**
  4010. * Returns an array populated with tangent vectors on each Path3D curve point.
  4011. * @returns an array populated with tangent vectors on each Path3D curve point.
  4012. */
  4013. getTangents(): Vector3[];
  4014. /**
  4015. * Returns an array populated with normal vectors on each Path3D curve point.
  4016. * @returns an array populated with normal vectors on each Path3D curve point.
  4017. */
  4018. getNormals(): Vector3[];
  4019. /**
  4020. * Returns an array populated with binormal vectors on each Path3D curve point.
  4021. * @returns an array populated with binormal vectors on each Path3D curve point.
  4022. */
  4023. getBinormals(): Vector3[];
  4024. /**
  4025. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4026. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4027. */
  4028. getDistances(): number[];
  4029. /**
  4030. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4031. * @param path path which all values are copied into the curves points
  4032. * @param firstNormal which should be projected onto the curve
  4033. * @returns the same object updated.
  4034. */
  4035. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4036. private _compute;
  4037. private _getFirstNonNullVector;
  4038. private _getLastNonNullVector;
  4039. private _normalVector;
  4040. }
  4041. /**
  4042. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4043. * A Curve3 is designed from a series of successive Vector3.
  4044. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4045. */
  4046. export class Curve3 {
  4047. private _points;
  4048. private _length;
  4049. /**
  4050. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4051. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4052. * @param v1 (Vector3) the control point
  4053. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4054. * @param nbPoints (integer) the wanted number of points in the curve
  4055. * @returns the created Curve3
  4056. */
  4057. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4058. /**
  4059. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4060. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4061. * @param v1 (Vector3) the first control point
  4062. * @param v2 (Vector3) the second control point
  4063. * @param v3 (Vector3) the end point of the Cubic Bezier
  4064. * @param nbPoints (integer) the wanted number of points in the curve
  4065. * @returns the created Curve3
  4066. */
  4067. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4068. /**
  4069. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4070. * @param p1 (Vector3) the origin point of the Hermite Spline
  4071. * @param t1 (Vector3) the tangent vector at the origin point
  4072. * @param p2 (Vector3) the end point of the Hermite Spline
  4073. * @param t2 (Vector3) the tangent vector at the end point
  4074. * @param nbPoints (integer) the wanted number of points in the curve
  4075. * @returns the created Curve3
  4076. */
  4077. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4078. /**
  4079. * Returns a Curve3 object along a CatmullRom Spline curve :
  4080. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4081. * @param nbPoints (integer) the wanted number of points between each curve control points
  4082. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4083. * @returns the created Curve3
  4084. */
  4085. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4086. /**
  4087. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4088. * A Curve3 is designed from a series of successive Vector3.
  4089. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4090. * @param points points which make up the curve
  4091. */
  4092. constructor(points: Vector3[]);
  4093. /**
  4094. * @returns the Curve3 stored array of successive Vector3
  4095. */
  4096. getPoints(): Vector3[];
  4097. /**
  4098. * @returns the computed length (float) of the curve.
  4099. */
  4100. length(): number;
  4101. /**
  4102. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4103. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4104. * curveA and curveB keep unchanged.
  4105. * @param curve the curve to continue from this curve
  4106. * @returns the newly constructed curve
  4107. */
  4108. continue(curve: DeepImmutable<Curve3>): Curve3;
  4109. private _computeLength;
  4110. }
  4111. /**
  4112. * Contains position and normal vectors for a vertex
  4113. */
  4114. export class PositionNormalVertex {
  4115. /** the position of the vertex (defaut: 0,0,0) */
  4116. position: Vector3;
  4117. /** the normal of the vertex (defaut: 0,1,0) */
  4118. normal: Vector3;
  4119. /**
  4120. * Creates a PositionNormalVertex
  4121. * @param position the position of the vertex (defaut: 0,0,0)
  4122. * @param normal the normal of the vertex (defaut: 0,1,0)
  4123. */
  4124. constructor(
  4125. /** the position of the vertex (defaut: 0,0,0) */
  4126. position?: Vector3,
  4127. /** the normal of the vertex (defaut: 0,1,0) */
  4128. normal?: Vector3);
  4129. /**
  4130. * Clones the PositionNormalVertex
  4131. * @returns the cloned PositionNormalVertex
  4132. */
  4133. clone(): PositionNormalVertex;
  4134. }
  4135. /**
  4136. * Contains position, normal and uv vectors for a vertex
  4137. */
  4138. export class PositionNormalTextureVertex {
  4139. /** the position of the vertex (defaut: 0,0,0) */
  4140. position: Vector3;
  4141. /** the normal of the vertex (defaut: 0,1,0) */
  4142. normal: Vector3;
  4143. /** the uv of the vertex (default: 0,0) */
  4144. uv: Vector2;
  4145. /**
  4146. * Creates a PositionNormalTextureVertex
  4147. * @param position the position of the vertex (defaut: 0,0,0)
  4148. * @param normal the normal of the vertex (defaut: 0,1,0)
  4149. * @param uv the uv of the vertex (default: 0,0)
  4150. */
  4151. constructor(
  4152. /** the position of the vertex (defaut: 0,0,0) */
  4153. position?: Vector3,
  4154. /** the normal of the vertex (defaut: 0,1,0) */
  4155. normal?: Vector3,
  4156. /** the uv of the vertex (default: 0,0) */
  4157. uv?: Vector2);
  4158. /**
  4159. * Clones the PositionNormalTextureVertex
  4160. * @returns the cloned PositionNormalTextureVertex
  4161. */
  4162. clone(): PositionNormalTextureVertex;
  4163. }
  4164. /**
  4165. * @hidden
  4166. */
  4167. export class Tmp {
  4168. static Color3: Color3[];
  4169. static Color4: Color4[];
  4170. static Vector2: Vector2[];
  4171. static Vector3: Vector3[];
  4172. static Vector4: Vector4[];
  4173. static Quaternion: Quaternion[];
  4174. static Matrix: Matrix[];
  4175. }
  4176. }
  4177. declare module BABYLON {
  4178. /**
  4179. * Class used to enable access to offline support
  4180. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4181. */
  4182. export interface IOfflineProvider {
  4183. /**
  4184. * Gets a boolean indicating if scene must be saved in the database
  4185. */
  4186. enableSceneOffline: boolean;
  4187. /**
  4188. * Gets a boolean indicating if textures must be saved in the database
  4189. */
  4190. enableTexturesOffline: boolean;
  4191. /**
  4192. * Open the offline support and make it available
  4193. * @param successCallback defines the callback to call on success
  4194. * @param errorCallback defines the callback to call on error
  4195. */
  4196. open(successCallback: () => void, errorCallback: () => void): void;
  4197. /**
  4198. * Loads an image from the offline support
  4199. * @param url defines the url to load from
  4200. * @param image defines the target DOM image
  4201. */
  4202. loadImage(url: string, image: HTMLImageElement): void;
  4203. /**
  4204. * Loads a file from offline support
  4205. * @param url defines the URL to load from
  4206. * @param sceneLoaded defines a callback to call on success
  4207. * @param progressCallBack defines a callback to call when progress changed
  4208. * @param errorCallback defines a callback to call on error
  4209. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4210. */
  4211. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4212. }
  4213. }
  4214. declare module BABYLON {
  4215. /**
  4216. * A class serves as a medium between the observable and its observers
  4217. */
  4218. export class EventState {
  4219. /**
  4220. * Create a new EventState
  4221. * @param mask defines the mask associated with this state
  4222. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4223. * @param target defines the original target of the state
  4224. * @param currentTarget defines the current target of the state
  4225. */
  4226. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4227. /**
  4228. * Initialize the current event state
  4229. * @param mask defines the mask associated with this state
  4230. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4231. * @param target defines the original target of the state
  4232. * @param currentTarget defines the current target of the state
  4233. * @returns the current event state
  4234. */
  4235. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4236. /**
  4237. * An Observer can set this property to true to prevent subsequent observers of being notified
  4238. */
  4239. skipNextObservers: boolean;
  4240. /**
  4241. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4242. */
  4243. mask: number;
  4244. /**
  4245. * The object that originally notified the event
  4246. */
  4247. target?: any;
  4248. /**
  4249. * The current object in the bubbling phase
  4250. */
  4251. currentTarget?: any;
  4252. /**
  4253. * This will be populated with the return value of the last function that was executed.
  4254. * If it is the first function in the callback chain it will be the event data.
  4255. */
  4256. lastReturnValue?: any;
  4257. }
  4258. /**
  4259. * Represent an Observer registered to a given Observable object.
  4260. */
  4261. export class Observer<T> {
  4262. /**
  4263. * Defines the callback to call when the observer is notified
  4264. */
  4265. callback: (eventData: T, eventState: EventState) => void;
  4266. /**
  4267. * Defines the mask of the observer (used to filter notifications)
  4268. */
  4269. mask: number;
  4270. /**
  4271. * Defines the current scope used to restore the JS context
  4272. */
  4273. scope: any;
  4274. /** @hidden */
  4275. _willBeUnregistered: boolean;
  4276. /**
  4277. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4278. */
  4279. unregisterOnNextCall: boolean;
  4280. /**
  4281. * Creates a new observer
  4282. * @param callback defines the callback to call when the observer is notified
  4283. * @param mask defines the mask of the observer (used to filter notifications)
  4284. * @param scope defines the current scope used to restore the JS context
  4285. */
  4286. constructor(
  4287. /**
  4288. * Defines the callback to call when the observer is notified
  4289. */
  4290. callback: (eventData: T, eventState: EventState) => void,
  4291. /**
  4292. * Defines the mask of the observer (used to filter notifications)
  4293. */
  4294. mask: number,
  4295. /**
  4296. * Defines the current scope used to restore the JS context
  4297. */
  4298. scope?: any);
  4299. }
  4300. /**
  4301. * Represent a list of observers registered to multiple Observables object.
  4302. */
  4303. export class MultiObserver<T> {
  4304. private _observers;
  4305. private _observables;
  4306. /**
  4307. * Release associated resources
  4308. */
  4309. dispose(): void;
  4310. /**
  4311. * Raise a callback when one of the observable will notify
  4312. * @param observables defines a list of observables to watch
  4313. * @param callback defines the callback to call on notification
  4314. * @param mask defines the mask used to filter notifications
  4315. * @param scope defines the current scope used to restore the JS context
  4316. * @returns the new MultiObserver
  4317. */
  4318. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4319. }
  4320. /**
  4321. * The Observable class is a simple implementation of the Observable pattern.
  4322. *
  4323. * 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.
  4324. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4325. * 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).
  4326. * 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.
  4327. */
  4328. export class Observable<T> {
  4329. private _observers;
  4330. private _eventState;
  4331. private _onObserverAdded;
  4332. /**
  4333. * Creates a new observable
  4334. * @param onObserverAdded defines a callback to call when a new observer is added
  4335. */
  4336. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4337. /**
  4338. * Create a new Observer with the specified callback
  4339. * @param callback the callback that will be executed for that Observer
  4340. * @param mask the mask used to filter observers
  4341. * @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.
  4342. * @param scope optional scope for the callback to be called from
  4343. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4344. * @returns the new observer created for the callback
  4345. */
  4346. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4347. /**
  4348. * Create a new Observer with the specified callback and unregisters after the next notification
  4349. * @param callback the callback that will be executed for that Observer
  4350. * @returns the new observer created for the callback
  4351. */
  4352. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4353. /**
  4354. * Remove an Observer from the Observable object
  4355. * @param observer the instance of the Observer to remove
  4356. * @returns false if it doesn't belong to this Observable
  4357. */
  4358. remove(observer: Nullable<Observer<T>>): boolean;
  4359. /**
  4360. * Remove a callback from the Observable object
  4361. * @param callback the callback to remove
  4362. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4363. * @returns false if it doesn't belong to this Observable
  4364. */
  4365. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4366. private _deferUnregister;
  4367. private _remove;
  4368. /**
  4369. * Moves the observable to the top of the observer list making it get called first when notified
  4370. * @param observer the observer to move
  4371. */
  4372. makeObserverTopPriority(observer: Observer<T>): void;
  4373. /**
  4374. * Moves the observable to the bottom of the observer list making it get called last when notified
  4375. * @param observer the observer to move
  4376. */
  4377. makeObserverBottomPriority(observer: Observer<T>): void;
  4378. /**
  4379. * Notify all Observers by calling their respective callback with the given data
  4380. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4381. * @param eventData defines the data to send to all observers
  4382. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4383. * @param target defines the original target of the state
  4384. * @param currentTarget defines the current target of the state
  4385. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4386. */
  4387. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4388. /**
  4389. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4390. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4391. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4392. * and it is crucial that all callbacks will be executed.
  4393. * The order of the callbacks is kept, callbacks are not executed parallel.
  4394. *
  4395. * @param eventData The data to be sent to each callback
  4396. * @param mask is used to filter observers defaults to -1
  4397. * @param target defines the callback target (see EventState)
  4398. * @param currentTarget defines he current object in the bubbling phase
  4399. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4400. */
  4401. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4402. /**
  4403. * Notify a specific observer
  4404. * @param observer defines the observer to notify
  4405. * @param eventData defines the data to be sent to each callback
  4406. * @param mask is used to filter observers defaults to -1
  4407. */
  4408. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4409. /**
  4410. * Gets a boolean indicating if the observable has at least one observer
  4411. * @returns true is the Observable has at least one Observer registered
  4412. */
  4413. hasObservers(): boolean;
  4414. /**
  4415. * Clear the list of observers
  4416. */
  4417. clear(): void;
  4418. /**
  4419. * Clone the current observable
  4420. * @returns a new observable
  4421. */
  4422. clone(): Observable<T>;
  4423. /**
  4424. * Does this observable handles observer registered with a given mask
  4425. * @param mask defines the mask to be tested
  4426. * @return whether or not one observer registered with the given mask is handeled
  4427. **/
  4428. hasSpecificMask(mask?: number): boolean;
  4429. }
  4430. }
  4431. declare module BABYLON {
  4432. /**
  4433. * Class used to help managing file picking and drag'n'drop
  4434. * File Storage
  4435. */
  4436. export class FilesInputStore {
  4437. /**
  4438. * List of files ready to be loaded
  4439. */
  4440. static FilesToLoad: {
  4441. [key: string]: File;
  4442. };
  4443. }
  4444. }
  4445. declare module BABYLON {
  4446. /** Defines the cross module used constants to avoid circular dependncies */
  4447. export class Constants {
  4448. /** Defines that alpha blending is disabled */
  4449. static readonly ALPHA_DISABLE: number;
  4450. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4451. static readonly ALPHA_ADD: number;
  4452. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4453. static readonly ALPHA_COMBINE: number;
  4454. /** Defines that alpha blending to DEST - SRC * DEST */
  4455. static readonly ALPHA_SUBTRACT: number;
  4456. /** Defines that alpha blending to SRC * DEST */
  4457. static readonly ALPHA_MULTIPLY: number;
  4458. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4459. static readonly ALPHA_MAXIMIZED: number;
  4460. /** Defines that alpha blending to SRC + DEST */
  4461. static readonly ALPHA_ONEONE: number;
  4462. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4463. static readonly ALPHA_PREMULTIPLIED: number;
  4464. /**
  4465. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4466. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4467. */
  4468. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4469. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4470. static readonly ALPHA_INTERPOLATE: number;
  4471. /**
  4472. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4473. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4474. */
  4475. static readonly ALPHA_SCREENMODE: number;
  4476. /** Defines that the ressource is not delayed*/
  4477. static readonly DELAYLOADSTATE_NONE: number;
  4478. /** Defines that the ressource was successfully delay loaded */
  4479. static readonly DELAYLOADSTATE_LOADED: number;
  4480. /** Defines that the ressource is currently delay loading */
  4481. static readonly DELAYLOADSTATE_LOADING: number;
  4482. /** Defines that the ressource is delayed and has not started loading */
  4483. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4484. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4485. static readonly NEVER: number;
  4486. /** 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 */
  4487. static readonly ALWAYS: number;
  4488. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4489. static readonly LESS: number;
  4490. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4491. static readonly EQUAL: number;
  4492. /** 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 */
  4493. static readonly LEQUAL: number;
  4494. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4495. static readonly GREATER: number;
  4496. /** 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 */
  4497. static readonly GEQUAL: number;
  4498. /** 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 */
  4499. static readonly NOTEQUAL: number;
  4500. /** Passed to stencilOperation to specify that stencil value must be kept */
  4501. static readonly KEEP: number;
  4502. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4503. static readonly REPLACE: number;
  4504. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4505. static readonly INCR: number;
  4506. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4507. static readonly DECR: number;
  4508. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4509. static readonly INVERT: number;
  4510. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4511. static readonly INCR_WRAP: number;
  4512. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4513. static readonly DECR_WRAP: number;
  4514. /** Texture is not repeating outside of 0..1 UVs */
  4515. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4516. /** Texture is repeating outside of 0..1 UVs */
  4517. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4518. /** Texture is repeating and mirrored */
  4519. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4520. /** ALPHA */
  4521. static readonly TEXTUREFORMAT_ALPHA: number;
  4522. /** LUMINANCE */
  4523. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4524. /** LUMINANCE_ALPHA */
  4525. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4526. /** RGB */
  4527. static readonly TEXTUREFORMAT_RGB: number;
  4528. /** RGBA */
  4529. static readonly TEXTUREFORMAT_RGBA: number;
  4530. /** RED */
  4531. static readonly TEXTUREFORMAT_RED: number;
  4532. /** RED (2nd reference) */
  4533. static readonly TEXTUREFORMAT_R: number;
  4534. /** RG */
  4535. static readonly TEXTUREFORMAT_RG: number;
  4536. /** RED_INTEGER */
  4537. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4538. /** RED_INTEGER (2nd reference) */
  4539. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4540. /** RG_INTEGER */
  4541. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4542. /** RGB_INTEGER */
  4543. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4544. /** RGBA_INTEGER */
  4545. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4546. /** UNSIGNED_BYTE */
  4547. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4548. /** UNSIGNED_BYTE (2nd reference) */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4550. /** FLOAT */
  4551. static readonly TEXTURETYPE_FLOAT: number;
  4552. /** HALF_FLOAT */
  4553. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4554. /** BYTE */
  4555. static readonly TEXTURETYPE_BYTE: number;
  4556. /** SHORT */
  4557. static readonly TEXTURETYPE_SHORT: number;
  4558. /** UNSIGNED_SHORT */
  4559. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4560. /** INT */
  4561. static readonly TEXTURETYPE_INT: number;
  4562. /** UNSIGNED_INT */
  4563. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4564. /** UNSIGNED_SHORT_4_4_4_4 */
  4565. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4566. /** UNSIGNED_SHORT_5_5_5_1 */
  4567. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4568. /** UNSIGNED_SHORT_5_6_5 */
  4569. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4570. /** UNSIGNED_INT_2_10_10_10_REV */
  4571. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4572. /** UNSIGNED_INT_24_8 */
  4573. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4574. /** UNSIGNED_INT_10F_11F_11F_REV */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4576. /** UNSIGNED_INT_5_9_9_9_REV */
  4577. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4578. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4579. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4580. /** nearest is mag = nearest and min = nearest and mip = linear */
  4581. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4582. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4583. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4584. /** Trilinear is mag = linear and min = linear and mip = linear */
  4585. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4586. /** nearest is mag = nearest and min = nearest and mip = linear */
  4587. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4588. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4589. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4590. /** Trilinear is mag = linear and min = linear and mip = linear */
  4591. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4592. /** mag = nearest and min = nearest and mip = nearest */
  4593. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4594. /** mag = nearest and min = linear and mip = nearest */
  4595. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4596. /** mag = nearest and min = linear and mip = linear */
  4597. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4598. /** mag = nearest and min = linear and mip = none */
  4599. static readonly TEXTURE_NEAREST_LINEAR: number;
  4600. /** mag = nearest and min = nearest and mip = none */
  4601. static readonly TEXTURE_NEAREST_NEAREST: number;
  4602. /** mag = linear and min = nearest and mip = nearest */
  4603. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4604. /** mag = linear and min = nearest and mip = linear */
  4605. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4606. /** mag = linear and min = linear and mip = none */
  4607. static readonly TEXTURE_LINEAR_LINEAR: number;
  4608. /** mag = linear and min = nearest and mip = none */
  4609. static readonly TEXTURE_LINEAR_NEAREST: number;
  4610. /** Explicit coordinates mode */
  4611. static readonly TEXTURE_EXPLICIT_MODE: number;
  4612. /** Spherical coordinates mode */
  4613. static readonly TEXTURE_SPHERICAL_MODE: number;
  4614. /** Planar coordinates mode */
  4615. static readonly TEXTURE_PLANAR_MODE: number;
  4616. /** Cubic coordinates mode */
  4617. static readonly TEXTURE_CUBIC_MODE: number;
  4618. /** Projection coordinates mode */
  4619. static readonly TEXTURE_PROJECTION_MODE: number;
  4620. /** Skybox coordinates mode */
  4621. static readonly TEXTURE_SKYBOX_MODE: number;
  4622. /** Inverse Cubic coordinates mode */
  4623. static readonly TEXTURE_INVCUBIC_MODE: number;
  4624. /** Equirectangular coordinates mode */
  4625. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4626. /** Equirectangular Fixed coordinates mode */
  4627. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4628. /** Equirectangular Fixed Mirrored coordinates mode */
  4629. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4630. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4631. static readonly SCALEMODE_FLOOR: number;
  4632. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4633. static readonly SCALEMODE_NEAREST: number;
  4634. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4635. static readonly SCALEMODE_CEILING: number;
  4636. /**
  4637. * The dirty texture flag value
  4638. */
  4639. static readonly MATERIAL_TextureDirtyFlag: number;
  4640. /**
  4641. * The dirty light flag value
  4642. */
  4643. static readonly MATERIAL_LightDirtyFlag: number;
  4644. /**
  4645. * The dirty fresnel flag value
  4646. */
  4647. static readonly MATERIAL_FresnelDirtyFlag: number;
  4648. /**
  4649. * The dirty attribute flag value
  4650. */
  4651. static readonly MATERIAL_AttributesDirtyFlag: number;
  4652. /**
  4653. * The dirty misc flag value
  4654. */
  4655. static readonly MATERIAL_MiscDirtyFlag: number;
  4656. /**
  4657. * The all dirty flag value
  4658. */
  4659. static readonly MATERIAL_AllDirtyFlag: number;
  4660. /**
  4661. * Returns the triangle fill mode
  4662. */
  4663. static readonly MATERIAL_TriangleFillMode: number;
  4664. /**
  4665. * Returns the wireframe mode
  4666. */
  4667. static readonly MATERIAL_WireFrameFillMode: number;
  4668. /**
  4669. * Returns the point fill mode
  4670. */
  4671. static readonly MATERIAL_PointFillMode: number;
  4672. /**
  4673. * Returns the point list draw mode
  4674. */
  4675. static readonly MATERIAL_PointListDrawMode: number;
  4676. /**
  4677. * Returns the line list draw mode
  4678. */
  4679. static readonly MATERIAL_LineListDrawMode: number;
  4680. /**
  4681. * Returns the line loop draw mode
  4682. */
  4683. static readonly MATERIAL_LineLoopDrawMode: number;
  4684. /**
  4685. * Returns the line strip draw mode
  4686. */
  4687. static readonly MATERIAL_LineStripDrawMode: number;
  4688. /**
  4689. * Returns the triangle strip draw mode
  4690. */
  4691. static readonly MATERIAL_TriangleStripDrawMode: number;
  4692. /**
  4693. * Returns the triangle fan draw mode
  4694. */
  4695. static readonly MATERIAL_TriangleFanDrawMode: number;
  4696. /**
  4697. * Stores the clock-wise side orientation
  4698. */
  4699. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4700. /**
  4701. * Stores the counter clock-wise side orientation
  4702. */
  4703. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4704. /**
  4705. * Nothing
  4706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4707. */
  4708. static readonly ACTION_NothingTrigger: number;
  4709. /**
  4710. * On pick
  4711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4712. */
  4713. static readonly ACTION_OnPickTrigger: number;
  4714. /**
  4715. * On left pick
  4716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4717. */
  4718. static readonly ACTION_OnLeftPickTrigger: number;
  4719. /**
  4720. * On right pick
  4721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4722. */
  4723. static readonly ACTION_OnRightPickTrigger: number;
  4724. /**
  4725. * On center pick
  4726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4727. */
  4728. static readonly ACTION_OnCenterPickTrigger: number;
  4729. /**
  4730. * On pick down
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPickDownTrigger: number;
  4734. /**
  4735. * On double pick
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnDoublePickTrigger: number;
  4739. /**
  4740. * On pick up
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPickUpTrigger: number;
  4744. /**
  4745. * On pick out.
  4746. * This trigger will only be raised if you also declared a OnPickDown
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnPickOutTrigger: number;
  4750. /**
  4751. * On long press
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnLongPressTrigger: number;
  4755. /**
  4756. * On pointer over
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPointerOverTrigger: number;
  4760. /**
  4761. * On pointer out
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnPointerOutTrigger: number;
  4765. /**
  4766. * On every frame
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnEveryFrameTrigger: number;
  4770. /**
  4771. * On intersection enter
  4772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4773. */
  4774. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4775. /**
  4776. * On intersection exit
  4777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4778. */
  4779. static readonly ACTION_OnIntersectionExitTrigger: number;
  4780. /**
  4781. * On key down
  4782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4783. */
  4784. static readonly ACTION_OnKeyDownTrigger: number;
  4785. /**
  4786. * On key up
  4787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4788. */
  4789. static readonly ACTION_OnKeyUpTrigger: number;
  4790. /**
  4791. * Billboard mode will only apply to Y axis
  4792. */
  4793. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4794. /**
  4795. * Billboard mode will apply to all axes
  4796. */
  4797. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4798. /**
  4799. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4800. */
  4801. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4802. /**
  4803. * Gets or sets base Assets URL
  4804. */
  4805. static readonly PARTICLES_BaseAssetsUrl: string;
  4806. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4807. * Test order :
  4808. * Is the bounding sphere outside the frustum ?
  4809. * If not, are the bounding box vertices outside the frustum ?
  4810. * It not, then the cullable object is in the frustum.
  4811. */
  4812. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4813. /** Culling strategy : Bounding Sphere Only.
  4814. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4815. * It's also less accurate than the standard because some not visible objects can still be selected.
  4816. * Test : is the bounding sphere outside the frustum ?
  4817. * If not, then the cullable object is in the frustum.
  4818. */
  4819. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4820. /** Culling strategy : Optimistic Inclusion.
  4821. * This in an inclusion test first, then the standard exclusion test.
  4822. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4823. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4824. * Anyway, it's as accurate as the standard strategy.
  4825. * Test :
  4826. * Is the cullable object bounding sphere center in the frustum ?
  4827. * If not, apply the default culling strategy.
  4828. */
  4829. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4830. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4831. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4832. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4833. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4834. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4835. * Test :
  4836. * Is the cullable object bounding sphere center in the frustum ?
  4837. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4838. */
  4839. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4840. /**
  4841. * No logging while loading
  4842. */
  4843. static readonly SCENELOADER_NO_LOGGING: number;
  4844. /**
  4845. * Minimal logging while loading
  4846. */
  4847. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4848. /**
  4849. * Summary logging while loading
  4850. */
  4851. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4852. /**
  4853. * Detailled logging while loading
  4854. */
  4855. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4856. }
  4857. }
  4858. declare module BABYLON {
  4859. /**
  4860. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4861. * Babylon.js
  4862. */
  4863. export class DomManagement {
  4864. /**
  4865. * Checks if the window object exists
  4866. * @returns true if the window object exists
  4867. */
  4868. static IsWindowObjectExist(): boolean;
  4869. /**
  4870. * Extracts text content from a DOM element hierarchy
  4871. * @param element defines the root element
  4872. * @returns a string
  4873. */
  4874. static GetDOMTextContent(element: HTMLElement): string;
  4875. }
  4876. }
  4877. declare module BABYLON {
  4878. /**
  4879. * Logger used througouht the application to allow configuration of
  4880. * the log level required for the messages.
  4881. */
  4882. export class Logger {
  4883. /**
  4884. * No log
  4885. */
  4886. static readonly NoneLogLevel: number;
  4887. /**
  4888. * Only message logs
  4889. */
  4890. static readonly MessageLogLevel: number;
  4891. /**
  4892. * Only warning logs
  4893. */
  4894. static readonly WarningLogLevel: number;
  4895. /**
  4896. * Only error logs
  4897. */
  4898. static readonly ErrorLogLevel: number;
  4899. /**
  4900. * All logs
  4901. */
  4902. static readonly AllLogLevel: number;
  4903. private static _LogCache;
  4904. /**
  4905. * Gets a value indicating the number of loading errors
  4906. * @ignorenaming
  4907. */
  4908. static errorsCount: number;
  4909. /**
  4910. * Callback called when a new log is added
  4911. */
  4912. static OnNewCacheEntry: (entry: string) => void;
  4913. private static _AddLogEntry;
  4914. private static _FormatMessage;
  4915. private static _LogDisabled;
  4916. private static _LogEnabled;
  4917. private static _WarnDisabled;
  4918. private static _WarnEnabled;
  4919. private static _ErrorDisabled;
  4920. private static _ErrorEnabled;
  4921. /**
  4922. * Log a message to the console
  4923. */
  4924. static Log: (message: string) => void;
  4925. /**
  4926. * Write a warning message to the console
  4927. */
  4928. static Warn: (message: string) => void;
  4929. /**
  4930. * Write an error message to the console
  4931. */
  4932. static Error: (message: string) => void;
  4933. /**
  4934. * Gets current log cache (list of logs)
  4935. */
  4936. static readonly LogCache: string;
  4937. /**
  4938. * Clears the log cache
  4939. */
  4940. static ClearLogCache(): void;
  4941. /**
  4942. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4943. */
  4944. static LogLevels: number;
  4945. }
  4946. }
  4947. declare module BABYLON {
  4948. /** @hidden */
  4949. export class _TypeStore {
  4950. /** @hidden */
  4951. static RegisteredTypes: {
  4952. [key: string]: Object;
  4953. };
  4954. /** @hidden */
  4955. static GetClass(fqdn: string): any;
  4956. }
  4957. }
  4958. declare module BABYLON {
  4959. /**
  4960. * Class containing a set of static utilities functions for deep copy.
  4961. */
  4962. export class DeepCopier {
  4963. /**
  4964. * Tries to copy an object by duplicating every property
  4965. * @param source defines the source object
  4966. * @param destination defines the target object
  4967. * @param doNotCopyList defines a list of properties to avoid
  4968. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4969. */
  4970. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4971. }
  4972. }
  4973. declare module BABYLON {
  4974. /**
  4975. * Class containing a set of static utilities functions for precision date
  4976. */
  4977. export class PrecisionDate {
  4978. /**
  4979. * Gets either window.performance.now() if supported or Date.now() else
  4980. */
  4981. static readonly Now: number;
  4982. }
  4983. }
  4984. declare module BABYLON {
  4985. /** @hidden */
  4986. export class _DevTools {
  4987. static WarnImport(name: string): string;
  4988. }
  4989. }
  4990. declare module BABYLON {
  4991. /**
  4992. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4993. */
  4994. export class WebRequest {
  4995. private _xhr;
  4996. /**
  4997. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4998. * i.e. when loading files, where the server/service expects an Authorization header
  4999. */
  5000. static CustomRequestHeaders: {
  5001. [key: string]: string;
  5002. };
  5003. /**
  5004. * Add callback functions in this array to update all the requests before they get sent to the network
  5005. */
  5006. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5007. private _injectCustomRequestHeaders;
  5008. /**
  5009. * Gets or sets a function to be called when loading progress changes
  5010. */
  5011. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5012. /**
  5013. * Returns client's state
  5014. */
  5015. readonly readyState: number;
  5016. /**
  5017. * Returns client's status
  5018. */
  5019. readonly status: number;
  5020. /**
  5021. * Returns client's status as a text
  5022. */
  5023. readonly statusText: string;
  5024. /**
  5025. * Returns client's response
  5026. */
  5027. readonly response: any;
  5028. /**
  5029. * Returns client's response url
  5030. */
  5031. readonly responseURL: string;
  5032. /**
  5033. * Returns client's response as text
  5034. */
  5035. readonly responseText: string;
  5036. /**
  5037. * Gets or sets the expected response type
  5038. */
  5039. responseType: XMLHttpRequestResponseType;
  5040. /** @hidden */
  5041. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5042. /** @hidden */
  5043. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5044. /**
  5045. * Cancels any network activity
  5046. */
  5047. abort(): void;
  5048. /**
  5049. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5050. * @param body defines an optional request body
  5051. */
  5052. send(body?: Document | BodyInit | null): void;
  5053. /**
  5054. * Sets the request method, request URL
  5055. * @param method defines the method to use (GET, POST, etc..)
  5056. * @param url defines the url to connect with
  5057. */
  5058. open(method: string, url: string): void;
  5059. }
  5060. }
  5061. declare module BABYLON {
  5062. /**
  5063. * Class used to evalaute queries containing `and` and `or` operators
  5064. */
  5065. export class AndOrNotEvaluator {
  5066. /**
  5067. * Evaluate a query
  5068. * @param query defines the query to evaluate
  5069. * @param evaluateCallback defines the callback used to filter result
  5070. * @returns true if the query matches
  5071. */
  5072. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5073. private static _HandleParenthesisContent;
  5074. private static _SimplifyNegation;
  5075. }
  5076. }
  5077. declare module BABYLON {
  5078. /**
  5079. * Class used to store custom tags
  5080. */
  5081. export class Tags {
  5082. /**
  5083. * Adds support for tags on the given object
  5084. * @param obj defines the object to use
  5085. */
  5086. static EnableFor(obj: any): void;
  5087. /**
  5088. * Removes tags support
  5089. * @param obj defines the object to use
  5090. */
  5091. static DisableFor(obj: any): void;
  5092. /**
  5093. * Gets a boolean indicating if the given object has tags
  5094. * @param obj defines the object to use
  5095. * @returns a boolean
  5096. */
  5097. static HasTags(obj: any): boolean;
  5098. /**
  5099. * Gets the tags available on a given object
  5100. * @param obj defines the object to use
  5101. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5102. * @returns the tags
  5103. */
  5104. static GetTags(obj: any, asString?: boolean): any;
  5105. /**
  5106. * Adds tags to an object
  5107. * @param obj defines the object to use
  5108. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5109. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5110. */
  5111. static AddTagsTo(obj: any, tagsString: string): void;
  5112. /**
  5113. * @hidden
  5114. */
  5115. static _AddTagTo(obj: any, tag: string): void;
  5116. /**
  5117. * Removes specific tags from a specific object
  5118. * @param obj defines the object to use
  5119. * @param tagsString defines the tags to remove
  5120. */
  5121. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5122. /**
  5123. * @hidden
  5124. */
  5125. static _RemoveTagFrom(obj: any, tag: string): void;
  5126. /**
  5127. * Defines if tags hosted on an object match a given query
  5128. * @param obj defines the object to use
  5129. * @param tagsQuery defines the tag query
  5130. * @returns a boolean
  5131. */
  5132. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5133. }
  5134. }
  5135. declare module BABYLON {
  5136. /**
  5137. * Manages the defines for the Material
  5138. */
  5139. export class MaterialDefines {
  5140. private _keys;
  5141. private _isDirty;
  5142. /** @hidden */
  5143. _renderId: number;
  5144. /** @hidden */
  5145. _areLightsDirty: boolean;
  5146. /** @hidden */
  5147. _areAttributesDirty: boolean;
  5148. /** @hidden */
  5149. _areTexturesDirty: boolean;
  5150. /** @hidden */
  5151. _areFresnelDirty: boolean;
  5152. /** @hidden */
  5153. _areMiscDirty: boolean;
  5154. /** @hidden */
  5155. _areImageProcessingDirty: boolean;
  5156. /** @hidden */
  5157. _normals: boolean;
  5158. /** @hidden */
  5159. _uvs: boolean;
  5160. /** @hidden */
  5161. _needNormals: boolean;
  5162. /** @hidden */
  5163. _needUVs: boolean;
  5164. /**
  5165. * Specifies if the material needs to be re-calculated
  5166. */
  5167. readonly isDirty: boolean;
  5168. /**
  5169. * Marks the material to indicate that it has been re-calculated
  5170. */
  5171. markAsProcessed(): void;
  5172. /**
  5173. * Marks the material to indicate that it needs to be re-calculated
  5174. */
  5175. markAsUnprocessed(): void;
  5176. /**
  5177. * Marks the material to indicate all of its defines need to be re-calculated
  5178. */
  5179. markAllAsDirty(): void;
  5180. /**
  5181. * Marks the material to indicate that image processing needs to be re-calculated
  5182. */
  5183. markAsImageProcessingDirty(): void;
  5184. /**
  5185. * Marks the material to indicate the lights need to be re-calculated
  5186. */
  5187. markAsLightDirty(): void;
  5188. /**
  5189. * Marks the attribute state as changed
  5190. */
  5191. markAsAttributesDirty(): void;
  5192. /**
  5193. * Marks the texture state as changed
  5194. */
  5195. markAsTexturesDirty(): void;
  5196. /**
  5197. * Marks the fresnel state as changed
  5198. */
  5199. markAsFresnelDirty(): void;
  5200. /**
  5201. * Marks the misc state as changed
  5202. */
  5203. markAsMiscDirty(): void;
  5204. /**
  5205. * Rebuilds the material defines
  5206. */
  5207. rebuild(): void;
  5208. /**
  5209. * Specifies if two material defines are equal
  5210. * @param other - A material define instance to compare to
  5211. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5212. */
  5213. isEqual(other: MaterialDefines): boolean;
  5214. /**
  5215. * Clones this instance's defines to another instance
  5216. * @param other - material defines to clone values to
  5217. */
  5218. cloneTo(other: MaterialDefines): void;
  5219. /**
  5220. * Resets the material define values
  5221. */
  5222. reset(): void;
  5223. /**
  5224. * Converts the material define values to a string
  5225. * @returns - String of material define information
  5226. */
  5227. toString(): string;
  5228. }
  5229. }
  5230. declare module BABYLON {
  5231. /**
  5232. * Class used to store and describe the pipeline context associated with an effect
  5233. */
  5234. export interface IPipelineContext {
  5235. /**
  5236. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5237. */
  5238. isAsync: boolean;
  5239. /**
  5240. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5241. */
  5242. isReady: boolean;
  5243. }
  5244. }
  5245. declare module BABYLON {
  5246. /**
  5247. * Class used to store gfx data (like WebGLBuffer)
  5248. */
  5249. export class DataBuffer {
  5250. /**
  5251. * Gets or sets the number of objects referencing this buffer
  5252. */
  5253. references: number;
  5254. /** Gets or sets the size of the underlying buffer */
  5255. capacity: number;
  5256. /**
  5257. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5258. */
  5259. is32Bits: boolean;
  5260. /**
  5261. * Gets the underlying buffer
  5262. */
  5263. readonly underlyingResource: any;
  5264. }
  5265. }
  5266. declare module BABYLON {
  5267. /**
  5268. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5269. */
  5270. export class PerformanceMonitor {
  5271. private _enabled;
  5272. private _rollingFrameTime;
  5273. private _lastFrameTimeMs;
  5274. /**
  5275. * constructor
  5276. * @param frameSampleSize The number of samples required to saturate the sliding window
  5277. */
  5278. constructor(frameSampleSize?: number);
  5279. /**
  5280. * Samples current frame
  5281. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5282. */
  5283. sampleFrame(timeMs?: number): void;
  5284. /**
  5285. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5286. */
  5287. readonly averageFrameTime: number;
  5288. /**
  5289. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5290. */
  5291. readonly averageFrameTimeVariance: number;
  5292. /**
  5293. * Returns the frame time of the most recent frame
  5294. */
  5295. readonly instantaneousFrameTime: number;
  5296. /**
  5297. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5298. */
  5299. readonly averageFPS: number;
  5300. /**
  5301. * Returns the average framerate in frames per second using the most recent frame time
  5302. */
  5303. readonly instantaneousFPS: number;
  5304. /**
  5305. * Returns true if enough samples have been taken to completely fill the sliding window
  5306. */
  5307. readonly isSaturated: boolean;
  5308. /**
  5309. * Enables contributions to the sliding window sample set
  5310. */
  5311. enable(): void;
  5312. /**
  5313. * Disables contributions to the sliding window sample set
  5314. * Samples will not be interpolated over the disabled period
  5315. */
  5316. disable(): void;
  5317. /**
  5318. * Returns true if sampling is enabled
  5319. */
  5320. readonly isEnabled: boolean;
  5321. /**
  5322. * Resets performance monitor
  5323. */
  5324. reset(): void;
  5325. }
  5326. /**
  5327. * RollingAverage
  5328. *
  5329. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5330. */
  5331. export class RollingAverage {
  5332. /**
  5333. * Current average
  5334. */
  5335. average: number;
  5336. /**
  5337. * Current variance
  5338. */
  5339. variance: number;
  5340. protected _samples: Array<number>;
  5341. protected _sampleCount: number;
  5342. protected _pos: number;
  5343. protected _m2: number;
  5344. /**
  5345. * constructor
  5346. * @param length The number of samples required to saturate the sliding window
  5347. */
  5348. constructor(length: number);
  5349. /**
  5350. * Adds a sample to the sample set
  5351. * @param v The sample value
  5352. */
  5353. add(v: number): void;
  5354. /**
  5355. * Returns previously added values or null if outside of history or outside the sliding window domain
  5356. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5357. * @return Value previously recorded with add() or null if outside of range
  5358. */
  5359. history(i: number): number;
  5360. /**
  5361. * Returns true if enough samples have been taken to completely fill the sliding window
  5362. * @return true if sample-set saturated
  5363. */
  5364. isSaturated(): boolean;
  5365. /**
  5366. * Resets the rolling average (equivalent to 0 samples taken so far)
  5367. */
  5368. reset(): void;
  5369. /**
  5370. * Wraps a value around the sample range boundaries
  5371. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5372. * @return Wrapped position in sample range
  5373. */
  5374. protected _wrapPosition(i: number): number;
  5375. }
  5376. }
  5377. declare module BABYLON {
  5378. /**
  5379. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5380. * The underlying implementation relies on an associative array to ensure the best performances.
  5381. * The value can be anything including 'null' but except 'undefined'
  5382. */
  5383. export class StringDictionary<T> {
  5384. /**
  5385. * This will clear this dictionary and copy the content from the 'source' one.
  5386. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5387. * @param source the dictionary to take the content from and copy to this dictionary
  5388. */
  5389. copyFrom(source: StringDictionary<T>): void;
  5390. /**
  5391. * Get a value based from its key
  5392. * @param key the given key to get the matching value from
  5393. * @return the value if found, otherwise undefined is returned
  5394. */
  5395. get(key: string): T | undefined;
  5396. /**
  5397. * Get a value from its key or add it if it doesn't exist.
  5398. * This method will ensure you that a given key/data will be present in the dictionary.
  5399. * @param key the given key to get the matching value from
  5400. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5401. * The factory will only be invoked if there's no data for the given key.
  5402. * @return the value corresponding to the key.
  5403. */
  5404. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5405. /**
  5406. * Get a value from its key if present in the dictionary otherwise add it
  5407. * @param key the key to get the value from
  5408. * @param val if there's no such key/value pair in the dictionary add it with this value
  5409. * @return the value corresponding to the key
  5410. */
  5411. getOrAdd(key: string, val: T): T;
  5412. /**
  5413. * Check if there's a given key in the dictionary
  5414. * @param key the key to check for
  5415. * @return true if the key is present, false otherwise
  5416. */
  5417. contains(key: string): boolean;
  5418. /**
  5419. * Add a new key and its corresponding value
  5420. * @param key the key to add
  5421. * @param value the value corresponding to the key
  5422. * @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
  5423. */
  5424. add(key: string, value: T): boolean;
  5425. /**
  5426. * Update a specific value associated to a key
  5427. * @param key defines the key to use
  5428. * @param value defines the value to store
  5429. * @returns true if the value was updated (or false if the key was not found)
  5430. */
  5431. set(key: string, value: T): boolean;
  5432. /**
  5433. * Get the element of the given key and remove it from the dictionary
  5434. * @param key defines the key to search
  5435. * @returns the value associated with the key or null if not found
  5436. */
  5437. getAndRemove(key: string): Nullable<T>;
  5438. /**
  5439. * Remove a key/value from the dictionary.
  5440. * @param key the key to remove
  5441. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5442. */
  5443. remove(key: string): boolean;
  5444. /**
  5445. * Clear the whole content of the dictionary
  5446. */
  5447. clear(): void;
  5448. /**
  5449. * Gets the current count
  5450. */
  5451. readonly count: number;
  5452. /**
  5453. * Execute a callback on each key/val of the dictionary.
  5454. * Note that you can remove any element in this dictionary in the callback implementation
  5455. * @param callback the callback to execute on a given key/value pair
  5456. */
  5457. forEach(callback: (key: string, val: T) => void): void;
  5458. /**
  5459. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5460. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5461. * Note that you can remove any element in this dictionary in the callback implementation
  5462. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5463. * @returns the first item
  5464. */
  5465. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5466. private _count;
  5467. private _data;
  5468. }
  5469. }
  5470. declare module BABYLON {
  5471. /**
  5472. * Helper class that provides a small promise polyfill
  5473. */
  5474. export class PromisePolyfill {
  5475. /**
  5476. * Static function used to check if the polyfill is required
  5477. * If this is the case then the function will inject the polyfill to window.Promise
  5478. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5479. */
  5480. static Apply(force?: boolean): void;
  5481. }
  5482. }
  5483. declare module BABYLON {
  5484. /**
  5485. * Class used to store data that will be store in GPU memory
  5486. */
  5487. export class Buffer {
  5488. private _engine;
  5489. private _buffer;
  5490. /** @hidden */
  5491. _data: Nullable<DataArray>;
  5492. private _updatable;
  5493. private _instanced;
  5494. /**
  5495. * Gets the byte stride.
  5496. */
  5497. readonly byteStride: number;
  5498. /**
  5499. * Constructor
  5500. * @param engine the engine
  5501. * @param data the data to use for this buffer
  5502. * @param updatable whether the data is updatable
  5503. * @param stride the stride (optional)
  5504. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5505. * @param instanced whether the buffer is instanced (optional)
  5506. * @param useBytes set to true if the stride in in bytes (optional)
  5507. */
  5508. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5509. /**
  5510. * Create a new VertexBuffer based on the current buffer
  5511. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5512. * @param offset defines offset in the buffer (0 by default)
  5513. * @param size defines the size in floats of attributes (position is 3 for instance)
  5514. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5515. * @param instanced defines if the vertex buffer contains indexed data
  5516. * @param useBytes defines if the offset and stride are in bytes
  5517. * @returns the new vertex buffer
  5518. */
  5519. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5520. /**
  5521. * Gets a boolean indicating if the Buffer is updatable?
  5522. * @returns true if the buffer is updatable
  5523. */
  5524. isUpdatable(): boolean;
  5525. /**
  5526. * Gets current buffer's data
  5527. * @returns a DataArray or null
  5528. */
  5529. getData(): Nullable<DataArray>;
  5530. /**
  5531. * Gets underlying native buffer
  5532. * @returns underlying native buffer
  5533. */
  5534. getBuffer(): Nullable<DataBuffer>;
  5535. /**
  5536. * Gets the stride in float32 units (i.e. byte stride / 4).
  5537. * May not be an integer if the byte stride is not divisible by 4.
  5538. * DEPRECATED. Use byteStride instead.
  5539. * @returns the stride in float32 units
  5540. */
  5541. getStrideSize(): number;
  5542. /**
  5543. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5544. * @param data defines the data to store
  5545. */
  5546. create(data?: Nullable<DataArray>): void;
  5547. /** @hidden */
  5548. _rebuild(): void;
  5549. /**
  5550. * Update current buffer data
  5551. * @param data defines the data to store
  5552. */
  5553. update(data: DataArray): void;
  5554. /**
  5555. * Updates the data directly.
  5556. * @param data the new data
  5557. * @param offset the new offset
  5558. * @param vertexCount the vertex count (optional)
  5559. * @param useBytes set to true if the offset is in bytes
  5560. */
  5561. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5562. /**
  5563. * Release all resources
  5564. */
  5565. dispose(): void;
  5566. }
  5567. /**
  5568. * Specialized buffer used to store vertex data
  5569. */
  5570. export class VertexBuffer {
  5571. /** @hidden */
  5572. _buffer: Buffer;
  5573. private _kind;
  5574. private _size;
  5575. private _ownsBuffer;
  5576. private _instanced;
  5577. private _instanceDivisor;
  5578. /**
  5579. * The byte type.
  5580. */
  5581. static readonly BYTE: number;
  5582. /**
  5583. * The unsigned byte type.
  5584. */
  5585. static readonly UNSIGNED_BYTE: number;
  5586. /**
  5587. * The short type.
  5588. */
  5589. static readonly SHORT: number;
  5590. /**
  5591. * The unsigned short type.
  5592. */
  5593. static readonly UNSIGNED_SHORT: number;
  5594. /**
  5595. * The integer type.
  5596. */
  5597. static readonly INT: number;
  5598. /**
  5599. * The unsigned integer type.
  5600. */
  5601. static readonly UNSIGNED_INT: number;
  5602. /**
  5603. * The float type.
  5604. */
  5605. static readonly FLOAT: number;
  5606. /**
  5607. * Gets or sets the instance divisor when in instanced mode
  5608. */
  5609. instanceDivisor: number;
  5610. /**
  5611. * Gets the byte stride.
  5612. */
  5613. readonly byteStride: number;
  5614. /**
  5615. * Gets the byte offset.
  5616. */
  5617. readonly byteOffset: number;
  5618. /**
  5619. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5620. */
  5621. readonly normalized: boolean;
  5622. /**
  5623. * Gets the data type of each component in the array.
  5624. */
  5625. readonly type: number;
  5626. /**
  5627. * Constructor
  5628. * @param engine the engine
  5629. * @param data the data to use for this vertex buffer
  5630. * @param kind the vertex buffer kind
  5631. * @param updatable whether the data is updatable
  5632. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5633. * @param stride the stride (optional)
  5634. * @param instanced whether the buffer is instanced (optional)
  5635. * @param offset the offset of the data (optional)
  5636. * @param size the number of components (optional)
  5637. * @param type the type of the component (optional)
  5638. * @param normalized whether the data contains normalized data (optional)
  5639. * @param useBytes set to true if stride and offset are in bytes (optional)
  5640. */
  5641. 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);
  5642. /** @hidden */
  5643. _rebuild(): void;
  5644. /**
  5645. * Returns the kind of the VertexBuffer (string)
  5646. * @returns a string
  5647. */
  5648. getKind(): string;
  5649. /**
  5650. * Gets a boolean indicating if the VertexBuffer is updatable?
  5651. * @returns true if the buffer is updatable
  5652. */
  5653. isUpdatable(): boolean;
  5654. /**
  5655. * Gets current buffer's data
  5656. * @returns a DataArray or null
  5657. */
  5658. getData(): Nullable<DataArray>;
  5659. /**
  5660. * Gets underlying native buffer
  5661. * @returns underlying native buffer
  5662. */
  5663. getBuffer(): Nullable<DataBuffer>;
  5664. /**
  5665. * Gets the stride in float32 units (i.e. byte stride / 4).
  5666. * May not be an integer if the byte stride is not divisible by 4.
  5667. * DEPRECATED. Use byteStride instead.
  5668. * @returns the stride in float32 units
  5669. */
  5670. getStrideSize(): number;
  5671. /**
  5672. * Returns the offset as a multiple of the type byte length.
  5673. * DEPRECATED. Use byteOffset instead.
  5674. * @returns the offset in bytes
  5675. */
  5676. getOffset(): number;
  5677. /**
  5678. * Returns the number of components per vertex attribute (integer)
  5679. * @returns the size in float
  5680. */
  5681. getSize(): number;
  5682. /**
  5683. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5684. * @returns true if this buffer is instanced
  5685. */
  5686. getIsInstanced(): boolean;
  5687. /**
  5688. * Returns the instancing divisor, zero for non-instanced (integer).
  5689. * @returns a number
  5690. */
  5691. getInstanceDivisor(): number;
  5692. /**
  5693. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5694. * @param data defines the data to store
  5695. */
  5696. create(data?: DataArray): void;
  5697. /**
  5698. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5699. * This function will create a new buffer if the current one is not updatable
  5700. * @param data defines the data to store
  5701. */
  5702. update(data: DataArray): void;
  5703. /**
  5704. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5705. * Returns the directly updated WebGLBuffer.
  5706. * @param data the new data
  5707. * @param offset the new offset
  5708. * @param useBytes set to true if the offset is in bytes
  5709. */
  5710. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5711. /**
  5712. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5713. */
  5714. dispose(): void;
  5715. /**
  5716. * Enumerates each value of this vertex buffer as numbers.
  5717. * @param count the number of values to enumerate
  5718. * @param callback the callback function called for each value
  5719. */
  5720. forEach(count: number, callback: (value: number, index: number) => void): void;
  5721. /**
  5722. * Positions
  5723. */
  5724. static readonly PositionKind: string;
  5725. /**
  5726. * Normals
  5727. */
  5728. static readonly NormalKind: string;
  5729. /**
  5730. * Tangents
  5731. */
  5732. static readonly TangentKind: string;
  5733. /**
  5734. * Texture coordinates
  5735. */
  5736. static readonly UVKind: string;
  5737. /**
  5738. * Texture coordinates 2
  5739. */
  5740. static readonly UV2Kind: string;
  5741. /**
  5742. * Texture coordinates 3
  5743. */
  5744. static readonly UV3Kind: string;
  5745. /**
  5746. * Texture coordinates 4
  5747. */
  5748. static readonly UV4Kind: string;
  5749. /**
  5750. * Texture coordinates 5
  5751. */
  5752. static readonly UV5Kind: string;
  5753. /**
  5754. * Texture coordinates 6
  5755. */
  5756. static readonly UV6Kind: string;
  5757. /**
  5758. * Colors
  5759. */
  5760. static readonly ColorKind: string;
  5761. /**
  5762. * Matrix indices (for bones)
  5763. */
  5764. static readonly MatricesIndicesKind: string;
  5765. /**
  5766. * Matrix weights (for bones)
  5767. */
  5768. static readonly MatricesWeightsKind: string;
  5769. /**
  5770. * Additional matrix indices (for bones)
  5771. */
  5772. static readonly MatricesIndicesExtraKind: string;
  5773. /**
  5774. * Additional matrix weights (for bones)
  5775. */
  5776. static readonly MatricesWeightsExtraKind: string;
  5777. /**
  5778. * Deduces the stride given a kind.
  5779. * @param kind The kind string to deduce
  5780. * @returns The deduced stride
  5781. */
  5782. static DeduceStride(kind: string): number;
  5783. /**
  5784. * Gets the byte length of the given type.
  5785. * @param type the type
  5786. * @returns the number of bytes
  5787. */
  5788. static GetTypeByteLength(type: number): number;
  5789. /**
  5790. * Enumerates each value of the given parameters as numbers.
  5791. * @param data the data to enumerate
  5792. * @param byteOffset the byte offset of the data
  5793. * @param byteStride the byte stride of the data
  5794. * @param componentCount the number of components per element
  5795. * @param componentType the type of the component
  5796. * @param count the total number of components
  5797. * @param normalized whether the data is normalized
  5798. * @param callback the callback function called for each value
  5799. */
  5800. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5801. private static _GetFloatValue;
  5802. }
  5803. }
  5804. declare module BABYLON {
  5805. /**
  5806. * Class representing spherical polynomial coefficients to the 3rd degree
  5807. */
  5808. export class SphericalPolynomial {
  5809. /**
  5810. * The x coefficients of the spherical polynomial
  5811. */
  5812. x: Vector3;
  5813. /**
  5814. * The y coefficients of the spherical polynomial
  5815. */
  5816. y: Vector3;
  5817. /**
  5818. * The z coefficients of the spherical polynomial
  5819. */
  5820. z: Vector3;
  5821. /**
  5822. * The xx coefficients of the spherical polynomial
  5823. */
  5824. xx: Vector3;
  5825. /**
  5826. * The yy coefficients of the spherical polynomial
  5827. */
  5828. yy: Vector3;
  5829. /**
  5830. * The zz coefficients of the spherical polynomial
  5831. */
  5832. zz: Vector3;
  5833. /**
  5834. * The xy coefficients of the spherical polynomial
  5835. */
  5836. xy: Vector3;
  5837. /**
  5838. * The yz coefficients of the spherical polynomial
  5839. */
  5840. yz: Vector3;
  5841. /**
  5842. * The zx coefficients of the spherical polynomial
  5843. */
  5844. zx: Vector3;
  5845. /**
  5846. * Adds an ambient color to the spherical polynomial
  5847. * @param color the color to add
  5848. */
  5849. addAmbient(color: Color3): void;
  5850. /**
  5851. * Scales the spherical polynomial by the given amount
  5852. * @param scale the amount to scale
  5853. */
  5854. scale(scale: number): void;
  5855. /**
  5856. * Gets the spherical polynomial from harmonics
  5857. * @param harmonics the spherical harmonics
  5858. * @returns the spherical polynomial
  5859. */
  5860. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5861. /**
  5862. * Constructs a spherical polynomial from an array.
  5863. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5864. * @returns the spherical polynomial
  5865. */
  5866. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5867. }
  5868. /**
  5869. * Class representing spherical harmonics coefficients to the 3rd degree
  5870. */
  5871. export class SphericalHarmonics {
  5872. /**
  5873. * The l0,0 coefficients of the spherical harmonics
  5874. */
  5875. l00: Vector3;
  5876. /**
  5877. * The l1,-1 coefficients of the spherical harmonics
  5878. */
  5879. l1_1: Vector3;
  5880. /**
  5881. * The l1,0 coefficients of the spherical harmonics
  5882. */
  5883. l10: Vector3;
  5884. /**
  5885. * The l1,1 coefficients of the spherical harmonics
  5886. */
  5887. l11: Vector3;
  5888. /**
  5889. * The l2,-2 coefficients of the spherical harmonics
  5890. */
  5891. l2_2: Vector3;
  5892. /**
  5893. * The l2,-1 coefficients of the spherical harmonics
  5894. */
  5895. l2_1: Vector3;
  5896. /**
  5897. * The l2,0 coefficients of the spherical harmonics
  5898. */
  5899. l20: Vector3;
  5900. /**
  5901. * The l2,1 coefficients of the spherical harmonics
  5902. */
  5903. l21: Vector3;
  5904. /**
  5905. * The l2,2 coefficients of the spherical harmonics
  5906. */
  5907. lL22: Vector3;
  5908. /**
  5909. * Adds a light to the spherical harmonics
  5910. * @param direction the direction of the light
  5911. * @param color the color of the light
  5912. * @param deltaSolidAngle the delta solid angle of the light
  5913. */
  5914. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5915. /**
  5916. * Scales the spherical harmonics by the given amount
  5917. * @param scale the amount to scale
  5918. */
  5919. scale(scale: number): void;
  5920. /**
  5921. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5922. *
  5923. * ```
  5924. * E_lm = A_l * L_lm
  5925. * ```
  5926. *
  5927. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5928. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5929. * the scaling factors are given in equation 9.
  5930. */
  5931. convertIncidentRadianceToIrradiance(): void;
  5932. /**
  5933. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5934. *
  5935. * ```
  5936. * L = (1/pi) * E * rho
  5937. * ```
  5938. *
  5939. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5940. */
  5941. convertIrradianceToLambertianRadiance(): void;
  5942. /**
  5943. * Gets the spherical harmonics from polynomial
  5944. * @param polynomial the spherical polynomial
  5945. * @returns the spherical harmonics
  5946. */
  5947. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5948. /**
  5949. * Constructs a spherical harmonics from an array.
  5950. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5951. * @returns the spherical harmonics
  5952. */
  5953. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5954. }
  5955. }
  5956. declare module BABYLON {
  5957. /**
  5958. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5959. */
  5960. export interface CubeMapInfo {
  5961. /**
  5962. * The pixel array for the front face.
  5963. * This is stored in format, left to right, up to down format.
  5964. */
  5965. front: Nullable<ArrayBufferView>;
  5966. /**
  5967. * The pixel array for the back face.
  5968. * This is stored in format, left to right, up to down format.
  5969. */
  5970. back: Nullable<ArrayBufferView>;
  5971. /**
  5972. * The pixel array for the left face.
  5973. * This is stored in format, left to right, up to down format.
  5974. */
  5975. left: Nullable<ArrayBufferView>;
  5976. /**
  5977. * The pixel array for the right face.
  5978. * This is stored in format, left to right, up to down format.
  5979. */
  5980. right: Nullable<ArrayBufferView>;
  5981. /**
  5982. * The pixel array for the up face.
  5983. * This is stored in format, left to right, up to down format.
  5984. */
  5985. up: Nullable<ArrayBufferView>;
  5986. /**
  5987. * The pixel array for the down face.
  5988. * This is stored in format, left to right, up to down format.
  5989. */
  5990. down: Nullable<ArrayBufferView>;
  5991. /**
  5992. * The size of the cubemap stored.
  5993. *
  5994. * Each faces will be size * size pixels.
  5995. */
  5996. size: number;
  5997. /**
  5998. * The format of the texture.
  5999. *
  6000. * RGBA, RGB.
  6001. */
  6002. format: number;
  6003. /**
  6004. * The type of the texture data.
  6005. *
  6006. * UNSIGNED_INT, FLOAT.
  6007. */
  6008. type: number;
  6009. /**
  6010. * Specifies whether the texture is in gamma space.
  6011. */
  6012. gammaSpace: boolean;
  6013. }
  6014. /**
  6015. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6016. */
  6017. export class PanoramaToCubeMapTools {
  6018. private static FACE_FRONT;
  6019. private static FACE_BACK;
  6020. private static FACE_RIGHT;
  6021. private static FACE_LEFT;
  6022. private static FACE_DOWN;
  6023. private static FACE_UP;
  6024. /**
  6025. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6026. *
  6027. * @param float32Array The source data.
  6028. * @param inputWidth The width of the input panorama.
  6029. * @param inputHeight The height of the input panorama.
  6030. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6031. * @return The cubemap data
  6032. */
  6033. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6034. private static CreateCubemapTexture;
  6035. private static CalcProjectionSpherical;
  6036. }
  6037. }
  6038. declare module BABYLON {
  6039. /**
  6040. * Helper class dealing with the extraction of spherical polynomial dataArray
  6041. * from a cube map.
  6042. */
  6043. export class CubeMapToSphericalPolynomialTools {
  6044. private static FileFaces;
  6045. /**
  6046. * Converts a texture to the according Spherical Polynomial data.
  6047. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6048. *
  6049. * @param texture The texture to extract the information from.
  6050. * @return The Spherical Polynomial data.
  6051. */
  6052. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6053. /**
  6054. * Converts a cubemap to the according Spherical Polynomial data.
  6055. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6056. *
  6057. * @param cubeInfo The Cube map to extract the information from.
  6058. * @return The Spherical Polynomial data.
  6059. */
  6060. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6061. }
  6062. }
  6063. declare module BABYLON {
  6064. /**
  6065. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6066. * during the life time of the application.
  6067. */
  6068. export class EngineStore {
  6069. /** Gets the list of created engines */
  6070. static Instances: Engine[];
  6071. /**
  6072. * Gets the latest created engine
  6073. */
  6074. static readonly LastCreatedEngine: Nullable<Engine>;
  6075. /**
  6076. * Gets the latest created scene
  6077. */
  6078. static readonly LastCreatedScene: Nullable<Scene>;
  6079. }
  6080. }
  6081. declare module BABYLON {
  6082. /**
  6083. * Define options used to create a render target texture
  6084. */
  6085. export class RenderTargetCreationOptions {
  6086. /**
  6087. * Specifies is mipmaps must be generated
  6088. */
  6089. generateMipMaps?: boolean;
  6090. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6091. generateDepthBuffer?: boolean;
  6092. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6093. generateStencilBuffer?: boolean;
  6094. /** Defines texture type (int by default) */
  6095. type?: number;
  6096. /** Defines sampling mode (trilinear by default) */
  6097. samplingMode?: number;
  6098. /** Defines format (RGBA by default) */
  6099. format?: number;
  6100. }
  6101. }
  6102. declare module BABYLON {
  6103. /**
  6104. * @hidden
  6105. **/
  6106. export class _AlphaState {
  6107. private _isAlphaBlendDirty;
  6108. private _isBlendFunctionParametersDirty;
  6109. private _isBlendEquationParametersDirty;
  6110. private _isBlendConstantsDirty;
  6111. private _alphaBlend;
  6112. private _blendFunctionParameters;
  6113. private _blendEquationParameters;
  6114. private _blendConstants;
  6115. /**
  6116. * Initializes the state.
  6117. */
  6118. constructor();
  6119. readonly isDirty: boolean;
  6120. alphaBlend: boolean;
  6121. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6122. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6123. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6124. reset(): void;
  6125. apply(gl: WebGLRenderingContext): void;
  6126. }
  6127. }
  6128. declare module BABYLON {
  6129. /**
  6130. * @hidden
  6131. **/
  6132. export class _DepthCullingState {
  6133. private _isDepthTestDirty;
  6134. private _isDepthMaskDirty;
  6135. private _isDepthFuncDirty;
  6136. private _isCullFaceDirty;
  6137. private _isCullDirty;
  6138. private _isZOffsetDirty;
  6139. private _isFrontFaceDirty;
  6140. private _depthTest;
  6141. private _depthMask;
  6142. private _depthFunc;
  6143. private _cull;
  6144. private _cullFace;
  6145. private _zOffset;
  6146. private _frontFace;
  6147. /**
  6148. * Initializes the state.
  6149. */
  6150. constructor();
  6151. readonly isDirty: boolean;
  6152. zOffset: number;
  6153. cullFace: Nullable<number>;
  6154. cull: Nullable<boolean>;
  6155. depthFunc: Nullable<number>;
  6156. depthMask: boolean;
  6157. depthTest: boolean;
  6158. frontFace: Nullable<number>;
  6159. reset(): void;
  6160. apply(gl: WebGLRenderingContext): void;
  6161. }
  6162. }
  6163. declare module BABYLON {
  6164. /**
  6165. * @hidden
  6166. **/
  6167. export class _StencilState {
  6168. /** 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 */
  6169. static readonly ALWAYS: number;
  6170. /** Passed to stencilOperation to specify that stencil value must be kept */
  6171. static readonly KEEP: number;
  6172. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6173. static readonly REPLACE: number;
  6174. private _isStencilTestDirty;
  6175. private _isStencilMaskDirty;
  6176. private _isStencilFuncDirty;
  6177. private _isStencilOpDirty;
  6178. private _stencilTest;
  6179. private _stencilMask;
  6180. private _stencilFunc;
  6181. private _stencilFuncRef;
  6182. private _stencilFuncMask;
  6183. private _stencilOpStencilFail;
  6184. private _stencilOpDepthFail;
  6185. private _stencilOpStencilDepthPass;
  6186. readonly isDirty: boolean;
  6187. stencilFunc: number;
  6188. stencilFuncRef: number;
  6189. stencilFuncMask: number;
  6190. stencilOpStencilFail: number;
  6191. stencilOpDepthFail: number;
  6192. stencilOpStencilDepthPass: number;
  6193. stencilMask: number;
  6194. stencilTest: boolean;
  6195. constructor();
  6196. reset(): void;
  6197. apply(gl: WebGLRenderingContext): void;
  6198. }
  6199. }
  6200. declare module BABYLON {
  6201. /**
  6202. * @hidden
  6203. **/
  6204. export class _TimeToken {
  6205. _startTimeQuery: Nullable<WebGLQuery>;
  6206. _endTimeQuery: Nullable<WebGLQuery>;
  6207. _timeElapsedQuery: Nullable<WebGLQuery>;
  6208. _timeElapsedQueryEnded: boolean;
  6209. }
  6210. }
  6211. declare module BABYLON {
  6212. /**
  6213. * Class used to store data associated with WebGL texture data for the engine
  6214. * This class should not be used directly
  6215. */
  6216. export class InternalTexture {
  6217. /** hidden */
  6218. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6219. /**
  6220. * The source of the texture data is unknown
  6221. */
  6222. static DATASOURCE_UNKNOWN: number;
  6223. /**
  6224. * Texture data comes from an URL
  6225. */
  6226. static DATASOURCE_URL: number;
  6227. /**
  6228. * Texture data is only used for temporary storage
  6229. */
  6230. static DATASOURCE_TEMP: number;
  6231. /**
  6232. * Texture data comes from raw data (ArrayBuffer)
  6233. */
  6234. static DATASOURCE_RAW: number;
  6235. /**
  6236. * Texture content is dynamic (video or dynamic texture)
  6237. */
  6238. static DATASOURCE_DYNAMIC: number;
  6239. /**
  6240. * Texture content is generated by rendering to it
  6241. */
  6242. static DATASOURCE_RENDERTARGET: number;
  6243. /**
  6244. * Texture content is part of a multi render target process
  6245. */
  6246. static DATASOURCE_MULTIRENDERTARGET: number;
  6247. /**
  6248. * Texture data comes from a cube data file
  6249. */
  6250. static DATASOURCE_CUBE: number;
  6251. /**
  6252. * Texture data comes from a raw cube data
  6253. */
  6254. static DATASOURCE_CUBERAW: number;
  6255. /**
  6256. * Texture data come from a prefiltered cube data file
  6257. */
  6258. static DATASOURCE_CUBEPREFILTERED: number;
  6259. /**
  6260. * Texture content is raw 3D data
  6261. */
  6262. static DATASOURCE_RAW3D: number;
  6263. /**
  6264. * Texture content is a depth texture
  6265. */
  6266. static DATASOURCE_DEPTHTEXTURE: number;
  6267. /**
  6268. * Texture data comes from a raw cube data encoded with RGBD
  6269. */
  6270. static DATASOURCE_CUBERAW_RGBD: number;
  6271. /**
  6272. * Defines if the texture is ready
  6273. */
  6274. isReady: boolean;
  6275. /**
  6276. * Defines if the texture is a cube texture
  6277. */
  6278. isCube: boolean;
  6279. /**
  6280. * Defines if the texture contains 3D data
  6281. */
  6282. is3D: boolean;
  6283. /**
  6284. * Defines if the texture contains multiview data
  6285. */
  6286. isMultiview: boolean;
  6287. /**
  6288. * Gets the URL used to load this texture
  6289. */
  6290. url: string;
  6291. /**
  6292. * Gets the sampling mode of the texture
  6293. */
  6294. samplingMode: number;
  6295. /**
  6296. * Gets a boolean indicating if the texture needs mipmaps generation
  6297. */
  6298. generateMipMaps: boolean;
  6299. /**
  6300. * Gets the number of samples used by the texture (WebGL2+ only)
  6301. */
  6302. samples: number;
  6303. /**
  6304. * Gets the type of the texture (int, float...)
  6305. */
  6306. type: number;
  6307. /**
  6308. * Gets the format of the texture (RGB, RGBA...)
  6309. */
  6310. format: number;
  6311. /**
  6312. * Observable called when the texture is loaded
  6313. */
  6314. onLoadedObservable: Observable<InternalTexture>;
  6315. /**
  6316. * Gets the width of the texture
  6317. */
  6318. width: number;
  6319. /**
  6320. * Gets the height of the texture
  6321. */
  6322. height: number;
  6323. /**
  6324. * Gets the depth of the texture
  6325. */
  6326. depth: number;
  6327. /**
  6328. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6329. */
  6330. baseWidth: number;
  6331. /**
  6332. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6333. */
  6334. baseHeight: number;
  6335. /**
  6336. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6337. */
  6338. baseDepth: number;
  6339. /**
  6340. * Gets a boolean indicating if the texture is inverted on Y axis
  6341. */
  6342. invertY: boolean;
  6343. /** @hidden */
  6344. _invertVScale: boolean;
  6345. /** @hidden */
  6346. _associatedChannel: number;
  6347. /** @hidden */
  6348. _dataSource: number;
  6349. /** @hidden */
  6350. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6351. /** @hidden */
  6352. _bufferView: Nullable<ArrayBufferView>;
  6353. /** @hidden */
  6354. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6355. /** @hidden */
  6356. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6357. /** @hidden */
  6358. _size: number;
  6359. /** @hidden */
  6360. _extension: string;
  6361. /** @hidden */
  6362. _files: Nullable<string[]>;
  6363. /** @hidden */
  6364. _workingCanvas: Nullable<HTMLCanvasElement>;
  6365. /** @hidden */
  6366. _workingContext: Nullable<CanvasRenderingContext2D>;
  6367. /** @hidden */
  6368. _framebuffer: Nullable<WebGLFramebuffer>;
  6369. /** @hidden */
  6370. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6371. /** @hidden */
  6372. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6373. /** @hidden */
  6374. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6375. /** @hidden */
  6376. _attachments: Nullable<number[]>;
  6377. /** @hidden */
  6378. _cachedCoordinatesMode: Nullable<number>;
  6379. /** @hidden */
  6380. _cachedWrapU: Nullable<number>;
  6381. /** @hidden */
  6382. _cachedWrapV: Nullable<number>;
  6383. /** @hidden */
  6384. _cachedWrapR: Nullable<number>;
  6385. /** @hidden */
  6386. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6387. /** @hidden */
  6388. _isDisabled: boolean;
  6389. /** @hidden */
  6390. _compression: Nullable<string>;
  6391. /** @hidden */
  6392. _generateStencilBuffer: boolean;
  6393. /** @hidden */
  6394. _generateDepthBuffer: boolean;
  6395. /** @hidden */
  6396. _comparisonFunction: number;
  6397. /** @hidden */
  6398. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6399. /** @hidden */
  6400. _lodGenerationScale: number;
  6401. /** @hidden */
  6402. _lodGenerationOffset: number;
  6403. /** @hidden */
  6404. _colorTextureArray: Nullable<WebGLTexture>;
  6405. /** @hidden */
  6406. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6407. /** @hidden */
  6408. _lodTextureHigh: Nullable<BaseTexture>;
  6409. /** @hidden */
  6410. _lodTextureMid: Nullable<BaseTexture>;
  6411. /** @hidden */
  6412. _lodTextureLow: Nullable<BaseTexture>;
  6413. /** @hidden */
  6414. _isRGBD: boolean;
  6415. /** @hidden */
  6416. _webGLTexture: Nullable<WebGLTexture>;
  6417. /** @hidden */
  6418. _references: number;
  6419. private _engine;
  6420. /**
  6421. * Gets the Engine the texture belongs to.
  6422. * @returns The babylon engine
  6423. */
  6424. getEngine(): Engine;
  6425. /**
  6426. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6427. */
  6428. readonly dataSource: number;
  6429. /**
  6430. * Creates a new InternalTexture
  6431. * @param engine defines the engine to use
  6432. * @param dataSource defines the type of data that will be used
  6433. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6434. */
  6435. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6436. /**
  6437. * Increments the number of references (ie. the number of Texture that point to it)
  6438. */
  6439. incrementReferences(): void;
  6440. /**
  6441. * Change the size of the texture (not the size of the content)
  6442. * @param width defines the new width
  6443. * @param height defines the new height
  6444. * @param depth defines the new depth (1 by default)
  6445. */
  6446. updateSize(width: int, height: int, depth?: int): void;
  6447. /** @hidden */
  6448. _rebuild(): void;
  6449. /** @hidden */
  6450. _swapAndDie(target: InternalTexture): void;
  6451. /**
  6452. * Dispose the current allocated resources
  6453. */
  6454. dispose(): void;
  6455. }
  6456. }
  6457. declare module BABYLON {
  6458. /**
  6459. * This represents the main contract an easing function should follow.
  6460. * Easing functions are used throughout the animation system.
  6461. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6462. */
  6463. export interface IEasingFunction {
  6464. /**
  6465. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6466. * of the easing function.
  6467. * The link below provides some of the most common examples of easing functions.
  6468. * @see https://easings.net/
  6469. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6470. * @returns the corresponding value on the curve defined by the easing function
  6471. */
  6472. ease(gradient: number): number;
  6473. }
  6474. /**
  6475. * Base class used for every default easing function.
  6476. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6477. */
  6478. export class EasingFunction implements IEasingFunction {
  6479. /**
  6480. * Interpolation follows the mathematical formula associated with the easing function.
  6481. */
  6482. static readonly EASINGMODE_EASEIN: number;
  6483. /**
  6484. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6485. */
  6486. static readonly EASINGMODE_EASEOUT: number;
  6487. /**
  6488. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6489. */
  6490. static readonly EASINGMODE_EASEINOUT: number;
  6491. private _easingMode;
  6492. /**
  6493. * Sets the easing mode of the current function.
  6494. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6495. */
  6496. setEasingMode(easingMode: number): void;
  6497. /**
  6498. * Gets the current easing mode.
  6499. * @returns the easing mode
  6500. */
  6501. getEasingMode(): number;
  6502. /**
  6503. * @hidden
  6504. */
  6505. easeInCore(gradient: number): number;
  6506. /**
  6507. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6508. * of the easing function.
  6509. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6510. * @returns the corresponding value on the curve defined by the easing function
  6511. */
  6512. ease(gradient: number): number;
  6513. }
  6514. /**
  6515. * Easing function with a circle shape (see link below).
  6516. * @see https://easings.net/#easeInCirc
  6517. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6518. */
  6519. export class CircleEase extends EasingFunction implements IEasingFunction {
  6520. /** @hidden */
  6521. easeInCore(gradient: number): number;
  6522. }
  6523. /**
  6524. * Easing function with a ease back shape (see link below).
  6525. * @see https://easings.net/#easeInBack
  6526. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6527. */
  6528. export class BackEase extends EasingFunction implements IEasingFunction {
  6529. /** Defines the amplitude of the function */
  6530. amplitude: number;
  6531. /**
  6532. * Instantiates a back ease easing
  6533. * @see https://easings.net/#easeInBack
  6534. * @param amplitude Defines the amplitude of the function
  6535. */
  6536. constructor(
  6537. /** Defines the amplitude of the function */
  6538. amplitude?: number);
  6539. /** @hidden */
  6540. easeInCore(gradient: number): number;
  6541. }
  6542. /**
  6543. * Easing function with a bouncing shape (see link below).
  6544. * @see https://easings.net/#easeInBounce
  6545. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6546. */
  6547. export class BounceEase extends EasingFunction implements IEasingFunction {
  6548. /** Defines the number of bounces */
  6549. bounces: number;
  6550. /** Defines the amplitude of the bounce */
  6551. bounciness: number;
  6552. /**
  6553. * Instantiates a bounce easing
  6554. * @see https://easings.net/#easeInBounce
  6555. * @param bounces Defines the number of bounces
  6556. * @param bounciness Defines the amplitude of the bounce
  6557. */
  6558. constructor(
  6559. /** Defines the number of bounces */
  6560. bounces?: number,
  6561. /** Defines the amplitude of the bounce */
  6562. bounciness?: number);
  6563. /** @hidden */
  6564. easeInCore(gradient: number): number;
  6565. }
  6566. /**
  6567. * Easing function with a power of 3 shape (see link below).
  6568. * @see https://easings.net/#easeInCubic
  6569. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6570. */
  6571. export class CubicEase extends EasingFunction implements IEasingFunction {
  6572. /** @hidden */
  6573. easeInCore(gradient: number): number;
  6574. }
  6575. /**
  6576. * Easing function with an elastic shape (see link below).
  6577. * @see https://easings.net/#easeInElastic
  6578. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6579. */
  6580. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6581. /** Defines the number of oscillations*/
  6582. oscillations: number;
  6583. /** Defines the amplitude of the oscillations*/
  6584. springiness: number;
  6585. /**
  6586. * Instantiates an elastic easing function
  6587. * @see https://easings.net/#easeInElastic
  6588. * @param oscillations Defines the number of oscillations
  6589. * @param springiness Defines the amplitude of the oscillations
  6590. */
  6591. constructor(
  6592. /** Defines the number of oscillations*/
  6593. oscillations?: number,
  6594. /** Defines the amplitude of the oscillations*/
  6595. springiness?: number);
  6596. /** @hidden */
  6597. easeInCore(gradient: number): number;
  6598. }
  6599. /**
  6600. * Easing function with an exponential shape (see link below).
  6601. * @see https://easings.net/#easeInExpo
  6602. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6603. */
  6604. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6605. /** Defines the exponent of the function */
  6606. exponent: number;
  6607. /**
  6608. * Instantiates an exponential easing function
  6609. * @see https://easings.net/#easeInExpo
  6610. * @param exponent Defines the exponent of the function
  6611. */
  6612. constructor(
  6613. /** Defines the exponent of the function */
  6614. exponent?: number);
  6615. /** @hidden */
  6616. easeInCore(gradient: number): number;
  6617. }
  6618. /**
  6619. * Easing function with a power shape (see link below).
  6620. * @see https://easings.net/#easeInQuad
  6621. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6622. */
  6623. export class PowerEase extends EasingFunction implements IEasingFunction {
  6624. /** Defines the power of the function */
  6625. power: number;
  6626. /**
  6627. * Instantiates an power base easing function
  6628. * @see https://easings.net/#easeInQuad
  6629. * @param power Defines the power of the function
  6630. */
  6631. constructor(
  6632. /** Defines the power of the function */
  6633. power?: number);
  6634. /** @hidden */
  6635. easeInCore(gradient: number): number;
  6636. }
  6637. /**
  6638. * Easing function with a power of 2 shape (see link below).
  6639. * @see https://easings.net/#easeInQuad
  6640. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6641. */
  6642. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6643. /** @hidden */
  6644. easeInCore(gradient: number): number;
  6645. }
  6646. /**
  6647. * Easing function with a power of 4 shape (see link below).
  6648. * @see https://easings.net/#easeInQuart
  6649. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6650. */
  6651. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6652. /** @hidden */
  6653. easeInCore(gradient: number): number;
  6654. }
  6655. /**
  6656. * Easing function with a power of 5 shape (see link below).
  6657. * @see https://easings.net/#easeInQuint
  6658. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6659. */
  6660. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6661. /** @hidden */
  6662. easeInCore(gradient: number): number;
  6663. }
  6664. /**
  6665. * Easing function with a sin shape (see link below).
  6666. * @see https://easings.net/#easeInSine
  6667. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6668. */
  6669. export class SineEase extends EasingFunction implements IEasingFunction {
  6670. /** @hidden */
  6671. easeInCore(gradient: number): number;
  6672. }
  6673. /**
  6674. * Easing function with a bezier shape (see link below).
  6675. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6676. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6677. */
  6678. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6679. /** Defines the x component of the start tangent in the bezier curve */
  6680. x1: number;
  6681. /** Defines the y component of the start tangent in the bezier curve */
  6682. y1: number;
  6683. /** Defines the x component of the end tangent in the bezier curve */
  6684. x2: number;
  6685. /** Defines the y component of the end tangent in the bezier curve */
  6686. y2: number;
  6687. /**
  6688. * Instantiates a bezier function
  6689. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6690. * @param x1 Defines the x component of the start tangent in the bezier curve
  6691. * @param y1 Defines the y component of the start tangent in the bezier curve
  6692. * @param x2 Defines the x component of the end tangent in the bezier curve
  6693. * @param y2 Defines the y component of the end tangent in the bezier curve
  6694. */
  6695. constructor(
  6696. /** Defines the x component of the start tangent in the bezier curve */
  6697. x1?: number,
  6698. /** Defines the y component of the start tangent in the bezier curve */
  6699. y1?: number,
  6700. /** Defines the x component of the end tangent in the bezier curve */
  6701. x2?: number,
  6702. /** Defines the y component of the end tangent in the bezier curve */
  6703. y2?: number);
  6704. /** @hidden */
  6705. easeInCore(gradient: number): number;
  6706. }
  6707. }
  6708. declare module BABYLON {
  6709. /**
  6710. * Defines an interface which represents an animation key frame
  6711. */
  6712. export interface IAnimationKey {
  6713. /**
  6714. * Frame of the key frame
  6715. */
  6716. frame: number;
  6717. /**
  6718. * Value at the specifies key frame
  6719. */
  6720. value: any;
  6721. /**
  6722. * The input tangent for the cubic hermite spline
  6723. */
  6724. inTangent?: any;
  6725. /**
  6726. * The output tangent for the cubic hermite spline
  6727. */
  6728. outTangent?: any;
  6729. /**
  6730. * The animation interpolation type
  6731. */
  6732. interpolation?: AnimationKeyInterpolation;
  6733. }
  6734. /**
  6735. * Enum for the animation key frame interpolation type
  6736. */
  6737. export enum AnimationKeyInterpolation {
  6738. /**
  6739. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6740. */
  6741. STEP = 1
  6742. }
  6743. }
  6744. declare module BABYLON {
  6745. /**
  6746. * Represents the range of an animation
  6747. */
  6748. export class AnimationRange {
  6749. /**The name of the animation range**/
  6750. name: string;
  6751. /**The starting frame of the animation */
  6752. from: number;
  6753. /**The ending frame of the animation*/
  6754. to: number;
  6755. /**
  6756. * Initializes the range of an animation
  6757. * @param name The name of the animation range
  6758. * @param from The starting frame of the animation
  6759. * @param to The ending frame of the animation
  6760. */
  6761. constructor(
  6762. /**The name of the animation range**/
  6763. name: string,
  6764. /**The starting frame of the animation */
  6765. from: number,
  6766. /**The ending frame of the animation*/
  6767. to: number);
  6768. /**
  6769. * Makes a copy of the animation range
  6770. * @returns A copy of the animation range
  6771. */
  6772. clone(): AnimationRange;
  6773. }
  6774. }
  6775. declare module BABYLON {
  6776. /**
  6777. * Composed of a frame, and an action function
  6778. */
  6779. export class AnimationEvent {
  6780. /** The frame for which the event is triggered **/
  6781. frame: number;
  6782. /** The event to perform when triggered **/
  6783. action: (currentFrame: number) => void;
  6784. /** Specifies if the event should be triggered only once**/
  6785. onlyOnce?: boolean | undefined;
  6786. /**
  6787. * Specifies if the animation event is done
  6788. */
  6789. isDone: boolean;
  6790. /**
  6791. * Initializes the animation event
  6792. * @param frame The frame for which the event is triggered
  6793. * @param action The event to perform when triggered
  6794. * @param onlyOnce Specifies if the event should be triggered only once
  6795. */
  6796. constructor(
  6797. /** The frame for which the event is triggered **/
  6798. frame: number,
  6799. /** The event to perform when triggered **/
  6800. action: (currentFrame: number) => void,
  6801. /** Specifies if the event should be triggered only once**/
  6802. onlyOnce?: boolean | undefined);
  6803. /** @hidden */
  6804. _clone(): AnimationEvent;
  6805. }
  6806. }
  6807. declare module BABYLON {
  6808. /**
  6809. * Interface used to define a behavior
  6810. */
  6811. export interface Behavior<T> {
  6812. /** gets or sets behavior's name */
  6813. name: string;
  6814. /**
  6815. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6816. */
  6817. init(): void;
  6818. /**
  6819. * Called when the behavior is attached to a target
  6820. * @param target defines the target where the behavior is attached to
  6821. */
  6822. attach(target: T): void;
  6823. /**
  6824. * Called when the behavior is detached from its target
  6825. */
  6826. detach(): void;
  6827. }
  6828. /**
  6829. * Interface implemented by classes supporting behaviors
  6830. */
  6831. export interface IBehaviorAware<T> {
  6832. /**
  6833. * Attach a behavior
  6834. * @param behavior defines the behavior to attach
  6835. * @returns the current host
  6836. */
  6837. addBehavior(behavior: Behavior<T>): T;
  6838. /**
  6839. * Remove a behavior from the current object
  6840. * @param behavior defines the behavior to detach
  6841. * @returns the current host
  6842. */
  6843. removeBehavior(behavior: Behavior<T>): T;
  6844. /**
  6845. * Gets a behavior using its name to search
  6846. * @param name defines the name to search
  6847. * @returns the behavior or null if not found
  6848. */
  6849. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6850. }
  6851. }
  6852. declare module BABYLON {
  6853. /**
  6854. * @hidden
  6855. */
  6856. export class IntersectionInfo {
  6857. bu: Nullable<number>;
  6858. bv: Nullable<number>;
  6859. distance: number;
  6860. faceId: number;
  6861. subMeshId: number;
  6862. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6863. }
  6864. }
  6865. declare module BABYLON {
  6866. /**
  6867. * Class used to store bounding sphere information
  6868. */
  6869. export class BoundingSphere {
  6870. /**
  6871. * Gets the center of the bounding sphere in local space
  6872. */
  6873. readonly center: Vector3;
  6874. /**
  6875. * Radius of the bounding sphere in local space
  6876. */
  6877. radius: number;
  6878. /**
  6879. * Gets the center of the bounding sphere in world space
  6880. */
  6881. readonly centerWorld: Vector3;
  6882. /**
  6883. * Radius of the bounding sphere in world space
  6884. */
  6885. radiusWorld: number;
  6886. /**
  6887. * Gets the minimum vector in local space
  6888. */
  6889. readonly minimum: Vector3;
  6890. /**
  6891. * Gets the maximum vector in local space
  6892. */
  6893. readonly maximum: Vector3;
  6894. private _worldMatrix;
  6895. private static readonly TmpVector3;
  6896. /**
  6897. * Creates a new bounding sphere
  6898. * @param min defines the minimum vector (in local space)
  6899. * @param max defines the maximum vector (in local space)
  6900. * @param worldMatrix defines the new world matrix
  6901. */
  6902. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6903. /**
  6904. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6905. * @param min defines the new minimum vector (in local space)
  6906. * @param max defines the new maximum vector (in local space)
  6907. * @param worldMatrix defines the new world matrix
  6908. */
  6909. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6910. /**
  6911. * Scale the current bounding sphere by applying a scale factor
  6912. * @param factor defines the scale factor to apply
  6913. * @returns the current bounding box
  6914. */
  6915. scale(factor: number): BoundingSphere;
  6916. /**
  6917. * Gets the world matrix of the bounding box
  6918. * @returns a matrix
  6919. */
  6920. getWorldMatrix(): DeepImmutable<Matrix>;
  6921. /** @hidden */
  6922. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6923. /**
  6924. * Tests if the bounding sphere is intersecting the frustum planes
  6925. * @param frustumPlanes defines the frustum planes to test
  6926. * @returns true if there is an intersection
  6927. */
  6928. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6929. /**
  6930. * Tests if the bounding sphere center is in between the frustum planes.
  6931. * Used for optimistic fast inclusion.
  6932. * @param frustumPlanes defines the frustum planes to test
  6933. * @returns true if the sphere center is in between the frustum planes
  6934. */
  6935. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6936. /**
  6937. * Tests if a point is inside the bounding sphere
  6938. * @param point defines the point to test
  6939. * @returns true if the point is inside the bounding sphere
  6940. */
  6941. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6942. /**
  6943. * Checks if two sphere intersct
  6944. * @param sphere0 sphere 0
  6945. * @param sphere1 sphere 1
  6946. * @returns true if the speres intersect
  6947. */
  6948. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6949. }
  6950. }
  6951. declare module BABYLON {
  6952. /**
  6953. * Class used to store bounding box information
  6954. */
  6955. export class BoundingBox implements ICullable {
  6956. /**
  6957. * Gets the 8 vectors representing the bounding box in local space
  6958. */
  6959. readonly vectors: Vector3[];
  6960. /**
  6961. * Gets the center of the bounding box in local space
  6962. */
  6963. readonly center: Vector3;
  6964. /**
  6965. * Gets the center of the bounding box in world space
  6966. */
  6967. readonly centerWorld: Vector3;
  6968. /**
  6969. * Gets the extend size in local space
  6970. */
  6971. readonly extendSize: Vector3;
  6972. /**
  6973. * Gets the extend size in world space
  6974. */
  6975. readonly extendSizeWorld: Vector3;
  6976. /**
  6977. * Gets the OBB (object bounding box) directions
  6978. */
  6979. readonly directions: Vector3[];
  6980. /**
  6981. * Gets the 8 vectors representing the bounding box in world space
  6982. */
  6983. readonly vectorsWorld: Vector3[];
  6984. /**
  6985. * Gets the minimum vector in world space
  6986. */
  6987. readonly minimumWorld: Vector3;
  6988. /**
  6989. * Gets the maximum vector in world space
  6990. */
  6991. readonly maximumWorld: Vector3;
  6992. /**
  6993. * Gets the minimum vector in local space
  6994. */
  6995. readonly minimum: Vector3;
  6996. /**
  6997. * Gets the maximum vector in local space
  6998. */
  6999. readonly maximum: Vector3;
  7000. private _worldMatrix;
  7001. private static readonly TmpVector3;
  7002. /**
  7003. * @hidden
  7004. */
  7005. _tag: number;
  7006. /**
  7007. * Creates a new bounding box
  7008. * @param min defines the minimum vector (in local space)
  7009. * @param max defines the maximum vector (in local space)
  7010. * @param worldMatrix defines the new world matrix
  7011. */
  7012. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7013. /**
  7014. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7015. * @param min defines the new minimum vector (in local space)
  7016. * @param max defines the new maximum vector (in local space)
  7017. * @param worldMatrix defines the new world matrix
  7018. */
  7019. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7020. /**
  7021. * Scale the current bounding box by applying a scale factor
  7022. * @param factor defines the scale factor to apply
  7023. * @returns the current bounding box
  7024. */
  7025. scale(factor: number): BoundingBox;
  7026. /**
  7027. * Gets the world matrix of the bounding box
  7028. * @returns a matrix
  7029. */
  7030. getWorldMatrix(): DeepImmutable<Matrix>;
  7031. /** @hidden */
  7032. _update(world: DeepImmutable<Matrix>): void;
  7033. /**
  7034. * Tests if the bounding box is intersecting the frustum planes
  7035. * @param frustumPlanes defines the frustum planes to test
  7036. * @returns true if there is an intersection
  7037. */
  7038. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7039. /**
  7040. * Tests if the bounding box is entirely inside the frustum planes
  7041. * @param frustumPlanes defines the frustum planes to test
  7042. * @returns true if there is an inclusion
  7043. */
  7044. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7045. /**
  7046. * Tests if a point is inside the bounding box
  7047. * @param point defines the point to test
  7048. * @returns true if the point is inside the bounding box
  7049. */
  7050. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7051. /**
  7052. * Tests if the bounding box intersects with a bounding sphere
  7053. * @param sphere defines the sphere to test
  7054. * @returns true if there is an intersection
  7055. */
  7056. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7057. /**
  7058. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7059. * @param min defines the min vector to use
  7060. * @param max defines the max vector to use
  7061. * @returns true if there is an intersection
  7062. */
  7063. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7064. /**
  7065. * Tests if two bounding boxes are intersections
  7066. * @param box0 defines the first box to test
  7067. * @param box1 defines the second box to test
  7068. * @returns true if there is an intersection
  7069. */
  7070. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7071. /**
  7072. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7073. * @param minPoint defines the minimum vector of the bounding box
  7074. * @param maxPoint defines the maximum vector of the bounding box
  7075. * @param sphereCenter defines the sphere center
  7076. * @param sphereRadius defines the sphere radius
  7077. * @returns true if there is an intersection
  7078. */
  7079. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7080. /**
  7081. * Tests if a bounding box defined with 8 vectors is entirely inside 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 inclusion
  7085. */
  7086. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7087. /**
  7088. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7089. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7090. * @param frustumPlanes defines the frustum planes to test
  7091. * @return true if there is an intersection
  7092. */
  7093. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7094. }
  7095. }
  7096. declare module BABYLON {
  7097. /** @hidden */
  7098. export class Collider {
  7099. /** Define if a collision was found */
  7100. collisionFound: boolean;
  7101. /**
  7102. * Define last intersection point in local space
  7103. */
  7104. intersectionPoint: Vector3;
  7105. /**
  7106. * Define last collided mesh
  7107. */
  7108. collidedMesh: Nullable<AbstractMesh>;
  7109. private _collisionPoint;
  7110. private _planeIntersectionPoint;
  7111. private _tempVector;
  7112. private _tempVector2;
  7113. private _tempVector3;
  7114. private _tempVector4;
  7115. private _edge;
  7116. private _baseToVertex;
  7117. private _destinationPoint;
  7118. private _slidePlaneNormal;
  7119. private _displacementVector;
  7120. /** @hidden */
  7121. _radius: Vector3;
  7122. /** @hidden */
  7123. _retry: number;
  7124. private _velocity;
  7125. private _basePoint;
  7126. private _epsilon;
  7127. /** @hidden */
  7128. _velocityWorldLength: number;
  7129. /** @hidden */
  7130. _basePointWorld: Vector3;
  7131. private _velocityWorld;
  7132. private _normalizedVelocity;
  7133. /** @hidden */
  7134. _initialVelocity: Vector3;
  7135. /** @hidden */
  7136. _initialPosition: Vector3;
  7137. private _nearestDistance;
  7138. private _collisionMask;
  7139. collisionMask: number;
  7140. /**
  7141. * Gets the plane normal used to compute the sliding response (in local space)
  7142. */
  7143. readonly slidePlaneNormal: Vector3;
  7144. /** @hidden */
  7145. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7146. /** @hidden */
  7147. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7148. /** @hidden */
  7149. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7150. /** @hidden */
  7151. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7152. /** @hidden */
  7153. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7154. /** @hidden */
  7155. _getResponse(pos: Vector3, vel: Vector3): void;
  7156. }
  7157. }
  7158. declare module BABYLON {
  7159. /**
  7160. * Interface for cullable objects
  7161. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7162. */
  7163. export interface ICullable {
  7164. /**
  7165. * Checks if the object or part of the object is in the frustum
  7166. * @param frustumPlanes Camera near/planes
  7167. * @returns true if the object is in frustum otherwise false
  7168. */
  7169. isInFrustum(frustumPlanes: Plane[]): boolean;
  7170. /**
  7171. * Checks if a cullable object (mesh...) is in the camera frustum
  7172. * Unlike isInFrustum this cheks the full bounding box
  7173. * @param frustumPlanes Camera near/planes
  7174. * @returns true if the object is in frustum otherwise false
  7175. */
  7176. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7177. }
  7178. /**
  7179. * Info for a bounding data of a mesh
  7180. */
  7181. export class BoundingInfo implements ICullable {
  7182. /**
  7183. * Bounding box for the mesh
  7184. */
  7185. readonly boundingBox: BoundingBox;
  7186. /**
  7187. * Bounding sphere for the mesh
  7188. */
  7189. readonly boundingSphere: BoundingSphere;
  7190. private _isLocked;
  7191. private static readonly TmpVector3;
  7192. /**
  7193. * Constructs bounding info
  7194. * @param minimum min vector of the bounding box/sphere
  7195. * @param maximum max vector of the bounding box/sphere
  7196. * @param worldMatrix defines the new world matrix
  7197. */
  7198. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7199. /**
  7200. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7201. * @param min defines the new minimum vector (in local space)
  7202. * @param max defines the new maximum vector (in local space)
  7203. * @param worldMatrix defines the new world matrix
  7204. */
  7205. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7206. /**
  7207. * min vector of the bounding box/sphere
  7208. */
  7209. readonly minimum: Vector3;
  7210. /**
  7211. * max vector of the bounding box/sphere
  7212. */
  7213. readonly maximum: Vector3;
  7214. /**
  7215. * If the info is locked and won't be updated to avoid perf overhead
  7216. */
  7217. isLocked: boolean;
  7218. /**
  7219. * Updates the bounding sphere and box
  7220. * @param world world matrix to be used to update
  7221. */
  7222. update(world: DeepImmutable<Matrix>): void;
  7223. /**
  7224. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7225. * @param center New center of the bounding info
  7226. * @param extend New extend of the bounding info
  7227. * @returns the current bounding info
  7228. */
  7229. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7230. /**
  7231. * Scale the current bounding info by applying a scale factor
  7232. * @param factor defines the scale factor to apply
  7233. * @returns the current bounding info
  7234. */
  7235. scale(factor: number): BoundingInfo;
  7236. /**
  7237. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7238. * @param frustumPlanes defines the frustum to test
  7239. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7240. * @returns true if the bounding info is in the frustum planes
  7241. */
  7242. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7243. /**
  7244. * Gets the world distance between the min and max points of the bounding box
  7245. */
  7246. readonly diagonalLength: number;
  7247. /**
  7248. * Checks if a cullable object (mesh...) is in the camera frustum
  7249. * Unlike isInFrustum this cheks the full bounding box
  7250. * @param frustumPlanes Camera near/planes
  7251. * @returns true if the object is in frustum otherwise false
  7252. */
  7253. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7254. /** @hidden */
  7255. _checkCollision(collider: Collider): boolean;
  7256. /**
  7257. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7258. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7259. * @param point the point to check intersection with
  7260. * @returns if the point intersects
  7261. */
  7262. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7263. /**
  7264. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7265. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7266. * @param boundingInfo the bounding info to check intersection with
  7267. * @param precise if the intersection should be done using OBB
  7268. * @returns if the bounding info intersects
  7269. */
  7270. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7271. }
  7272. }
  7273. declare module BABYLON {
  7274. /**
  7275. * Defines an array and its length.
  7276. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7277. */
  7278. export interface ISmartArrayLike<T> {
  7279. /**
  7280. * The data of the array.
  7281. */
  7282. data: Array<T>;
  7283. /**
  7284. * The active length of the array.
  7285. */
  7286. length: number;
  7287. }
  7288. /**
  7289. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7290. */
  7291. export class SmartArray<T> implements ISmartArrayLike<T> {
  7292. /**
  7293. * The full set of data from the array.
  7294. */
  7295. data: Array<T>;
  7296. /**
  7297. * The active length of the array.
  7298. */
  7299. length: number;
  7300. protected _id: number;
  7301. /**
  7302. * Instantiates a Smart Array.
  7303. * @param capacity defines the default capacity of the array.
  7304. */
  7305. constructor(capacity: number);
  7306. /**
  7307. * Pushes a value at the end of the active data.
  7308. * @param value defines the object to push in the array.
  7309. */
  7310. push(value: T): void;
  7311. /**
  7312. * Iterates over the active data and apply the lambda to them.
  7313. * @param func defines the action to apply on each value.
  7314. */
  7315. forEach(func: (content: T) => void): void;
  7316. /**
  7317. * Sorts the full sets of data.
  7318. * @param compareFn defines the comparison function to apply.
  7319. */
  7320. sort(compareFn: (a: T, b: T) => number): void;
  7321. /**
  7322. * Resets the active data to an empty array.
  7323. */
  7324. reset(): void;
  7325. /**
  7326. * Releases all the data from the array as well as the array.
  7327. */
  7328. dispose(): void;
  7329. /**
  7330. * Concats the active data with a given array.
  7331. * @param array defines the data to concatenate with.
  7332. */
  7333. concat(array: any): void;
  7334. /**
  7335. * Returns the position of a value in the active data.
  7336. * @param value defines the value to find the index for
  7337. * @returns the index if found in the active data otherwise -1
  7338. */
  7339. indexOf(value: T): number;
  7340. /**
  7341. * Returns whether an element is part of the active data.
  7342. * @param value defines the value to look for
  7343. * @returns true if found in the active data otherwise false
  7344. */
  7345. contains(value: T): boolean;
  7346. private static _GlobalId;
  7347. }
  7348. /**
  7349. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7350. * The data in this array can only be present once
  7351. */
  7352. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7353. private _duplicateId;
  7354. /**
  7355. * Pushes a value at the end of the active data.
  7356. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7357. * @param value defines the object to push in the array.
  7358. */
  7359. push(value: T): void;
  7360. /**
  7361. * Pushes a value at the end of the active data.
  7362. * If the data is already present, it won t be added again
  7363. * @param value defines the object to push in the array.
  7364. * @returns true if added false if it was already present
  7365. */
  7366. pushNoDuplicate(value: T): boolean;
  7367. /**
  7368. * Resets the active data to an empty array.
  7369. */
  7370. reset(): void;
  7371. /**
  7372. * Concats the active data with a given array.
  7373. * This ensures no dupplicate will be present in the result.
  7374. * @param array defines the data to concatenate with.
  7375. */
  7376. concatWithNoDuplicate(array: any): void;
  7377. }
  7378. }
  7379. declare module BABYLON {
  7380. /**
  7381. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7382. * separate meshes. This can be use to improve performances.
  7383. * @see http://doc.babylonjs.com/how_to/multi_materials
  7384. */
  7385. export class MultiMaterial extends Material {
  7386. private _subMaterials;
  7387. /**
  7388. * Gets or Sets the list of Materials used within the multi material.
  7389. * They need to be ordered according to the submeshes order in the associated mesh
  7390. */
  7391. subMaterials: Nullable<Material>[];
  7392. /**
  7393. * Function used to align with Node.getChildren()
  7394. * @returns the list of Materials used within the multi material
  7395. */
  7396. getChildren(): Nullable<Material>[];
  7397. /**
  7398. * Instantiates a new Multi Material
  7399. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7400. * separate meshes. This can be use to improve performances.
  7401. * @see http://doc.babylonjs.com/how_to/multi_materials
  7402. * @param name Define the name in the scene
  7403. * @param scene Define the scene the material belongs to
  7404. */
  7405. constructor(name: string, scene: Scene);
  7406. private _hookArray;
  7407. /**
  7408. * Get one of the submaterial by its index in the submaterials array
  7409. * @param index The index to look the sub material at
  7410. * @returns The Material if the index has been defined
  7411. */
  7412. getSubMaterial(index: number): Nullable<Material>;
  7413. /**
  7414. * Get the list of active textures for the whole sub materials list.
  7415. * @returns All the textures that will be used during the rendering
  7416. */
  7417. getActiveTextures(): BaseTexture[];
  7418. /**
  7419. * Gets the current class name of the material e.g. "MultiMaterial"
  7420. * Mainly use in serialization.
  7421. * @returns the class name
  7422. */
  7423. getClassName(): string;
  7424. /**
  7425. * Checks if the material is ready to render the requested sub mesh
  7426. * @param mesh Define the mesh the submesh belongs to
  7427. * @param subMesh Define the sub mesh to look readyness for
  7428. * @param useInstances Define whether or not the material is used with instances
  7429. * @returns true if ready, otherwise false
  7430. */
  7431. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7432. /**
  7433. * Clones the current material and its related sub materials
  7434. * @param name Define the name of the newly cloned material
  7435. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7436. * @returns the cloned material
  7437. */
  7438. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7439. /**
  7440. * Serializes the materials into a JSON representation.
  7441. * @returns the JSON representation
  7442. */
  7443. serialize(): any;
  7444. /**
  7445. * Dispose the material and release its associated resources
  7446. * @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)
  7447. * @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)
  7448. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  7449. */
  7450. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7451. /**
  7452. * Creates a MultiMaterial from parsed MultiMaterial data.
  7453. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7454. * @param scene defines the hosting scene
  7455. * @returns a new MultiMaterial
  7456. */
  7457. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7458. }
  7459. }
  7460. declare module BABYLON {
  7461. /**
  7462. * Class used to represent data loading progression
  7463. */
  7464. export class SceneLoaderFlags {
  7465. private static _ForceFullSceneLoadingForIncremental;
  7466. private static _ShowLoadingScreen;
  7467. private static _CleanBoneMatrixWeights;
  7468. private static _loggingLevel;
  7469. /**
  7470. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7471. */
  7472. static ForceFullSceneLoadingForIncremental: boolean;
  7473. /**
  7474. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7475. */
  7476. static ShowLoadingScreen: boolean;
  7477. /**
  7478. * Defines the current logging level (while loading the scene)
  7479. * @ignorenaming
  7480. */
  7481. static loggingLevel: number;
  7482. /**
  7483. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7484. */
  7485. static CleanBoneMatrixWeights: boolean;
  7486. }
  7487. }
  7488. declare module BABYLON {
  7489. /**
  7490. * 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.
  7491. * @see https://doc.babylonjs.com/how_to/transformnode
  7492. */
  7493. export class TransformNode extends Node {
  7494. /**
  7495. * Object will not rotate to face the camera
  7496. */
  7497. static BILLBOARDMODE_NONE: number;
  7498. /**
  7499. * Object will rotate to face the camera but only on the x axis
  7500. */
  7501. static BILLBOARDMODE_X: number;
  7502. /**
  7503. * Object will rotate to face the camera but only on the y axis
  7504. */
  7505. static BILLBOARDMODE_Y: number;
  7506. /**
  7507. * Object will rotate to face the camera but only on the z axis
  7508. */
  7509. static BILLBOARDMODE_Z: number;
  7510. /**
  7511. * Object will rotate to face the camera
  7512. */
  7513. static BILLBOARDMODE_ALL: number;
  7514. private _forward;
  7515. private _forwardInverted;
  7516. private _up;
  7517. private _right;
  7518. private _rightInverted;
  7519. private _position;
  7520. private _rotation;
  7521. private _rotationQuaternion;
  7522. protected _scaling: Vector3;
  7523. protected _isDirty: boolean;
  7524. private _transformToBoneReferal;
  7525. private _billboardMode;
  7526. /**
  7527. * Gets or sets the billboard mode. Default is 0.
  7528. *
  7529. * | Value | Type | Description |
  7530. * | --- | --- | --- |
  7531. * | 0 | BILLBOARDMODE_NONE | |
  7532. * | 1 | BILLBOARDMODE_X | |
  7533. * | 2 | BILLBOARDMODE_Y | |
  7534. * | 4 | BILLBOARDMODE_Z | |
  7535. * | 7 | BILLBOARDMODE_ALL | |
  7536. *
  7537. */
  7538. billboardMode: number;
  7539. private _preserveParentRotationForBillboard;
  7540. /**
  7541. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7542. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7543. */
  7544. preserveParentRotationForBillboard: boolean;
  7545. /**
  7546. * 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
  7547. */
  7548. scalingDeterminant: number;
  7549. private _infiniteDistance;
  7550. /**
  7551. * Gets or sets the distance of the object to max, often used by skybox
  7552. */
  7553. infiniteDistance: boolean;
  7554. /**
  7555. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7556. * By default the system will update normals to compensate
  7557. */
  7558. ignoreNonUniformScaling: boolean;
  7559. /**
  7560. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7561. */
  7562. reIntegrateRotationIntoRotationQuaternion: boolean;
  7563. /** @hidden */
  7564. _poseMatrix: Nullable<Matrix>;
  7565. /** @hidden */
  7566. _localMatrix: Matrix;
  7567. private _usePivotMatrix;
  7568. private _absolutePosition;
  7569. private _pivotMatrix;
  7570. private _pivotMatrixInverse;
  7571. protected _postMultiplyPivotMatrix: boolean;
  7572. protected _isWorldMatrixFrozen: boolean;
  7573. /** @hidden */
  7574. _indexInSceneTransformNodesArray: number;
  7575. /**
  7576. * An event triggered after the world matrix is updated
  7577. */
  7578. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7579. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7580. /**
  7581. * Gets a string identifying the name of the class
  7582. * @returns "TransformNode" string
  7583. */
  7584. getClassName(): string;
  7585. /**
  7586. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7587. */
  7588. position: Vector3;
  7589. /**
  7590. * 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)).
  7591. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7592. */
  7593. rotation: Vector3;
  7594. /**
  7595. * 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)).
  7596. */
  7597. scaling: Vector3;
  7598. /**
  7599. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  7600. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7601. */
  7602. rotationQuaternion: Nullable<Quaternion>;
  7603. /**
  7604. * The forward direction of that transform in world space.
  7605. */
  7606. readonly forward: Vector3;
  7607. /**
  7608. * The up direction of that transform in world space.
  7609. */
  7610. readonly up: Vector3;
  7611. /**
  7612. * The right direction of that transform in world space.
  7613. */
  7614. readonly right: Vector3;
  7615. /**
  7616. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7617. * @param matrix the matrix to copy the pose from
  7618. * @returns this TransformNode.
  7619. */
  7620. updatePoseMatrix(matrix: Matrix): TransformNode;
  7621. /**
  7622. * Returns the mesh Pose matrix.
  7623. * @returns the pose matrix
  7624. */
  7625. getPoseMatrix(): Matrix;
  7626. /** @hidden */
  7627. _isSynchronized(): boolean;
  7628. /** @hidden */
  7629. _initCache(): void;
  7630. /**
  7631. * Flag the transform node as dirty (Forcing it to update everything)
  7632. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7633. * @returns this transform node
  7634. */
  7635. markAsDirty(property: string): TransformNode;
  7636. /**
  7637. * Returns the current mesh absolute position.
  7638. * Returns a Vector3.
  7639. */
  7640. readonly absolutePosition: Vector3;
  7641. /**
  7642. * Sets a new matrix to apply before all other transformation
  7643. * @param matrix defines the transform matrix
  7644. * @returns the current TransformNode
  7645. */
  7646. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7647. /**
  7648. * Sets a new pivot matrix to the current node
  7649. * @param matrix defines the new pivot matrix to use
  7650. * @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
  7651. * @returns the current TransformNode
  7652. */
  7653. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7654. /**
  7655. * Returns the mesh pivot matrix.
  7656. * Default : Identity.
  7657. * @returns the matrix
  7658. */
  7659. getPivotMatrix(): Matrix;
  7660. /**
  7661. * Prevents the World matrix to be computed any longer.
  7662. * @returns the TransformNode.
  7663. */
  7664. freezeWorldMatrix(): TransformNode;
  7665. /**
  7666. * Allows back the World matrix computation.
  7667. * @returns the TransformNode.
  7668. */
  7669. unfreezeWorldMatrix(): this;
  7670. /**
  7671. * True if the World matrix has been frozen.
  7672. */
  7673. readonly isWorldMatrixFrozen: boolean;
  7674. /**
  7675. * Retuns the mesh absolute position in the World.
  7676. * @returns a Vector3.
  7677. */
  7678. getAbsolutePosition(): Vector3;
  7679. /**
  7680. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7681. * @param absolutePosition the absolute position to set
  7682. * @returns the TransformNode.
  7683. */
  7684. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7685. /**
  7686. * Sets the mesh position in its local space.
  7687. * @param vector3 the position to set in localspace
  7688. * @returns the TransformNode.
  7689. */
  7690. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7691. /**
  7692. * Returns the mesh position in the local space from the current World matrix values.
  7693. * @returns a new Vector3.
  7694. */
  7695. getPositionExpressedInLocalSpace(): Vector3;
  7696. /**
  7697. * Translates the mesh along the passed Vector3 in its local space.
  7698. * @param vector3 the distance to translate in localspace
  7699. * @returns the TransformNode.
  7700. */
  7701. locallyTranslate(vector3: Vector3): TransformNode;
  7702. private static _lookAtVectorCache;
  7703. /**
  7704. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7705. * @param targetPoint the position (must be in same space as current mesh) to look at
  7706. * @param yawCor optional yaw (y-axis) correction in radians
  7707. * @param pitchCor optional pitch (x-axis) correction in radians
  7708. * @param rollCor optional roll (z-axis) correction in radians
  7709. * @param space the choosen space of the target
  7710. * @returns the TransformNode.
  7711. */
  7712. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7713. /**
  7714. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7715. * This Vector3 is expressed in the World space.
  7716. * @param localAxis axis to rotate
  7717. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7718. */
  7719. getDirection(localAxis: Vector3): Vector3;
  7720. /**
  7721. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7722. * localAxis is expressed in the mesh local space.
  7723. * result is computed in the Wordl space from the mesh World matrix.
  7724. * @param localAxis axis to rotate
  7725. * @param result the resulting transformnode
  7726. * @returns this TransformNode.
  7727. */
  7728. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7729. /**
  7730. * Sets this transform node rotation to the given local axis.
  7731. * @param localAxis the axis in local space
  7732. * @param yawCor optional yaw (y-axis) correction in radians
  7733. * @param pitchCor optional pitch (x-axis) correction in radians
  7734. * @param rollCor optional roll (z-axis) correction in radians
  7735. * @returns this TransformNode
  7736. */
  7737. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7738. /**
  7739. * Sets a new pivot point to the current node
  7740. * @param point defines the new pivot point to use
  7741. * @param space defines if the point is in world or local space (local by default)
  7742. * @returns the current TransformNode
  7743. */
  7744. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7745. /**
  7746. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7747. * @returns the pivot point
  7748. */
  7749. getPivotPoint(): Vector3;
  7750. /**
  7751. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7752. * @param result the vector3 to store the result
  7753. * @returns this TransformNode.
  7754. */
  7755. getPivotPointToRef(result: Vector3): TransformNode;
  7756. /**
  7757. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7758. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7759. */
  7760. getAbsolutePivotPoint(): Vector3;
  7761. /**
  7762. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7763. * @param result vector3 to store the result
  7764. * @returns this TransformNode.
  7765. */
  7766. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7767. /**
  7768. * Defines the passed node as the parent of the current node.
  7769. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7770. * @see https://doc.babylonjs.com/how_to/parenting
  7771. * @param node the node ot set as the parent
  7772. * @returns this TransformNode.
  7773. */
  7774. setParent(node: Nullable<Node>): TransformNode;
  7775. private _nonUniformScaling;
  7776. /**
  7777. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7778. */
  7779. readonly nonUniformScaling: boolean;
  7780. /** @hidden */
  7781. _updateNonUniformScalingState(value: boolean): boolean;
  7782. /**
  7783. * Attach the current TransformNode to another TransformNode associated with a bone
  7784. * @param bone Bone affecting the TransformNode
  7785. * @param affectedTransformNode TransformNode associated with the bone
  7786. * @returns this object
  7787. */
  7788. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7789. /**
  7790. * Detach the transform node if its associated with a bone
  7791. * @returns this object
  7792. */
  7793. detachFromBone(): TransformNode;
  7794. private static _rotationAxisCache;
  7795. /**
  7796. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7797. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7798. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7799. * The passed axis is also normalized.
  7800. * @param axis the axis to rotate around
  7801. * @param amount the amount to rotate in radians
  7802. * @param space Space to rotate in (Default: local)
  7803. * @returns the TransformNode.
  7804. */
  7805. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7806. /**
  7807. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7808. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7809. * The passed axis is also normalized. .
  7810. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7811. * @param point the point to rotate around
  7812. * @param axis the axis to rotate around
  7813. * @param amount the amount to rotate in radians
  7814. * @returns the TransformNode
  7815. */
  7816. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7817. /**
  7818. * Translates the mesh along the axis vector for the passed distance in the given space.
  7819. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7820. * @param axis the axis to translate in
  7821. * @param distance the distance to translate
  7822. * @param space Space to rotate in (Default: local)
  7823. * @returns the TransformNode.
  7824. */
  7825. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7826. /**
  7827. * Adds a rotation step to the mesh current rotation.
  7828. * x, y, z are Euler angles expressed in radians.
  7829. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7830. * This means this rotation is made in the mesh local space only.
  7831. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7832. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7833. * ```javascript
  7834. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7835. * ```
  7836. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7837. * 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.
  7838. * @param x Rotation to add
  7839. * @param y Rotation to add
  7840. * @param z Rotation to add
  7841. * @returns the TransformNode.
  7842. */
  7843. addRotation(x: number, y: number, z: number): TransformNode;
  7844. /**
  7845. * @hidden
  7846. */
  7847. protected _getEffectiveParent(): Nullable<Node>;
  7848. /**
  7849. * Computes the world matrix of the node
  7850. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7851. * @returns the world matrix
  7852. */
  7853. computeWorldMatrix(force?: boolean): Matrix;
  7854. protected _afterComputeWorldMatrix(): void;
  7855. /**
  7856. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7857. * @param func callback function to add
  7858. *
  7859. * @returns the TransformNode.
  7860. */
  7861. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7862. /**
  7863. * Removes a registered callback function.
  7864. * @param func callback function to remove
  7865. * @returns the TransformNode.
  7866. */
  7867. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7868. /**
  7869. * Gets the position of the current mesh in camera space
  7870. * @param camera defines the camera to use
  7871. * @returns a position
  7872. */
  7873. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7874. /**
  7875. * Returns the distance from the mesh to the active camera
  7876. * @param camera defines the camera to use
  7877. * @returns the distance
  7878. */
  7879. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7880. /**
  7881. * Clone the current transform node
  7882. * @param name Name of the new clone
  7883. * @param newParent New parent for the clone
  7884. * @param doNotCloneChildren Do not clone children hierarchy
  7885. * @returns the new transform node
  7886. */
  7887. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7888. /**
  7889. * Serializes the objects information.
  7890. * @param currentSerializationObject defines the object to serialize in
  7891. * @returns the serialized object
  7892. */
  7893. serialize(currentSerializationObject?: any): any;
  7894. /**
  7895. * Returns a new TransformNode object parsed from the source provided.
  7896. * @param parsedTransformNode is the source.
  7897. * @param scene the scne the object belongs to
  7898. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7899. * @returns a new TransformNode object parsed from the source provided.
  7900. */
  7901. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7902. /**
  7903. * Get all child-transformNodes of this node
  7904. * @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
  7905. * @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
  7906. * @returns an array of TransformNode
  7907. */
  7908. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7909. /**
  7910. * Releases resources associated with this transform node.
  7911. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7912. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7913. */
  7914. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7915. }
  7916. }
  7917. declare module BABYLON {
  7918. /**
  7919. * Class used to override all child animations of a given target
  7920. */
  7921. export class AnimationPropertiesOverride {
  7922. /**
  7923. * Gets or sets a value indicating if animation blending must be used
  7924. */
  7925. enableBlending: boolean;
  7926. /**
  7927. * Gets or sets the blending speed to use when enableBlending is true
  7928. */
  7929. blendingSpeed: number;
  7930. /**
  7931. * Gets or sets the default loop mode to use
  7932. */
  7933. loopMode: number;
  7934. }
  7935. }
  7936. declare module BABYLON {
  7937. /**
  7938. * Class used to store bone information
  7939. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7940. */
  7941. export class Bone extends Node {
  7942. /**
  7943. * defines the bone name
  7944. */
  7945. name: string;
  7946. private static _tmpVecs;
  7947. private static _tmpQuat;
  7948. private static _tmpMats;
  7949. /**
  7950. * Gets the list of child bones
  7951. */
  7952. children: Bone[];
  7953. /** Gets the animations associated with this bone */
  7954. animations: Animation[];
  7955. /**
  7956. * Gets or sets bone length
  7957. */
  7958. length: number;
  7959. /**
  7960. * @hidden Internal only
  7961. * Set this value to map this bone to a different index in the transform matrices
  7962. * Set this value to -1 to exclude the bone from the transform matrices
  7963. */
  7964. _index: Nullable<number>;
  7965. private _skeleton;
  7966. private _localMatrix;
  7967. private _restPose;
  7968. private _baseMatrix;
  7969. private _absoluteTransform;
  7970. private _invertedAbsoluteTransform;
  7971. private _parent;
  7972. private _scalingDeterminant;
  7973. private _worldTransform;
  7974. private _localScaling;
  7975. private _localRotation;
  7976. private _localPosition;
  7977. private _needToDecompose;
  7978. private _needToCompose;
  7979. /** @hidden */
  7980. _linkedTransformNode: Nullable<TransformNode>;
  7981. /** @hidden */
  7982. /** @hidden */
  7983. _matrix: Matrix;
  7984. /**
  7985. * Create a new bone
  7986. * @param name defines the bone name
  7987. * @param skeleton defines the parent skeleton
  7988. * @param parentBone defines the parent (can be null if the bone is the root)
  7989. * @param localMatrix defines the local matrix
  7990. * @param restPose defines the rest pose matrix
  7991. * @param baseMatrix defines the base matrix
  7992. * @param index defines index of the bone in the hiearchy
  7993. */
  7994. constructor(
  7995. /**
  7996. * defines the bone name
  7997. */
  7998. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7999. /**
  8000. * Gets the current object class name.
  8001. * @return the class name
  8002. */
  8003. getClassName(): string;
  8004. /**
  8005. * Gets the parent skeleton
  8006. * @returns a skeleton
  8007. */
  8008. getSkeleton(): Skeleton;
  8009. /**
  8010. * Gets parent bone
  8011. * @returns a bone or null if the bone is the root of the bone hierarchy
  8012. */
  8013. getParent(): Nullable<Bone>;
  8014. /**
  8015. * Returns an array containing the root bones
  8016. * @returns an array containing the root bones
  8017. */
  8018. getChildren(): Array<Bone>;
  8019. /**
  8020. * Sets the parent bone
  8021. * @param parent defines the parent (can be null if the bone is the root)
  8022. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8023. */
  8024. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8025. /**
  8026. * Gets the local matrix
  8027. * @returns a matrix
  8028. */
  8029. getLocalMatrix(): Matrix;
  8030. /**
  8031. * Gets the base matrix (initial matrix which remains unchanged)
  8032. * @returns a matrix
  8033. */
  8034. getBaseMatrix(): Matrix;
  8035. /**
  8036. * Gets the rest pose matrix
  8037. * @returns a matrix
  8038. */
  8039. getRestPose(): Matrix;
  8040. /**
  8041. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8042. */
  8043. getWorldMatrix(): Matrix;
  8044. /**
  8045. * Sets the local matrix to rest pose matrix
  8046. */
  8047. returnToRest(): void;
  8048. /**
  8049. * Gets the inverse of the absolute transform matrix.
  8050. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8051. * @returns a matrix
  8052. */
  8053. getInvertedAbsoluteTransform(): Matrix;
  8054. /**
  8055. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8056. * @returns a matrix
  8057. */
  8058. getAbsoluteTransform(): Matrix;
  8059. /**
  8060. * Links with the given transform node.
  8061. * The local matrix of this bone is copied from the transform node every frame.
  8062. * @param transformNode defines the transform node to link to
  8063. */
  8064. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8065. /** Gets or sets current position (in local space) */
  8066. position: Vector3;
  8067. /** Gets or sets current rotation (in local space) */
  8068. rotation: Vector3;
  8069. /** Gets or sets current rotation quaternion (in local space) */
  8070. rotationQuaternion: Quaternion;
  8071. /** Gets or sets current scaling (in local space) */
  8072. scaling: Vector3;
  8073. /**
  8074. * Gets the animation properties override
  8075. */
  8076. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8077. private _decompose;
  8078. private _compose;
  8079. /**
  8080. * Update the base and local matrices
  8081. * @param matrix defines the new base or local matrix
  8082. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8083. * @param updateLocalMatrix defines if the local matrix should be updated
  8084. */
  8085. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8086. /** @hidden */
  8087. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8088. /**
  8089. * Flag the bone as dirty (Forcing it to update everything)
  8090. */
  8091. markAsDirty(): void;
  8092. private _markAsDirtyAndCompose;
  8093. private _markAsDirtyAndDecompose;
  8094. /**
  8095. * Translate the bone in local or world space
  8096. * @param vec The amount to translate the bone
  8097. * @param space The space that the translation is in
  8098. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8099. */
  8100. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8101. /**
  8102. * Set the postion of the bone in local or world space
  8103. * @param position The position to set the bone
  8104. * @param space The space that the position is in
  8105. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8106. */
  8107. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8108. /**
  8109. * Set the absolute position of the bone (world space)
  8110. * @param position The position to set the bone
  8111. * @param mesh The mesh that this bone is attached to
  8112. */
  8113. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8114. /**
  8115. * Scale the bone on the x, y and z axes (in local space)
  8116. * @param x The amount to scale the bone on the x axis
  8117. * @param y The amount to scale the bone on the y axis
  8118. * @param z The amount to scale the bone on the z axis
  8119. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8120. */
  8121. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8122. /**
  8123. * Set the bone scaling in local space
  8124. * @param scale defines the scaling vector
  8125. */
  8126. setScale(scale: Vector3): void;
  8127. /**
  8128. * Gets the current scaling in local space
  8129. * @returns the current scaling vector
  8130. */
  8131. getScale(): Vector3;
  8132. /**
  8133. * Gets the current scaling in local space and stores it in a target vector
  8134. * @param result defines the target vector
  8135. */
  8136. getScaleToRef(result: Vector3): void;
  8137. /**
  8138. * Set the yaw, pitch, and roll of the bone in local or world space
  8139. * @param yaw The rotation of the bone on the y axis
  8140. * @param pitch The rotation of the bone on the x axis
  8141. * @param roll The rotation of the bone on the z axis
  8142. * @param space The space that the axes of rotation are in
  8143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8144. */
  8145. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8146. /**
  8147. * Add a rotation to the bone on an axis in local or world space
  8148. * @param axis The axis to rotate the bone on
  8149. * @param amount The amount to rotate the bone
  8150. * @param space The space that the axis is in
  8151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8152. */
  8153. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8154. /**
  8155. * Set the rotation of the bone to a particular axis angle in local or world space
  8156. * @param axis The axis to rotate the bone on
  8157. * @param angle The angle that the bone should be rotated to
  8158. * @param space The space that the axis is in
  8159. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8160. */
  8161. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8162. /**
  8163. * Set the euler rotation of the bone in local of world space
  8164. * @param rotation The euler rotation that the bone should be set to
  8165. * @param space The space that the rotation is in
  8166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8167. */
  8168. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8169. /**
  8170. * Set the quaternion rotation of the bone in local of world space
  8171. * @param quat The quaternion rotation that the bone should be set to
  8172. * @param space The space that the rotation is in
  8173. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8174. */
  8175. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8176. /**
  8177. * Set the rotation matrix of the bone in local of world space
  8178. * @param rotMat The rotation matrix that the bone should be set to
  8179. * @param space The space that the rotation is in
  8180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8181. */
  8182. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8183. private _rotateWithMatrix;
  8184. private _getNegativeRotationToRef;
  8185. /**
  8186. * Get the position of the bone in local or world space
  8187. * @param space The space that the returned position is in
  8188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8189. * @returns The position of the bone
  8190. */
  8191. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8192. /**
  8193. * Copy the position of the bone to a vector3 in local or world space
  8194. * @param space The space that the returned position is in
  8195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8196. * @param result The vector3 to copy the position to
  8197. */
  8198. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8199. /**
  8200. * Get the absolute position of the bone (world space)
  8201. * @param mesh The mesh that this bone is attached to
  8202. * @returns The absolute position of the bone
  8203. */
  8204. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8205. /**
  8206. * Copy the absolute position of the bone (world space) to the result param
  8207. * @param mesh The mesh that this bone is attached to
  8208. * @param result The vector3 to copy the absolute position to
  8209. */
  8210. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8211. /**
  8212. * Compute the absolute transforms of this bone and its children
  8213. */
  8214. computeAbsoluteTransforms(): void;
  8215. /**
  8216. * Get the world direction from an axis that is in the local space of the bone
  8217. * @param localAxis The local direction that is used to compute the world direction
  8218. * @param mesh The mesh that this bone is attached to
  8219. * @returns The world direction
  8220. */
  8221. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8222. /**
  8223. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8224. * @param localAxis The local direction that is used to compute the world direction
  8225. * @param mesh The mesh that this bone is attached to
  8226. * @param result The vector3 that the world direction will be copied to
  8227. */
  8228. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8229. /**
  8230. * Get the euler rotation of the bone in local or world space
  8231. * @param space The space that the rotation should be in
  8232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8233. * @returns The euler rotation
  8234. */
  8235. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8236. /**
  8237. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8238. * @param space The space that the rotation should be in
  8239. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8240. * @param result The vector3 that the rotation should be copied to
  8241. */
  8242. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8243. /**
  8244. * Get the quaternion rotation of the bone in either local or world space
  8245. * @param space The space that the rotation should be in
  8246. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8247. * @returns The quaternion rotation
  8248. */
  8249. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8250. /**
  8251. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8252. * @param space The space that the rotation should be in
  8253. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8254. * @param result The quaternion that the rotation should be copied to
  8255. */
  8256. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8257. /**
  8258. * Get the rotation matrix of the bone in local or world space
  8259. * @param space The space that the rotation should be in
  8260. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8261. * @returns The rotation matrix
  8262. */
  8263. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8264. /**
  8265. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8266. * @param space The space that the rotation should be in
  8267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8268. * @param result The quaternion that the rotation should be copied to
  8269. */
  8270. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8271. /**
  8272. * Get the world position of a point that is in the local space of the bone
  8273. * @param position The local position
  8274. * @param mesh The mesh that this bone is attached to
  8275. * @returns The world position
  8276. */
  8277. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8278. /**
  8279. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8280. * @param position The local position
  8281. * @param mesh The mesh that this bone is attached to
  8282. * @param result The vector3 that the world position should be copied to
  8283. */
  8284. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8285. /**
  8286. * Get the local position of a point that is in world space
  8287. * @param position The world position
  8288. * @param mesh The mesh that this bone is attached to
  8289. * @returns The local position
  8290. */
  8291. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8292. /**
  8293. * Get the local position of a point that is in world space and copy it to the result param
  8294. * @param position The world position
  8295. * @param mesh The mesh that this bone is attached to
  8296. * @param result The vector3 that the local position should be copied to
  8297. */
  8298. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8299. }
  8300. }
  8301. declare module BABYLON {
  8302. /**
  8303. * Enum that determines the text-wrapping mode to use.
  8304. */
  8305. export enum InspectableType {
  8306. /**
  8307. * Checkbox for booleans
  8308. */
  8309. Checkbox = 0,
  8310. /**
  8311. * Sliders for numbers
  8312. */
  8313. Slider = 1,
  8314. /**
  8315. * Vector3
  8316. */
  8317. Vector3 = 2,
  8318. /**
  8319. * Quaternions
  8320. */
  8321. Quaternion = 3,
  8322. /**
  8323. * Color3
  8324. */
  8325. Color3 = 4
  8326. }
  8327. /**
  8328. * Interface used to define custom inspectable properties.
  8329. * This interface is used by the inspector to display custom property grids
  8330. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8331. */
  8332. export interface IInspectable {
  8333. /**
  8334. * Gets the label to display
  8335. */
  8336. label: string;
  8337. /**
  8338. * Gets the name of the property to edit
  8339. */
  8340. propertyName: string;
  8341. /**
  8342. * Gets the type of the editor to use
  8343. */
  8344. type: InspectableType;
  8345. /**
  8346. * Gets the minimum value of the property when using in "slider" mode
  8347. */
  8348. min?: number;
  8349. /**
  8350. * Gets the maximum value of the property when using in "slider" mode
  8351. */
  8352. max?: number;
  8353. /**
  8354. * Gets the setp to use when using in "slider" mode
  8355. */
  8356. step?: number;
  8357. }
  8358. }
  8359. declare module BABYLON {
  8360. /**
  8361. * This represents the required contract to create a new type of texture loader.
  8362. */
  8363. export interface IInternalTextureLoader {
  8364. /**
  8365. * Defines wether the loader supports cascade loading the different faces.
  8366. */
  8367. supportCascades: boolean;
  8368. /**
  8369. * This returns if the loader support the current file information.
  8370. * @param extension defines the file extension of the file being loaded
  8371. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8372. * @param fallback defines the fallback internal texture if any
  8373. * @param isBase64 defines whether the texture is encoded as a base64
  8374. * @param isBuffer defines whether the texture data are stored as a buffer
  8375. * @returns true if the loader can load the specified file
  8376. */
  8377. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8378. /**
  8379. * Transform the url before loading if required.
  8380. * @param rootUrl the url of the texture
  8381. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8382. * @returns the transformed texture
  8383. */
  8384. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8385. /**
  8386. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8387. * @param rootUrl the url of the texture
  8388. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8389. * @returns the fallback texture
  8390. */
  8391. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8392. /**
  8393. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8394. * @param data contains the texture data
  8395. * @param texture defines the BabylonJS internal texture
  8396. * @param createPolynomials will be true if polynomials have been requested
  8397. * @param onLoad defines the callback to trigger once the texture is ready
  8398. * @param onError defines the callback to trigger in case of error
  8399. */
  8400. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8401. /**
  8402. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8403. * @param data contains the texture data
  8404. * @param texture defines the BabylonJS internal texture
  8405. * @param callback defines the method to call once ready to upload
  8406. */
  8407. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8408. }
  8409. }
  8410. declare module BABYLON {
  8411. interface Engine {
  8412. /**
  8413. * Creates a depth stencil cube texture.
  8414. * This is only available in WebGL 2.
  8415. * @param size The size of face edge in the cube texture.
  8416. * @param options The options defining the cube texture.
  8417. * @returns The cube texture
  8418. */
  8419. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8420. /**
  8421. * Creates a cube texture
  8422. * @param rootUrl defines the url where the files to load is located
  8423. * @param scene defines the current scene
  8424. * @param files defines the list of files to load (1 per face)
  8425. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8426. * @param onLoad defines an optional callback raised when the texture is loaded
  8427. * @param onError defines an optional callback raised if there is an issue to load the texture
  8428. * @param format defines the format of the data
  8429. * @param forcedExtension defines the extension to use to pick the right loader
  8430. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8431. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8432. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8433. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8434. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8435. * @returns the cube texture as an InternalTexture
  8436. */
  8437. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  8438. /**
  8439. * Creates a cube texture
  8440. * @param rootUrl defines the url where the files to load is located
  8441. * @param scene defines the current scene
  8442. * @param files defines the list of files to load (1 per face)
  8443. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8444. * @param onLoad defines an optional callback raised when the texture is loaded
  8445. * @param onError defines an optional callback raised if there is an issue to load the texture
  8446. * @param format defines the format of the data
  8447. * @param forcedExtension defines the extension to use to pick the right loader
  8448. * @returns the cube texture as an InternalTexture
  8449. */
  8450. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  8451. /**
  8452. * Creates a cube texture
  8453. * @param rootUrl defines the url where the files to load is located
  8454. * @param scene defines the current scene
  8455. * @param files defines the list of files to load (1 per face)
  8456. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8457. * @param onLoad defines an optional callback raised when the texture is loaded
  8458. * @param onError defines an optional callback raised if there is an issue to load the texture
  8459. * @param format defines the format of the data
  8460. * @param forcedExtension defines the extension to use to pick the right loader
  8461. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8462. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8463. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8464. * @returns the cube texture as an InternalTexture
  8465. */
  8466. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  8467. /** @hidden */
  8468. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8469. /** @hidden */
  8470. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8471. /** @hidden */
  8472. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8473. /** @hidden */
  8474. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8475. }
  8476. }
  8477. declare module BABYLON {
  8478. /**
  8479. * Class for creating a cube texture
  8480. */
  8481. export class CubeTexture extends BaseTexture {
  8482. private _delayedOnLoad;
  8483. /**
  8484. * The url of the texture
  8485. */
  8486. url: string;
  8487. /**
  8488. * Gets or sets the center of the bounding box associated with the cube texture.
  8489. * It must define where the camera used to render the texture was set
  8490. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8491. */
  8492. boundingBoxPosition: Vector3;
  8493. private _boundingBoxSize;
  8494. /**
  8495. * Gets or sets the size of the bounding box associated with the cube texture
  8496. * When defined, the cubemap will switch to local mode
  8497. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8498. * @example https://www.babylonjs-playground.com/#RNASML
  8499. */
  8500. /**
  8501. * Returns the bounding box size
  8502. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8503. */
  8504. boundingBoxSize: Vector3;
  8505. protected _rotationY: number;
  8506. /**
  8507. * Sets texture matrix rotation angle around Y axis in radians.
  8508. */
  8509. /**
  8510. * Gets texture matrix rotation angle around Y axis radians.
  8511. */
  8512. rotationY: number;
  8513. /**
  8514. * Are mip maps generated for this texture or not.
  8515. */
  8516. readonly noMipmap: boolean;
  8517. private _noMipmap;
  8518. private _files;
  8519. private _extensions;
  8520. private _textureMatrix;
  8521. private _format;
  8522. private _createPolynomials;
  8523. /** @hidden */
  8524. _prefiltered: boolean;
  8525. /**
  8526. * Creates a cube texture from an array of image urls
  8527. * @param files defines an array of image urls
  8528. * @param scene defines the hosting scene
  8529. * @param noMipmap specifies if mip maps are not used
  8530. * @returns a cube texture
  8531. */
  8532. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8533. /**
  8534. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8535. * @param url defines the url of the prefiltered texture
  8536. * @param scene defines the scene the texture is attached to
  8537. * @param forcedExtension defines the extension of the file if different from the url
  8538. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8539. * @return the prefiltered texture
  8540. */
  8541. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8542. /**
  8543. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8544. * as prefiltered data.
  8545. * @param rootUrl defines the url of the texture or the root name of the six images
  8546. * @param scene defines the scene the texture is attached to
  8547. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8548. * @param noMipmap defines if mipmaps should be created or not
  8549. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8550. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8551. * @param onError defines a callback triggered in case of error during load
  8552. * @param format defines the internal format to use for the texture once loaded
  8553. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8554. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8555. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8556. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8557. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8558. * @return the cube texture
  8559. */
  8560. 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);
  8561. /**
  8562. * Get the current class name of the texture useful for serialization or dynamic coding.
  8563. * @returns "CubeTexture"
  8564. */
  8565. getClassName(): string;
  8566. /**
  8567. * Update the url (and optional buffer) of this texture if url was null during construction.
  8568. * @param url the url of the texture
  8569. * @param forcedExtension defines the extension to use
  8570. * @param onLoad callback called when the texture is loaded (defaults to null)
  8571. */
  8572. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8573. /**
  8574. * Delays loading of the cube texture
  8575. * @param forcedExtension defines the extension to use
  8576. */
  8577. delayLoad(forcedExtension?: string): void;
  8578. /**
  8579. * Returns the reflection texture matrix
  8580. * @returns the reflection texture matrix
  8581. */
  8582. getReflectionTextureMatrix(): Matrix;
  8583. /**
  8584. * Sets the reflection texture matrix
  8585. * @param value Reflection texture matrix
  8586. */
  8587. setReflectionTextureMatrix(value: Matrix): void;
  8588. /**
  8589. * Parses text to create a cube texture
  8590. * @param parsedTexture define the serialized text to read from
  8591. * @param scene defines the hosting scene
  8592. * @param rootUrl defines the root url of the cube texture
  8593. * @returns a cube texture
  8594. */
  8595. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8596. /**
  8597. * Makes a clone, or deep copy, of the cube texture
  8598. * @returns a new cube texture
  8599. */
  8600. clone(): CubeTexture;
  8601. }
  8602. }
  8603. declare module BABYLON {
  8604. /** @hidden */
  8605. export var postprocessVertexShader: {
  8606. name: string;
  8607. shader: string;
  8608. };
  8609. }
  8610. declare module BABYLON {
  8611. /**
  8612. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8613. * This is the base of the follow, arc rotate cameras and Free camera
  8614. * @see http://doc.babylonjs.com/features/cameras
  8615. */
  8616. export class TargetCamera extends Camera {
  8617. private static _RigCamTransformMatrix;
  8618. private static _TargetTransformMatrix;
  8619. private static _TargetFocalPoint;
  8620. /**
  8621. * Define the current direction the camera is moving to
  8622. */
  8623. cameraDirection: Vector3;
  8624. /**
  8625. * Define the current rotation the camera is rotating to
  8626. */
  8627. cameraRotation: Vector2;
  8628. /**
  8629. * When set, the up vector of the camera will be updated by the rotation of the camera
  8630. */
  8631. updateUpVectorFromRotation: boolean;
  8632. private _tmpQuaternion;
  8633. /**
  8634. * Define the current rotation of the camera
  8635. */
  8636. rotation: Vector3;
  8637. /**
  8638. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8639. */
  8640. rotationQuaternion: Quaternion;
  8641. /**
  8642. * Define the current speed of the camera
  8643. */
  8644. speed: number;
  8645. /**
  8646. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8647. * around all axis.
  8648. */
  8649. noRotationConstraint: boolean;
  8650. /**
  8651. * Define the current target of the camera as an object or a position.
  8652. */
  8653. lockedTarget: any;
  8654. /** @hidden */
  8655. _currentTarget: Vector3;
  8656. /** @hidden */
  8657. _initialFocalDistance: number;
  8658. /** @hidden */
  8659. _viewMatrix: Matrix;
  8660. /** @hidden */
  8661. _camMatrix: Matrix;
  8662. /** @hidden */
  8663. _cameraTransformMatrix: Matrix;
  8664. /** @hidden */
  8665. _cameraRotationMatrix: Matrix;
  8666. /** @hidden */
  8667. _referencePoint: Vector3;
  8668. /** @hidden */
  8669. _transformedReferencePoint: Vector3;
  8670. protected _globalCurrentTarget: Vector3;
  8671. protected _globalCurrentUpVector: Vector3;
  8672. /** @hidden */
  8673. _reset: () => void;
  8674. private _defaultUp;
  8675. /**
  8676. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8677. * This is the base of the follow, arc rotate cameras and Free camera
  8678. * @see http://doc.babylonjs.com/features/cameras
  8679. * @param name Defines the name of the camera in the scene
  8680. * @param position Defines the start position of the camera in the scene
  8681. * @param scene Defines the scene the camera belongs to
  8682. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8683. */
  8684. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8685. /**
  8686. * Gets the position in front of the camera at a given distance.
  8687. * @param distance The distance from the camera we want the position to be
  8688. * @returns the position
  8689. */
  8690. getFrontPosition(distance: number): Vector3;
  8691. /** @hidden */
  8692. _getLockedTargetPosition(): Nullable<Vector3>;
  8693. private _storedPosition;
  8694. private _storedRotation;
  8695. private _storedRotationQuaternion;
  8696. /**
  8697. * Store current camera state of the camera (fov, position, rotation, etc..)
  8698. * @returns the camera
  8699. */
  8700. storeState(): Camera;
  8701. /**
  8702. * Restored camera state. You must call storeState() first
  8703. * @returns whether it was successful or not
  8704. * @hidden
  8705. */
  8706. _restoreStateValues(): boolean;
  8707. /** @hidden */
  8708. _initCache(): void;
  8709. /** @hidden */
  8710. _updateCache(ignoreParentClass?: boolean): void;
  8711. /** @hidden */
  8712. _isSynchronizedViewMatrix(): boolean;
  8713. /** @hidden */
  8714. _computeLocalCameraSpeed(): number;
  8715. /**
  8716. * Defines the target the camera should look at.
  8717. * This will automatically adapt alpha beta and radius to fit within the new target.
  8718. * @param target Defines the new target as a Vector or a mesh
  8719. */
  8720. setTarget(target: Vector3): void;
  8721. /**
  8722. * Return the current target position of the camera. This value is expressed in local space.
  8723. * @returns the target position
  8724. */
  8725. getTarget(): Vector3;
  8726. /** @hidden */
  8727. _decideIfNeedsToMove(): boolean;
  8728. /** @hidden */
  8729. _updatePosition(): void;
  8730. /** @hidden */
  8731. _checkInputs(): void;
  8732. protected _updateCameraRotationMatrix(): void;
  8733. /**
  8734. * 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)
  8735. * @returns the current camera
  8736. */
  8737. private _rotateUpVectorWithCameraRotationMatrix;
  8738. private _cachedRotationZ;
  8739. private _cachedQuaternionRotationZ;
  8740. /** @hidden */
  8741. _getViewMatrix(): Matrix;
  8742. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8743. /**
  8744. * @hidden
  8745. */
  8746. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8747. /**
  8748. * @hidden
  8749. */
  8750. _updateRigCameras(): void;
  8751. private _getRigCamPositionAndTarget;
  8752. /**
  8753. * Gets the current object class name.
  8754. * @return the class name
  8755. */
  8756. getClassName(): string;
  8757. }
  8758. }
  8759. declare module BABYLON {
  8760. /**
  8761. * @ignore
  8762. * This is a list of all the different input types that are available in the application.
  8763. * Fo instance: ArcRotateCameraGamepadInput...
  8764. */
  8765. export var CameraInputTypes: {};
  8766. /**
  8767. * This is the contract to implement in order to create a new input class.
  8768. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8769. */
  8770. export interface ICameraInput<TCamera extends Camera> {
  8771. /**
  8772. * Defines the camera the input is attached to.
  8773. */
  8774. camera: Nullable<TCamera>;
  8775. /**
  8776. * Gets the class name of the current intput.
  8777. * @returns the class name
  8778. */
  8779. getClassName(): string;
  8780. /**
  8781. * Get the friendly name associated with the input class.
  8782. * @returns the input friendly name
  8783. */
  8784. getSimpleName(): string;
  8785. /**
  8786. * Attach the input controls to a specific dom element to get the input from.
  8787. * @param element Defines the element the controls should be listened from
  8788. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8789. */
  8790. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8791. /**
  8792. * Detach the current controls from the specified dom element.
  8793. * @param element Defines the element to stop listening the inputs from
  8794. */
  8795. detachControl(element: Nullable<HTMLElement>): void;
  8796. /**
  8797. * Update the current camera state depending on the inputs that have been used this frame.
  8798. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8799. */
  8800. checkInputs?: () => void;
  8801. }
  8802. /**
  8803. * Represents a map of input types to input instance or input index to input instance.
  8804. */
  8805. export interface CameraInputsMap<TCamera extends Camera> {
  8806. /**
  8807. * Accessor to the input by input type.
  8808. */
  8809. [name: string]: ICameraInput<TCamera>;
  8810. /**
  8811. * Accessor to the input by input index.
  8812. */
  8813. [idx: number]: ICameraInput<TCamera>;
  8814. }
  8815. /**
  8816. * This represents the input manager used within a camera.
  8817. * It helps dealing with all the different kind of input attached to a camera.
  8818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8819. */
  8820. export class CameraInputsManager<TCamera extends Camera> {
  8821. /**
  8822. * Defines the list of inputs attahed to the camera.
  8823. */
  8824. attached: CameraInputsMap<TCamera>;
  8825. /**
  8826. * Defines the dom element the camera is collecting inputs from.
  8827. * This is null if the controls have not been attached.
  8828. */
  8829. attachedElement: Nullable<HTMLElement>;
  8830. /**
  8831. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8832. */
  8833. noPreventDefault: boolean;
  8834. /**
  8835. * Defined the camera the input manager belongs to.
  8836. */
  8837. camera: TCamera;
  8838. /**
  8839. * Update the current camera state depending on the inputs that have been used this frame.
  8840. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8841. */
  8842. checkInputs: () => void;
  8843. /**
  8844. * Instantiate a new Camera Input Manager.
  8845. * @param camera Defines the camera the input manager blongs to
  8846. */
  8847. constructor(camera: TCamera);
  8848. /**
  8849. * Add an input method to a camera
  8850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8851. * @param input camera input method
  8852. */
  8853. add(input: ICameraInput<TCamera>): void;
  8854. /**
  8855. * Remove a specific input method from a camera
  8856. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8857. * @param inputToRemove camera input method
  8858. */
  8859. remove(inputToRemove: ICameraInput<TCamera>): void;
  8860. /**
  8861. * Remove a specific input type from a camera
  8862. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8863. * @param inputType the type of the input to remove
  8864. */
  8865. removeByType(inputType: string): void;
  8866. private _addCheckInputs;
  8867. /**
  8868. * Attach the input controls to the currently attached dom element to listen the events from.
  8869. * @param input Defines the input to attach
  8870. */
  8871. attachInput(input: ICameraInput<TCamera>): void;
  8872. /**
  8873. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8874. * @param element Defines the dom element to collect the events from
  8875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8876. */
  8877. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8878. /**
  8879. * Detach the current manager inputs controls from a specific dom element.
  8880. * @param element Defines the dom element to collect the events from
  8881. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8882. */
  8883. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8884. /**
  8885. * Rebuild the dynamic inputCheck function from the current list of
  8886. * defined inputs in the manager.
  8887. */
  8888. rebuildInputCheck(): void;
  8889. /**
  8890. * Remove all attached input methods from a camera
  8891. */
  8892. clear(): void;
  8893. /**
  8894. * Serialize the current input manager attached to a camera.
  8895. * This ensures than once parsed,
  8896. * the input associated to the camera will be identical to the current ones
  8897. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8898. */
  8899. serialize(serializedCamera: any): void;
  8900. /**
  8901. * Parses an input manager serialized JSON to restore the previous list of inputs
  8902. * and states associated to a camera.
  8903. * @param parsedCamera Defines the JSON to parse
  8904. */
  8905. parse(parsedCamera: any): void;
  8906. }
  8907. }
  8908. declare module BABYLON {
  8909. /**
  8910. * Gather the list of keyboard event types as constants.
  8911. */
  8912. export class KeyboardEventTypes {
  8913. /**
  8914. * The keydown event is fired when a key becomes active (pressed).
  8915. */
  8916. static readonly KEYDOWN: number;
  8917. /**
  8918. * The keyup event is fired when a key has been released.
  8919. */
  8920. static readonly KEYUP: number;
  8921. }
  8922. /**
  8923. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8924. */
  8925. export class KeyboardInfo {
  8926. /**
  8927. * Defines the type of event (KeyboardEventTypes)
  8928. */
  8929. type: number;
  8930. /**
  8931. * Defines the related dom event
  8932. */
  8933. event: KeyboardEvent;
  8934. /**
  8935. * Instantiates a new keyboard info.
  8936. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8937. * @param type Defines the type of event (KeyboardEventTypes)
  8938. * @param event Defines the related dom event
  8939. */
  8940. constructor(
  8941. /**
  8942. * Defines the type of event (KeyboardEventTypes)
  8943. */
  8944. type: number,
  8945. /**
  8946. * Defines the related dom event
  8947. */
  8948. event: KeyboardEvent);
  8949. }
  8950. /**
  8951. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8952. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8953. */
  8954. export class KeyboardInfoPre extends KeyboardInfo {
  8955. /**
  8956. * Defines the type of event (KeyboardEventTypes)
  8957. */
  8958. type: number;
  8959. /**
  8960. * Defines the related dom event
  8961. */
  8962. event: KeyboardEvent;
  8963. /**
  8964. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8965. */
  8966. skipOnPointerObservable: boolean;
  8967. /**
  8968. * Instantiates a new keyboard pre info.
  8969. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8970. * @param type Defines the type of event (KeyboardEventTypes)
  8971. * @param event Defines the related dom event
  8972. */
  8973. constructor(
  8974. /**
  8975. * Defines the type of event (KeyboardEventTypes)
  8976. */
  8977. type: number,
  8978. /**
  8979. * Defines the related dom event
  8980. */
  8981. event: KeyboardEvent);
  8982. }
  8983. }
  8984. declare module BABYLON {
  8985. /**
  8986. * Manage the keyboard inputs to control the movement of a free camera.
  8987. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8988. */
  8989. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8990. /**
  8991. * Defines the camera the input is attached to.
  8992. */
  8993. camera: FreeCamera;
  8994. /**
  8995. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8996. */
  8997. keysUp: number[];
  8998. /**
  8999. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9000. */
  9001. keysDown: number[];
  9002. /**
  9003. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9004. */
  9005. keysLeft: number[];
  9006. /**
  9007. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9008. */
  9009. keysRight: number[];
  9010. private _keys;
  9011. private _onCanvasBlurObserver;
  9012. private _onKeyboardObserver;
  9013. private _engine;
  9014. private _scene;
  9015. /**
  9016. * Attach the input controls to a specific dom element to get the input from.
  9017. * @param element Defines the element the controls should be listened from
  9018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9019. */
  9020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9021. /**
  9022. * Detach the current controls from the specified dom element.
  9023. * @param element Defines the element to stop listening the inputs from
  9024. */
  9025. detachControl(element: Nullable<HTMLElement>): void;
  9026. /**
  9027. * Update the current camera state depending on the inputs that have been used this frame.
  9028. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9029. */
  9030. checkInputs(): void;
  9031. /**
  9032. * Gets the class name of the current intput.
  9033. * @returns the class name
  9034. */
  9035. getClassName(): string;
  9036. /** @hidden */
  9037. _onLostFocus(): void;
  9038. /**
  9039. * Get the friendly name associated with the input class.
  9040. * @returns the input friendly name
  9041. */
  9042. getSimpleName(): string;
  9043. }
  9044. }
  9045. declare module BABYLON {
  9046. /**
  9047. * Interface describing all the common properties and methods a shadow light needs to implement.
  9048. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9049. * as well as binding the different shadow properties to the effects.
  9050. */
  9051. export interface IShadowLight extends Light {
  9052. /**
  9053. * The light id in the scene (used in scene.findLighById for instance)
  9054. */
  9055. id: string;
  9056. /**
  9057. * The position the shdow will be casted from.
  9058. */
  9059. position: Vector3;
  9060. /**
  9061. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9062. */
  9063. direction: Vector3;
  9064. /**
  9065. * The transformed position. Position of the light in world space taking parenting in account.
  9066. */
  9067. transformedPosition: Vector3;
  9068. /**
  9069. * The transformed direction. Direction of the light in world space taking parenting in account.
  9070. */
  9071. transformedDirection: Vector3;
  9072. /**
  9073. * The friendly name of the light in the scene.
  9074. */
  9075. name: string;
  9076. /**
  9077. * Defines the shadow projection clipping minimum z value.
  9078. */
  9079. shadowMinZ: number;
  9080. /**
  9081. * Defines the shadow projection clipping maximum z value.
  9082. */
  9083. shadowMaxZ: number;
  9084. /**
  9085. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9086. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9087. */
  9088. computeTransformedInformation(): boolean;
  9089. /**
  9090. * Gets the scene the light belongs to.
  9091. * @returns The scene
  9092. */
  9093. getScene(): Scene;
  9094. /**
  9095. * Callback defining a custom Projection Matrix Builder.
  9096. * This can be used to override the default projection matrix computation.
  9097. */
  9098. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9099. /**
  9100. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9101. * @param matrix The materix to updated with the projection information
  9102. * @param viewMatrix The transform matrix of the light
  9103. * @param renderList The list of mesh to render in the map
  9104. * @returns The current light
  9105. */
  9106. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9107. /**
  9108. * Gets the current depth scale used in ESM.
  9109. * @returns The scale
  9110. */
  9111. getDepthScale(): number;
  9112. /**
  9113. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9114. * @returns true if a cube texture needs to be use
  9115. */
  9116. needCube(): boolean;
  9117. /**
  9118. * Detects if the projection matrix requires to be recomputed this frame.
  9119. * @returns true if it requires to be recomputed otherwise, false.
  9120. */
  9121. needProjectionMatrixCompute(): boolean;
  9122. /**
  9123. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9124. */
  9125. forceProjectionMatrixCompute(): void;
  9126. /**
  9127. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9128. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9129. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9130. */
  9131. getShadowDirection(faceIndex?: number): Vector3;
  9132. /**
  9133. * Gets the minZ used for shadow according to both the scene and the light.
  9134. * @param activeCamera The camera we are returning the min for
  9135. * @returns the depth min z
  9136. */
  9137. getDepthMinZ(activeCamera: Camera): number;
  9138. /**
  9139. * Gets the maxZ used for shadow according to both the scene and the light.
  9140. * @param activeCamera The camera we are returning the max for
  9141. * @returns the depth max z
  9142. */
  9143. getDepthMaxZ(activeCamera: Camera): number;
  9144. }
  9145. /**
  9146. * Base implementation IShadowLight
  9147. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9148. */
  9149. export abstract class ShadowLight extends Light implements IShadowLight {
  9150. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9151. protected _position: Vector3;
  9152. protected _setPosition(value: Vector3): void;
  9153. /**
  9154. * Sets the position the shadow will be casted from. Also use as the light position for both
  9155. * point and spot lights.
  9156. */
  9157. /**
  9158. * Sets the position the shadow will be casted from. Also use as the light position for both
  9159. * point and spot lights.
  9160. */
  9161. position: Vector3;
  9162. protected _direction: Vector3;
  9163. protected _setDirection(value: Vector3): void;
  9164. /**
  9165. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9166. * Also use as the light direction on spot and directional lights.
  9167. */
  9168. /**
  9169. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9170. * Also use as the light direction on spot and directional lights.
  9171. */
  9172. direction: Vector3;
  9173. private _shadowMinZ;
  9174. /**
  9175. * Gets the shadow projection clipping minimum z value.
  9176. */
  9177. /**
  9178. * Sets the shadow projection clipping minimum z value.
  9179. */
  9180. shadowMinZ: number;
  9181. private _shadowMaxZ;
  9182. /**
  9183. * Sets the shadow projection clipping maximum z value.
  9184. */
  9185. /**
  9186. * Gets the shadow projection clipping maximum z value.
  9187. */
  9188. shadowMaxZ: number;
  9189. /**
  9190. * Callback defining a custom Projection Matrix Builder.
  9191. * This can be used to override the default projection matrix computation.
  9192. */
  9193. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9194. /**
  9195. * The transformed position. Position of the light in world space taking parenting in account.
  9196. */
  9197. transformedPosition: Vector3;
  9198. /**
  9199. * The transformed direction. Direction of the light in world space taking parenting in account.
  9200. */
  9201. transformedDirection: Vector3;
  9202. private _needProjectionMatrixCompute;
  9203. /**
  9204. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9205. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9206. */
  9207. computeTransformedInformation(): boolean;
  9208. /**
  9209. * Return the depth scale used for the shadow map.
  9210. * @returns the depth scale.
  9211. */
  9212. getDepthScale(): number;
  9213. /**
  9214. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9215. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9216. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9217. */
  9218. getShadowDirection(faceIndex?: number): Vector3;
  9219. /**
  9220. * Returns the ShadowLight absolute position in the World.
  9221. * @returns the position vector in world space
  9222. */
  9223. getAbsolutePosition(): Vector3;
  9224. /**
  9225. * Sets the ShadowLight direction toward the passed target.
  9226. * @param target The point to target in local space
  9227. * @returns the updated ShadowLight direction
  9228. */
  9229. setDirectionToTarget(target: Vector3): Vector3;
  9230. /**
  9231. * Returns the light rotation in euler definition.
  9232. * @returns the x y z rotation in local space.
  9233. */
  9234. getRotation(): Vector3;
  9235. /**
  9236. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9237. * @returns true if a cube texture needs to be use
  9238. */
  9239. needCube(): boolean;
  9240. /**
  9241. * Detects if the projection matrix requires to be recomputed this frame.
  9242. * @returns true if it requires to be recomputed otherwise, false.
  9243. */
  9244. needProjectionMatrixCompute(): boolean;
  9245. /**
  9246. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9247. */
  9248. forceProjectionMatrixCompute(): void;
  9249. /** @hidden */
  9250. _initCache(): void;
  9251. /** @hidden */
  9252. _isSynchronized(): boolean;
  9253. /**
  9254. * Computes the world matrix of the node
  9255. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9256. * @returns the world matrix
  9257. */
  9258. computeWorldMatrix(force?: boolean): Matrix;
  9259. /**
  9260. * Gets the minZ used for shadow according to both the scene and the light.
  9261. * @param activeCamera The camera we are returning the min for
  9262. * @returns the depth min z
  9263. */
  9264. getDepthMinZ(activeCamera: Camera): number;
  9265. /**
  9266. * Gets the maxZ used for shadow according to both the scene and the light.
  9267. * @param activeCamera The camera we are returning the max for
  9268. * @returns the depth max z
  9269. */
  9270. getDepthMaxZ(activeCamera: Camera): number;
  9271. /**
  9272. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9273. * @param matrix The materix to updated with the projection information
  9274. * @param viewMatrix The transform matrix of the light
  9275. * @param renderList The list of mesh to render in the map
  9276. * @returns The current light
  9277. */
  9278. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9279. }
  9280. }
  9281. declare module BABYLON {
  9282. /**
  9283. * "Static Class" containing the most commonly used helper while dealing with material for
  9284. * rendering purpose.
  9285. *
  9286. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9287. *
  9288. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9289. */
  9290. export class MaterialHelper {
  9291. /**
  9292. * Bind the current view position to an effect.
  9293. * @param effect The effect to be bound
  9294. * @param scene The scene the eyes position is used from
  9295. */
  9296. static BindEyePosition(effect: Effect, scene: Scene): void;
  9297. /**
  9298. * Helps preparing the defines values about the UVs in used in the effect.
  9299. * UVs are shared as much as we can accross channels in the shaders.
  9300. * @param texture The texture we are preparing the UVs for
  9301. * @param defines The defines to update
  9302. * @param key The channel key "diffuse", "specular"... used in the shader
  9303. */
  9304. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9305. /**
  9306. * Binds a texture matrix value to its corrsponding uniform
  9307. * @param texture The texture to bind the matrix for
  9308. * @param uniformBuffer The uniform buffer receivin the data
  9309. * @param key The channel key "diffuse", "specular"... used in the shader
  9310. */
  9311. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9312. /**
  9313. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9314. * @param mesh defines the current mesh
  9315. * @param scene defines the current scene
  9316. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9317. * @param pointsCloud defines if point cloud rendering has to be turned on
  9318. * @param fogEnabled defines if fog has to be turned on
  9319. * @param alphaTest defines if alpha testing has to be turned on
  9320. * @param defines defines the current list of defines
  9321. */
  9322. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9323. /**
  9324. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9325. * @param scene defines the current scene
  9326. * @param engine defines the current engine
  9327. * @param defines specifies the list of active defines
  9328. * @param useInstances defines if instances have to be turned on
  9329. * @param useClipPlane defines if clip plane have to be turned on
  9330. */
  9331. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9332. /**
  9333. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9334. * @param mesh The mesh containing the geometry data we will draw
  9335. * @param defines The defines to update
  9336. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9337. * @param useBones Precise whether bones should be used or not (override mesh info)
  9338. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9339. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9340. * @returns false if defines are considered not dirty and have not been checked
  9341. */
  9342. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9343. /**
  9344. * Prepares the defines related to multiview
  9345. * @param scene The scene we are intending to draw
  9346. * @param defines The defines to update
  9347. */
  9348. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9349. /**
  9350. * Prepares the defines related to the light information passed in parameter
  9351. * @param scene The scene we are intending to draw
  9352. * @param mesh The mesh the effect is compiling for
  9353. * @param defines The defines to update
  9354. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9355. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9356. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9357. * @returns true if normals will be required for the rest of the effect
  9358. */
  9359. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9360. /**
  9361. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9362. * that won t be acctive due to defines being turned off.
  9363. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9364. * @param samplersList The samplers list
  9365. * @param defines The defines helping in the list generation
  9366. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9367. */
  9368. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9369. /**
  9370. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9371. * @param defines The defines to update while falling back
  9372. * @param fallbacks The authorized effect fallbacks
  9373. * @param maxSimultaneousLights The maximum number of lights allowed
  9374. * @param rank the current rank of the Effect
  9375. * @returns The newly affected rank
  9376. */
  9377. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9378. /**
  9379. * Prepares the list of attributes required for morph targets according to the effect defines.
  9380. * @param attribs The current list of supported attribs
  9381. * @param mesh The mesh to prepare the morph targets attributes for
  9382. * @param defines The current Defines of the effect
  9383. */
  9384. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9385. /**
  9386. * Prepares the list of attributes required for bones according to the effect defines.
  9387. * @param attribs The current list of supported attribs
  9388. * @param mesh The mesh to prepare the bones attributes for
  9389. * @param defines The current Defines of the effect
  9390. * @param fallbacks The current efffect fallback strategy
  9391. */
  9392. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9393. /**
  9394. * Prepares the list of attributes required for instances according to the effect defines.
  9395. * @param attribs The current list of supported attribs
  9396. * @param defines The current Defines of the effect
  9397. */
  9398. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9399. /**
  9400. * Binds the light shadow information to the effect for the given mesh.
  9401. * @param light The light containing the generator
  9402. * @param scene The scene the lights belongs to
  9403. * @param mesh The mesh we are binding the information to render
  9404. * @param lightIndex The light index in the effect used to render the mesh
  9405. * @param effect The effect we are binding the data to
  9406. */
  9407. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9408. /**
  9409. * Binds the light information to the effect.
  9410. * @param light The light containing the generator
  9411. * @param effect The effect we are binding the data to
  9412. * @param lightIndex The light index in the effect used to render
  9413. */
  9414. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9415. /**
  9416. * Binds the lights information from the scene to the effect for the given mesh.
  9417. * @param scene The scene the lights belongs to
  9418. * @param mesh The mesh we are binding the information to render
  9419. * @param effect The effect we are binding the data to
  9420. * @param defines The generated defines for the effect
  9421. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9422. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9423. */
  9424. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9425. private static _tempFogColor;
  9426. /**
  9427. * Binds the fog information from the scene to the effect for the given mesh.
  9428. * @param scene The scene the lights belongs to
  9429. * @param mesh The mesh we are binding the information to render
  9430. * @param effect The effect we are binding the data to
  9431. * @param linearSpace Defines if the fog effect is applied in linear space
  9432. */
  9433. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9434. /**
  9435. * Binds the bones information from the mesh to the effect.
  9436. * @param mesh The mesh we are binding the information to render
  9437. * @param effect The effect we are binding the data to
  9438. */
  9439. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9440. /**
  9441. * Binds the morph targets information from the mesh to the effect.
  9442. * @param abstractMesh The mesh we are binding the information to render
  9443. * @param effect The effect we are binding the data to
  9444. */
  9445. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9446. /**
  9447. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9448. * @param defines The generated defines used in the effect
  9449. * @param effect The effect we are binding the data to
  9450. * @param scene The scene we are willing to render with logarithmic scale for
  9451. */
  9452. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9453. /**
  9454. * Binds the clip plane information from the scene to the effect.
  9455. * @param scene The scene the clip plane information are extracted from
  9456. * @param effect The effect we are binding the data to
  9457. */
  9458. static BindClipPlane(effect: Effect, scene: Scene): void;
  9459. }
  9460. }
  9461. declare module BABYLON {
  9462. /** @hidden */
  9463. export var kernelBlurVaryingDeclaration: {
  9464. name: string;
  9465. shader: string;
  9466. };
  9467. }
  9468. declare module BABYLON {
  9469. /** @hidden */
  9470. export var kernelBlurFragment: {
  9471. name: string;
  9472. shader: string;
  9473. };
  9474. }
  9475. declare module BABYLON {
  9476. /** @hidden */
  9477. export var kernelBlurFragment2: {
  9478. name: string;
  9479. shader: string;
  9480. };
  9481. }
  9482. declare module BABYLON {
  9483. /** @hidden */
  9484. export var kernelBlurPixelShader: {
  9485. name: string;
  9486. shader: string;
  9487. };
  9488. }
  9489. declare module BABYLON {
  9490. /** @hidden */
  9491. export var kernelBlurVertex: {
  9492. name: string;
  9493. shader: string;
  9494. };
  9495. }
  9496. declare module BABYLON {
  9497. /** @hidden */
  9498. export var kernelBlurVertexShader: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module BABYLON {
  9504. /**
  9505. * The Blur Post Process which blurs an image based on a kernel and direction.
  9506. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9507. */
  9508. export class BlurPostProcess extends PostProcess {
  9509. /** The direction in which to blur the image. */
  9510. direction: Vector2;
  9511. private blockCompilation;
  9512. protected _kernel: number;
  9513. protected _idealKernel: number;
  9514. protected _packedFloat: boolean;
  9515. private _staticDefines;
  9516. /**
  9517. * Sets the length in pixels of the blur sample region
  9518. */
  9519. /**
  9520. * Gets the length in pixels of the blur sample region
  9521. */
  9522. kernel: number;
  9523. /**
  9524. * Sets wether or not the blur needs to unpack/repack floats
  9525. */
  9526. /**
  9527. * Gets wether or not the blur is unpacking/repacking floats
  9528. */
  9529. packedFloat: boolean;
  9530. /**
  9531. * Creates a new instance BlurPostProcess
  9532. * @param name The name of the effect.
  9533. * @param direction The direction in which to blur the image.
  9534. * @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.
  9535. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9536. * @param camera The camera to apply the render pass to.
  9537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9538. * @param engine The engine which the post process will be applied. (default: current engine)
  9539. * @param reusable If the post process can be reused on the same frame. (default: false)
  9540. * @param textureType Type of textures used when performing the post process. (default: 0)
  9541. * @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)
  9542. */
  9543. constructor(name: string,
  9544. /** The direction in which to blur the image. */
  9545. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9546. /**
  9547. * Updates the effect with the current post process compile time values and recompiles the shader.
  9548. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9549. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9550. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9551. * @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
  9552. * @param onCompiled Called when the shader has been compiled.
  9553. * @param onError Called if there is an error when compiling a shader.
  9554. */
  9555. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9556. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9557. /**
  9558. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9559. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9560. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9561. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9562. * The gaps between physical kernels are compensated for in the weighting of the samples
  9563. * @param idealKernel Ideal blur kernel.
  9564. * @return Nearest best kernel.
  9565. */
  9566. protected _nearestBestKernel(idealKernel: number): number;
  9567. /**
  9568. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9569. * @param x The point on the Gaussian distribution to sample.
  9570. * @return the value of the Gaussian function at x.
  9571. */
  9572. protected _gaussianWeight(x: number): number;
  9573. /**
  9574. * Generates a string that can be used as a floating point number in GLSL.
  9575. * @param x Value to print.
  9576. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9577. * @return GLSL float string.
  9578. */
  9579. protected _glslFloat(x: number, decimalFigures?: number): string;
  9580. }
  9581. }
  9582. declare module BABYLON {
  9583. /** @hidden */
  9584. export var shadowMapPixelShader: {
  9585. name: string;
  9586. shader: string;
  9587. };
  9588. }
  9589. declare module BABYLON {
  9590. /** @hidden */
  9591. export var bonesDeclaration: {
  9592. name: string;
  9593. shader: string;
  9594. };
  9595. }
  9596. declare module BABYLON {
  9597. /** @hidden */
  9598. export var morphTargetsVertexGlobalDeclaration: {
  9599. name: string;
  9600. shader: string;
  9601. };
  9602. }
  9603. declare module BABYLON {
  9604. /** @hidden */
  9605. export var morphTargetsVertexDeclaration: {
  9606. name: string;
  9607. shader: string;
  9608. };
  9609. }
  9610. declare module BABYLON {
  9611. /** @hidden */
  9612. export var instancesDeclaration: {
  9613. name: string;
  9614. shader: string;
  9615. };
  9616. }
  9617. declare module BABYLON {
  9618. /** @hidden */
  9619. export var helperFunctions: {
  9620. name: string;
  9621. shader: string;
  9622. };
  9623. }
  9624. declare module BABYLON {
  9625. /** @hidden */
  9626. export var morphTargetsVertex: {
  9627. name: string;
  9628. shader: string;
  9629. };
  9630. }
  9631. declare module BABYLON {
  9632. /** @hidden */
  9633. export var instancesVertex: {
  9634. name: string;
  9635. shader: string;
  9636. };
  9637. }
  9638. declare module BABYLON {
  9639. /** @hidden */
  9640. export var bonesVertex: {
  9641. name: string;
  9642. shader: string;
  9643. };
  9644. }
  9645. declare module BABYLON {
  9646. /** @hidden */
  9647. export var shadowMapVertexShader: {
  9648. name: string;
  9649. shader: string;
  9650. };
  9651. }
  9652. declare module BABYLON {
  9653. /** @hidden */
  9654. export var depthBoxBlurPixelShader: {
  9655. name: string;
  9656. shader: string;
  9657. };
  9658. }
  9659. declare module BABYLON {
  9660. /**
  9661. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9662. */
  9663. export interface ICustomShaderOptions {
  9664. /**
  9665. * Gets or sets the custom shader name to use
  9666. */
  9667. shaderName: string;
  9668. /**
  9669. * The list of attribute names used in the shader
  9670. */
  9671. attributes?: string[];
  9672. /**
  9673. * The list of unifrom names used in the shader
  9674. */
  9675. uniforms?: string[];
  9676. /**
  9677. * The list of sampler names used in the shader
  9678. */
  9679. samplers?: string[];
  9680. /**
  9681. * The list of defines used in the shader
  9682. */
  9683. defines?: string[];
  9684. }
  9685. /**
  9686. * Interface to implement to create a shadow generator compatible with BJS.
  9687. */
  9688. export interface IShadowGenerator {
  9689. /**
  9690. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9691. * @returns The render target texture if present otherwise, null
  9692. */
  9693. getShadowMap(): Nullable<RenderTargetTexture>;
  9694. /**
  9695. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9696. * @returns The render target texture if the shadow map is present otherwise, null
  9697. */
  9698. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9699. /**
  9700. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9701. * @param subMesh The submesh we want to render in the shadow map
  9702. * @param useInstances Defines wether will draw in the map using instances
  9703. * @returns true if ready otherwise, false
  9704. */
  9705. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9706. /**
  9707. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9708. * @param defines Defines of the material we want to update
  9709. * @param lightIndex Index of the light in the enabled light list of the material
  9710. */
  9711. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9712. /**
  9713. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9714. * defined in the generator but impacting the effect).
  9715. * It implies the unifroms available on the materials are the standard BJS ones.
  9716. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9717. * @param effect The effect we are binfing the information for
  9718. */
  9719. bindShadowLight(lightIndex: string, effect: Effect): void;
  9720. /**
  9721. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9722. * (eq to shadow prjection matrix * light transform matrix)
  9723. * @returns The transform matrix used to create the shadow map
  9724. */
  9725. getTransformMatrix(): Matrix;
  9726. /**
  9727. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9728. * Cube and 2D textures for instance.
  9729. */
  9730. recreateShadowMap(): void;
  9731. /**
  9732. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9733. * @param onCompiled Callback triggered at the and of the effects compilation
  9734. * @param options Sets of optional options forcing the compilation with different modes
  9735. */
  9736. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9737. useInstances: boolean;
  9738. }>): void;
  9739. /**
  9740. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9741. * @param options Sets of optional options forcing the compilation with different modes
  9742. * @returns A promise that resolves when the compilation completes
  9743. */
  9744. forceCompilationAsync(options?: Partial<{
  9745. useInstances: boolean;
  9746. }>): Promise<void>;
  9747. /**
  9748. * Serializes the shadow generator setup to a json object.
  9749. * @returns The serialized JSON object
  9750. */
  9751. serialize(): any;
  9752. /**
  9753. * Disposes the Shadow map and related Textures and effects.
  9754. */
  9755. dispose(): void;
  9756. }
  9757. /**
  9758. * Default implementation IShadowGenerator.
  9759. * This is the main object responsible of generating shadows in the framework.
  9760. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9761. */
  9762. export class ShadowGenerator implements IShadowGenerator {
  9763. /**
  9764. * Shadow generator mode None: no filtering applied.
  9765. */
  9766. static readonly FILTER_NONE: number;
  9767. /**
  9768. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9769. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9770. */
  9771. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9772. /**
  9773. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9774. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9775. */
  9776. static readonly FILTER_POISSONSAMPLING: number;
  9777. /**
  9778. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9779. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9780. */
  9781. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9782. /**
  9783. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9784. * edge artifacts on steep falloff.
  9785. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9786. */
  9787. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9788. /**
  9789. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9790. * edge artifacts on steep falloff.
  9791. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9792. */
  9793. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9794. /**
  9795. * Shadow generator mode PCF: Percentage Closer Filtering
  9796. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9797. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9798. */
  9799. static readonly FILTER_PCF: number;
  9800. /**
  9801. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9802. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9803. * Contact Hardening
  9804. */
  9805. static readonly FILTER_PCSS: number;
  9806. /**
  9807. * Reserved for PCF and PCSS
  9808. * Highest Quality.
  9809. *
  9810. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9811. *
  9812. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9813. */
  9814. static readonly QUALITY_HIGH: number;
  9815. /**
  9816. * Reserved for PCF and PCSS
  9817. * Good tradeoff for quality/perf cross devices
  9818. *
  9819. * Execute PCF on a 3*3 kernel.
  9820. *
  9821. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9822. */
  9823. static readonly QUALITY_MEDIUM: number;
  9824. /**
  9825. * Reserved for PCF and PCSS
  9826. * The lowest quality but the fastest.
  9827. *
  9828. * Execute PCF on a 1*1 kernel.
  9829. *
  9830. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9831. */
  9832. static readonly QUALITY_LOW: number;
  9833. /** Gets or sets the custom shader name to use */
  9834. customShaderOptions: ICustomShaderOptions;
  9835. /**
  9836. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9837. */
  9838. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9839. /**
  9840. * Observable triggered before a mesh is rendered in the shadow map.
  9841. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9842. */
  9843. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9844. private _bias;
  9845. /**
  9846. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9847. */
  9848. /**
  9849. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9850. */
  9851. bias: number;
  9852. private _normalBias;
  9853. /**
  9854. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9855. */
  9856. /**
  9857. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9858. */
  9859. normalBias: number;
  9860. private _blurBoxOffset;
  9861. /**
  9862. * Gets the blur box offset: offset applied during the blur pass.
  9863. * Only useful if useKernelBlur = false
  9864. */
  9865. /**
  9866. * Sets the blur box offset: offset applied during the blur pass.
  9867. * Only useful if useKernelBlur = false
  9868. */
  9869. blurBoxOffset: number;
  9870. private _blurScale;
  9871. /**
  9872. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9873. * 2 means half of the size.
  9874. */
  9875. /**
  9876. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9877. * 2 means half of the size.
  9878. */
  9879. blurScale: number;
  9880. private _blurKernel;
  9881. /**
  9882. * Gets the blur kernel: kernel size of the blur pass.
  9883. * Only useful if useKernelBlur = true
  9884. */
  9885. /**
  9886. * Sets the blur kernel: kernel size of the blur pass.
  9887. * Only useful if useKernelBlur = true
  9888. */
  9889. blurKernel: number;
  9890. private _useKernelBlur;
  9891. /**
  9892. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9893. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9894. */
  9895. /**
  9896. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9897. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9898. */
  9899. useKernelBlur: boolean;
  9900. private _depthScale;
  9901. /**
  9902. * Gets the depth scale used in ESM mode.
  9903. */
  9904. /**
  9905. * Sets the depth scale used in ESM mode.
  9906. * This can override the scale stored on the light.
  9907. */
  9908. depthScale: number;
  9909. private _filter;
  9910. /**
  9911. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9912. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9913. */
  9914. /**
  9915. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9916. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9917. */
  9918. filter: number;
  9919. /**
  9920. * Gets if the current filter is set to Poisson Sampling.
  9921. */
  9922. /**
  9923. * Sets the current filter to Poisson Sampling.
  9924. */
  9925. usePoissonSampling: boolean;
  9926. /**
  9927. * Gets if the current filter is set to ESM.
  9928. */
  9929. /**
  9930. * Sets the current filter is to ESM.
  9931. */
  9932. useExponentialShadowMap: boolean;
  9933. /**
  9934. * Gets if the current filter is set to filtered ESM.
  9935. */
  9936. /**
  9937. * Gets if the current filter is set to filtered ESM.
  9938. */
  9939. useBlurExponentialShadowMap: boolean;
  9940. /**
  9941. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9942. * exponential to prevent steep falloff artifacts).
  9943. */
  9944. /**
  9945. * Sets the current filter to "close ESM" (using the inverse of the
  9946. * exponential to prevent steep falloff artifacts).
  9947. */
  9948. useCloseExponentialShadowMap: boolean;
  9949. /**
  9950. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9951. * exponential to prevent steep falloff artifacts).
  9952. */
  9953. /**
  9954. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9955. * exponential to prevent steep falloff artifacts).
  9956. */
  9957. useBlurCloseExponentialShadowMap: boolean;
  9958. /**
  9959. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9960. */
  9961. /**
  9962. * Sets the current filter to "PCF" (percentage closer filtering).
  9963. */
  9964. usePercentageCloserFiltering: boolean;
  9965. private _filteringQuality;
  9966. /**
  9967. * Gets the PCF or PCSS Quality.
  9968. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9969. */
  9970. /**
  9971. * Sets the PCF or PCSS Quality.
  9972. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9973. */
  9974. filteringQuality: number;
  9975. /**
  9976. * Gets if the current filter is set to "PCSS" (contact hardening).
  9977. */
  9978. /**
  9979. * Sets the current filter to "PCSS" (contact hardening).
  9980. */
  9981. useContactHardeningShadow: boolean;
  9982. private _contactHardeningLightSizeUVRatio;
  9983. /**
  9984. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9985. * Using a ratio helps keeping shape stability independently of the map size.
  9986. *
  9987. * It does not account for the light projection as it was having too much
  9988. * instability during the light setup or during light position changes.
  9989. *
  9990. * Only valid if useContactHardeningShadow is true.
  9991. */
  9992. /**
  9993. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9994. * Using a ratio helps keeping shape stability independently of the map size.
  9995. *
  9996. * It does not account for the light projection as it was having too much
  9997. * instability during the light setup or during light position changes.
  9998. *
  9999. * Only valid if useContactHardeningShadow is true.
  10000. */
  10001. contactHardeningLightSizeUVRatio: number;
  10002. private _darkness;
  10003. /**
  10004. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10005. * 0 means strongest and 1 would means no shadow.
  10006. * @returns the darkness.
  10007. */
  10008. getDarkness(): number;
  10009. /**
  10010. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10011. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10012. * @returns the shadow generator allowing fluent coding.
  10013. */
  10014. setDarkness(darkness: number): ShadowGenerator;
  10015. private _transparencyShadow;
  10016. /**
  10017. * Sets the ability to have transparent shadow (boolean).
  10018. * @param transparent True if transparent else False
  10019. * @returns the shadow generator allowing fluent coding
  10020. */
  10021. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10022. private _shadowMap;
  10023. private _shadowMap2;
  10024. /**
  10025. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10026. * @returns The render target texture if present otherwise, null
  10027. */
  10028. getShadowMap(): Nullable<RenderTargetTexture>;
  10029. /**
  10030. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10031. * @returns The render target texture if the shadow map is present otherwise, null
  10032. */
  10033. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10034. /**
  10035. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10036. * @param mesh Mesh to add
  10037. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10038. * @returns the Shadow Generator itself
  10039. */
  10040. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10041. /**
  10042. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10043. * @param mesh Mesh to remove
  10044. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10045. * @returns the Shadow Generator itself
  10046. */
  10047. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10048. /**
  10049. * Controls the extent to which the shadows fade out at the edge of the frustum
  10050. * Used only by directionals and spots
  10051. */
  10052. frustumEdgeFalloff: number;
  10053. private _light;
  10054. /**
  10055. * Returns the associated light object.
  10056. * @returns the light generating the shadow
  10057. */
  10058. getLight(): IShadowLight;
  10059. /**
  10060. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10061. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10062. * It might on the other hand introduce peter panning.
  10063. */
  10064. forceBackFacesOnly: boolean;
  10065. private _scene;
  10066. private _lightDirection;
  10067. private _effect;
  10068. private _viewMatrix;
  10069. private _projectionMatrix;
  10070. private _transformMatrix;
  10071. private _cachedPosition;
  10072. private _cachedDirection;
  10073. private _cachedDefines;
  10074. private _currentRenderID;
  10075. private _boxBlurPostprocess;
  10076. private _kernelBlurXPostprocess;
  10077. private _kernelBlurYPostprocess;
  10078. private _blurPostProcesses;
  10079. private _mapSize;
  10080. private _currentFaceIndex;
  10081. private _currentFaceIndexCache;
  10082. private _textureType;
  10083. private _defaultTextureMatrix;
  10084. /** @hidden */
  10085. static _SceneComponentInitialization: (scene: Scene) => void;
  10086. /**
  10087. * Creates a ShadowGenerator object.
  10088. * A ShadowGenerator is the required tool to use the shadows.
  10089. * Each light casting shadows needs to use its own ShadowGenerator.
  10090. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10091. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10092. * @param light The light object generating the shadows.
  10093. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  10094. */
  10095. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10096. private _initializeGenerator;
  10097. private _initializeShadowMap;
  10098. private _initializeBlurRTTAndPostProcesses;
  10099. private _renderForShadowMap;
  10100. private _renderSubMeshForShadowMap;
  10101. private _applyFilterValues;
  10102. /**
  10103. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10104. * @param onCompiled Callback triggered at the and of the effects compilation
  10105. * @param options Sets of optional options forcing the compilation with different modes
  10106. */
  10107. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10108. useInstances: boolean;
  10109. }>): void;
  10110. /**
  10111. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10112. * @param options Sets of optional options forcing the compilation with different modes
  10113. * @returns A promise that resolves when the compilation completes
  10114. */
  10115. forceCompilationAsync(options?: Partial<{
  10116. useInstances: boolean;
  10117. }>): Promise<void>;
  10118. /**
  10119. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10120. * @param subMesh The submesh we want to render in the shadow map
  10121. * @param useInstances Defines wether will draw in the map using instances
  10122. * @returns true if ready otherwise, false
  10123. */
  10124. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10125. /**
  10126. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10127. * @param defines Defines of the material we want to update
  10128. * @param lightIndex Index of the light in the enabled light list of the material
  10129. */
  10130. prepareDefines(defines: any, lightIndex: number): void;
  10131. /**
  10132. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10133. * defined in the generator but impacting the effect).
  10134. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10135. * @param effect The effect we are binfing the information for
  10136. */
  10137. bindShadowLight(lightIndex: string, effect: Effect): void;
  10138. /**
  10139. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10140. * (eq to shadow prjection matrix * light transform matrix)
  10141. * @returns The transform matrix used to create the shadow map
  10142. */
  10143. getTransformMatrix(): Matrix;
  10144. /**
  10145. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10146. * Cube and 2D textures for instance.
  10147. */
  10148. recreateShadowMap(): void;
  10149. private _disposeBlurPostProcesses;
  10150. private _disposeRTTandPostProcesses;
  10151. /**
  10152. * Disposes the ShadowGenerator.
  10153. * Returns nothing.
  10154. */
  10155. dispose(): void;
  10156. /**
  10157. * Serializes the shadow generator setup to a json object.
  10158. * @returns The serialized JSON object
  10159. */
  10160. serialize(): any;
  10161. /**
  10162. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10163. * @param parsedShadowGenerator The JSON object to parse
  10164. * @param scene The scene to create the shadow map for
  10165. * @returns The parsed shadow generator
  10166. */
  10167. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10168. }
  10169. }
  10170. declare module BABYLON {
  10171. /**
  10172. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10173. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10174. * 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.
  10175. */
  10176. export abstract class Light extends Node {
  10177. /**
  10178. * Falloff Default: light is falling off following the material specification:
  10179. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10180. */
  10181. static readonly FALLOFF_DEFAULT: number;
  10182. /**
  10183. * Falloff Physical: light is falling off following the inverse squared distance law.
  10184. */
  10185. static readonly FALLOFF_PHYSICAL: number;
  10186. /**
  10187. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10188. * to enhance interoperability with other engines.
  10189. */
  10190. static readonly FALLOFF_GLTF: number;
  10191. /**
  10192. * Falloff Standard: light is falling off like in the standard material
  10193. * to enhance interoperability with other materials.
  10194. */
  10195. static readonly FALLOFF_STANDARD: number;
  10196. /**
  10197. * If every light affecting the material is in this lightmapMode,
  10198. * material.lightmapTexture adds or multiplies
  10199. * (depends on material.useLightmapAsShadowmap)
  10200. * after every other light calculations.
  10201. */
  10202. static readonly LIGHTMAP_DEFAULT: number;
  10203. /**
  10204. * material.lightmapTexture as only diffuse lighting from this light
  10205. * adds only specular lighting from this light
  10206. * adds dynamic shadows
  10207. */
  10208. static readonly LIGHTMAP_SPECULAR: number;
  10209. /**
  10210. * material.lightmapTexture as only lighting
  10211. * no light calculation from this light
  10212. * only adds dynamic shadows from this light
  10213. */
  10214. static readonly LIGHTMAP_SHADOWSONLY: number;
  10215. /**
  10216. * Each light type uses the default quantity according to its type:
  10217. * point/spot lights use luminous intensity
  10218. * directional lights use illuminance
  10219. */
  10220. static readonly INTENSITYMODE_AUTOMATIC: number;
  10221. /**
  10222. * lumen (lm)
  10223. */
  10224. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10225. /**
  10226. * candela (lm/sr)
  10227. */
  10228. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10229. /**
  10230. * lux (lm/m^2)
  10231. */
  10232. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10233. /**
  10234. * nit (cd/m^2)
  10235. */
  10236. static readonly INTENSITYMODE_LUMINANCE: number;
  10237. /**
  10238. * Light type const id of the point light.
  10239. */
  10240. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10241. /**
  10242. * Light type const id of the directional light.
  10243. */
  10244. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10245. /**
  10246. * Light type const id of the spot light.
  10247. */
  10248. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10249. /**
  10250. * Light type const id of the hemispheric light.
  10251. */
  10252. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10253. /**
  10254. * Diffuse gives the basic color to an object.
  10255. */
  10256. diffuse: Color3;
  10257. /**
  10258. * Specular produces a highlight color on an object.
  10259. * Note: This is note affecting PBR materials.
  10260. */
  10261. specular: Color3;
  10262. /**
  10263. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10264. * falling off base on range or angle.
  10265. * This can be set to any values in Light.FALLOFF_x.
  10266. *
  10267. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10268. * other types of materials.
  10269. */
  10270. falloffType: number;
  10271. /**
  10272. * Strength of the light.
  10273. * Note: By default it is define in the framework own unit.
  10274. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10275. */
  10276. intensity: number;
  10277. private _range;
  10278. protected _inverseSquaredRange: number;
  10279. /**
  10280. * Defines how far from the source the light is impacting in scene units.
  10281. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10282. */
  10283. /**
  10284. * Defines how far from the source the light is impacting in scene units.
  10285. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10286. */
  10287. range: number;
  10288. /**
  10289. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10290. * of light.
  10291. */
  10292. private _photometricScale;
  10293. private _intensityMode;
  10294. /**
  10295. * Gets the photometric scale used to interpret the intensity.
  10296. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10297. */
  10298. /**
  10299. * Sets the photometric scale used to interpret the intensity.
  10300. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10301. */
  10302. intensityMode: number;
  10303. private _radius;
  10304. /**
  10305. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10306. */
  10307. /**
  10308. * sets the light radius used by PBR Materials to simulate soft area lights.
  10309. */
  10310. radius: number;
  10311. private _renderPriority;
  10312. /**
  10313. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10314. * exceeding the number allowed of the materials.
  10315. */
  10316. renderPriority: number;
  10317. private _shadowEnabled;
  10318. /**
  10319. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10320. * the current shadow generator.
  10321. */
  10322. /**
  10323. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10324. * the current shadow generator.
  10325. */
  10326. shadowEnabled: boolean;
  10327. private _includedOnlyMeshes;
  10328. /**
  10329. * Gets the only meshes impacted by this light.
  10330. */
  10331. /**
  10332. * Sets the only meshes impacted by this light.
  10333. */
  10334. includedOnlyMeshes: AbstractMesh[];
  10335. private _excludedMeshes;
  10336. /**
  10337. * Gets the meshes not impacted by this light.
  10338. */
  10339. /**
  10340. * Sets the meshes not impacted by this light.
  10341. */
  10342. excludedMeshes: AbstractMesh[];
  10343. private _excludeWithLayerMask;
  10344. /**
  10345. * Gets the layer id use to find what meshes are not impacted by the light.
  10346. * Inactive if 0
  10347. */
  10348. /**
  10349. * Sets the layer id use to find what meshes are not impacted by the light.
  10350. * Inactive if 0
  10351. */
  10352. excludeWithLayerMask: number;
  10353. private _includeOnlyWithLayerMask;
  10354. /**
  10355. * Gets the layer id use to find what meshes are impacted by the light.
  10356. * Inactive if 0
  10357. */
  10358. /**
  10359. * Sets the layer id use to find what meshes are impacted by the light.
  10360. * Inactive if 0
  10361. */
  10362. includeOnlyWithLayerMask: number;
  10363. private _lightmapMode;
  10364. /**
  10365. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10366. */
  10367. /**
  10368. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10369. */
  10370. lightmapMode: number;
  10371. /**
  10372. * Shadow generator associted to the light.
  10373. * @hidden Internal use only.
  10374. */
  10375. _shadowGenerator: Nullable<IShadowGenerator>;
  10376. /**
  10377. * @hidden Internal use only.
  10378. */
  10379. _excludedMeshesIds: string[];
  10380. /**
  10381. * @hidden Internal use only.
  10382. */
  10383. _includedOnlyMeshesIds: string[];
  10384. /**
  10385. * The current light unifom buffer.
  10386. * @hidden Internal use only.
  10387. */
  10388. _uniformBuffer: UniformBuffer;
  10389. /**
  10390. * Creates a Light object in the scene.
  10391. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10392. * @param name The firendly name of the light
  10393. * @param scene The scene the light belongs too
  10394. */
  10395. constructor(name: string, scene: Scene);
  10396. protected abstract _buildUniformLayout(): void;
  10397. /**
  10398. * Sets the passed Effect "effect" with the Light information.
  10399. * @param effect The effect to update
  10400. * @param lightIndex The index of the light in the effect to update
  10401. * @returns The light
  10402. */
  10403. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10404. /**
  10405. * Returns the string "Light".
  10406. * @returns the class name
  10407. */
  10408. getClassName(): string;
  10409. /** @hidden */
  10410. readonly _isLight: boolean;
  10411. /**
  10412. * Converts the light information to a readable string for debug purpose.
  10413. * @param fullDetails Supports for multiple levels of logging within scene loading
  10414. * @returns the human readable light info
  10415. */
  10416. toString(fullDetails?: boolean): string;
  10417. /** @hidden */
  10418. protected _syncParentEnabledState(): void;
  10419. /**
  10420. * Set the enabled state of this node.
  10421. * @param value - the new enabled state
  10422. */
  10423. setEnabled(value: boolean): void;
  10424. /**
  10425. * Returns the Light associated shadow generator if any.
  10426. * @return the associated shadow generator.
  10427. */
  10428. getShadowGenerator(): Nullable<IShadowGenerator>;
  10429. /**
  10430. * Returns a Vector3, the absolute light position in the World.
  10431. * @returns the world space position of the light
  10432. */
  10433. getAbsolutePosition(): Vector3;
  10434. /**
  10435. * Specifies if the light will affect the passed mesh.
  10436. * @param mesh The mesh to test against the light
  10437. * @return true the mesh is affected otherwise, false.
  10438. */
  10439. canAffectMesh(mesh: AbstractMesh): boolean;
  10440. /**
  10441. * Sort function to order lights for rendering.
  10442. * @param a First Light object to compare to second.
  10443. * @param b Second Light object to compare first.
  10444. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10445. */
  10446. static CompareLightsPriority(a: Light, b: Light): number;
  10447. /**
  10448. * Releases resources associated with this node.
  10449. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10450. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10451. */
  10452. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10453. /**
  10454. * Returns the light type ID (integer).
  10455. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10456. */
  10457. getTypeID(): number;
  10458. /**
  10459. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10460. * @returns the scaled intensity in intensity mode unit
  10461. */
  10462. getScaledIntensity(): number;
  10463. /**
  10464. * Returns a new Light object, named "name", from the current one.
  10465. * @param name The name of the cloned light
  10466. * @returns the new created light
  10467. */
  10468. clone(name: string): Nullable<Light>;
  10469. /**
  10470. * Serializes the current light into a Serialization object.
  10471. * @returns the serialized object.
  10472. */
  10473. serialize(): any;
  10474. /**
  10475. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10476. * This new light is named "name" and added to the passed scene.
  10477. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10478. * @param name The friendly name of the light
  10479. * @param scene The scene the new light will belong to
  10480. * @returns the constructor function
  10481. */
  10482. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10483. /**
  10484. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10485. * @param parsedLight The JSON representation of the light
  10486. * @param scene The scene to create the parsed light in
  10487. * @returns the created light after parsing
  10488. */
  10489. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10490. private _hookArrayForExcluded;
  10491. private _hookArrayForIncludedOnly;
  10492. private _resyncMeshes;
  10493. /**
  10494. * Forces the meshes to update their light related information in their rendering used effects
  10495. * @hidden Internal Use Only
  10496. */
  10497. _markMeshesAsLightDirty(): void;
  10498. /**
  10499. * Recomputes the cached photometric scale if needed.
  10500. */
  10501. private _computePhotometricScale;
  10502. /**
  10503. * Returns the Photometric Scale according to the light type and intensity mode.
  10504. */
  10505. private _getPhotometricScale;
  10506. /**
  10507. * Reorder the light in the scene according to their defined priority.
  10508. * @hidden Internal Use Only
  10509. */
  10510. _reorderLightsInScene(): void;
  10511. /**
  10512. * Prepares the list of defines specific to the light type.
  10513. * @param defines the list of defines
  10514. * @param lightIndex defines the index of the light for the effect
  10515. */
  10516. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10517. }
  10518. }
  10519. declare module BABYLON {
  10520. /**
  10521. * Interface used to define Action
  10522. */
  10523. export interface IAction {
  10524. /**
  10525. * Trigger for the action
  10526. */
  10527. trigger: number;
  10528. /** Options of the trigger */
  10529. triggerOptions: any;
  10530. /**
  10531. * Gets the trigger parameters
  10532. * @returns the trigger parameters
  10533. */
  10534. getTriggerParameter(): any;
  10535. /**
  10536. * Internal only - executes current action event
  10537. * @hidden
  10538. */
  10539. _executeCurrent(evt?: ActionEvent): void;
  10540. /**
  10541. * Serialize placeholder for child classes
  10542. * @param parent of child
  10543. * @returns the serialized object
  10544. */
  10545. serialize(parent: any): any;
  10546. /**
  10547. * Internal only
  10548. * @hidden
  10549. */
  10550. _prepare(): void;
  10551. /**
  10552. * Internal only - manager for action
  10553. * @hidden
  10554. */
  10555. _actionManager: AbstractActionManager;
  10556. }
  10557. /**
  10558. * The action to be carried out following a trigger
  10559. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10560. */
  10561. export class Action implements IAction {
  10562. /** the trigger, with or without parameters, for the action */
  10563. triggerOptions: any;
  10564. /**
  10565. * Trigger for the action
  10566. */
  10567. trigger: number;
  10568. /**
  10569. * Internal only - manager for action
  10570. * @hidden
  10571. */
  10572. _actionManager: ActionManager;
  10573. private _nextActiveAction;
  10574. private _child;
  10575. private _condition?;
  10576. private _triggerParameter;
  10577. /**
  10578. * An event triggered prior to action being executed.
  10579. */
  10580. onBeforeExecuteObservable: Observable<Action>;
  10581. /**
  10582. * Creates a new Action
  10583. * @param triggerOptions the trigger, with or without parameters, for the action
  10584. * @param condition an optional determinant of action
  10585. */
  10586. constructor(
  10587. /** the trigger, with or without parameters, for the action */
  10588. triggerOptions: any, condition?: Condition);
  10589. /**
  10590. * Internal only
  10591. * @hidden
  10592. */
  10593. _prepare(): void;
  10594. /**
  10595. * Gets the trigger parameters
  10596. * @returns the trigger parameters
  10597. */
  10598. getTriggerParameter(): any;
  10599. /**
  10600. * Internal only - executes current action event
  10601. * @hidden
  10602. */
  10603. _executeCurrent(evt?: ActionEvent): void;
  10604. /**
  10605. * Execute placeholder for child classes
  10606. * @param evt optional action event
  10607. */
  10608. execute(evt?: ActionEvent): void;
  10609. /**
  10610. * Skips to next active action
  10611. */
  10612. skipToNextActiveAction(): void;
  10613. /**
  10614. * Adds action to chain of actions, may be a DoNothingAction
  10615. * @param action defines the next action to execute
  10616. * @returns The action passed in
  10617. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10618. */
  10619. then(action: Action): Action;
  10620. /**
  10621. * Internal only
  10622. * @hidden
  10623. */
  10624. _getProperty(propertyPath: string): string;
  10625. /**
  10626. * Internal only
  10627. * @hidden
  10628. */
  10629. _getEffectiveTarget(target: any, propertyPath: string): any;
  10630. /**
  10631. * Serialize placeholder for child classes
  10632. * @param parent of child
  10633. * @returns the serialized object
  10634. */
  10635. serialize(parent: any): any;
  10636. /**
  10637. * Internal only called by serialize
  10638. * @hidden
  10639. */
  10640. protected _serialize(serializedAction: any, parent?: any): any;
  10641. /**
  10642. * Internal only
  10643. * @hidden
  10644. */
  10645. static _SerializeValueAsString: (value: any) => string;
  10646. /**
  10647. * Internal only
  10648. * @hidden
  10649. */
  10650. static _GetTargetProperty: (target: Scene | Node) => {
  10651. name: string;
  10652. targetType: string;
  10653. value: string;
  10654. };
  10655. }
  10656. }
  10657. declare module BABYLON {
  10658. /**
  10659. * A Condition applied to an Action
  10660. */
  10661. export class Condition {
  10662. /**
  10663. * Internal only - manager for action
  10664. * @hidden
  10665. */
  10666. _actionManager: ActionManager;
  10667. /**
  10668. * Internal only
  10669. * @hidden
  10670. */
  10671. _evaluationId: number;
  10672. /**
  10673. * Internal only
  10674. * @hidden
  10675. */
  10676. _currentResult: boolean;
  10677. /**
  10678. * Creates a new Condition
  10679. * @param actionManager the manager of the action the condition is applied to
  10680. */
  10681. constructor(actionManager: ActionManager);
  10682. /**
  10683. * Check if the current condition is valid
  10684. * @returns a boolean
  10685. */
  10686. isValid(): boolean;
  10687. /**
  10688. * Internal only
  10689. * @hidden
  10690. */
  10691. _getProperty(propertyPath: string): string;
  10692. /**
  10693. * Internal only
  10694. * @hidden
  10695. */
  10696. _getEffectiveTarget(target: any, propertyPath: string): any;
  10697. /**
  10698. * Serialize placeholder for child classes
  10699. * @returns the serialized object
  10700. */
  10701. serialize(): any;
  10702. /**
  10703. * Internal only
  10704. * @hidden
  10705. */
  10706. protected _serialize(serializedCondition: any): any;
  10707. }
  10708. /**
  10709. * Defines specific conditional operators as extensions of Condition
  10710. */
  10711. export class ValueCondition extends Condition {
  10712. /** path to specify the property of the target the conditional operator uses */
  10713. propertyPath: string;
  10714. /** the value compared by the conditional operator against the current value of the property */
  10715. value: any;
  10716. /** the conditional operator, default ValueCondition.IsEqual */
  10717. operator: number;
  10718. /**
  10719. * Internal only
  10720. * @hidden
  10721. */
  10722. private static _IsEqual;
  10723. /**
  10724. * Internal only
  10725. * @hidden
  10726. */
  10727. private static _IsDifferent;
  10728. /**
  10729. * Internal only
  10730. * @hidden
  10731. */
  10732. private static _IsGreater;
  10733. /**
  10734. * Internal only
  10735. * @hidden
  10736. */
  10737. private static _IsLesser;
  10738. /**
  10739. * returns the number for IsEqual
  10740. */
  10741. static readonly IsEqual: number;
  10742. /**
  10743. * Returns the number for IsDifferent
  10744. */
  10745. static readonly IsDifferent: number;
  10746. /**
  10747. * Returns the number for IsGreater
  10748. */
  10749. static readonly IsGreater: number;
  10750. /**
  10751. * Returns the number for IsLesser
  10752. */
  10753. static readonly IsLesser: number;
  10754. /**
  10755. * Internal only The action manager for the condition
  10756. * @hidden
  10757. */
  10758. _actionManager: ActionManager;
  10759. /**
  10760. * Internal only
  10761. * @hidden
  10762. */
  10763. private _target;
  10764. /**
  10765. * Internal only
  10766. * @hidden
  10767. */
  10768. private _effectiveTarget;
  10769. /**
  10770. * Internal only
  10771. * @hidden
  10772. */
  10773. private _property;
  10774. /**
  10775. * Creates a new ValueCondition
  10776. * @param actionManager manager for the action the condition applies to
  10777. * @param target for the action
  10778. * @param propertyPath path to specify the property of the target the conditional operator uses
  10779. * @param value the value compared by the conditional operator against the current value of the property
  10780. * @param operator the conditional operator, default ValueCondition.IsEqual
  10781. */
  10782. constructor(actionManager: ActionManager, target: any,
  10783. /** path to specify the property of the target the conditional operator uses */
  10784. propertyPath: string,
  10785. /** the value compared by the conditional operator against the current value of the property */
  10786. value: any,
  10787. /** the conditional operator, default ValueCondition.IsEqual */
  10788. operator?: number);
  10789. /**
  10790. * Compares the given value with the property value for the specified conditional operator
  10791. * @returns the result of the comparison
  10792. */
  10793. isValid(): boolean;
  10794. /**
  10795. * Serialize the ValueCondition into a JSON compatible object
  10796. * @returns serialization object
  10797. */
  10798. serialize(): any;
  10799. /**
  10800. * Gets the name of the conditional operator for the ValueCondition
  10801. * @param operator the conditional operator
  10802. * @returns the name
  10803. */
  10804. static GetOperatorName(operator: number): string;
  10805. }
  10806. /**
  10807. * Defines a predicate condition as an extension of Condition
  10808. */
  10809. export class PredicateCondition extends Condition {
  10810. /** defines the predicate function used to validate the condition */
  10811. predicate: () => boolean;
  10812. /**
  10813. * Internal only - manager for action
  10814. * @hidden
  10815. */
  10816. _actionManager: ActionManager;
  10817. /**
  10818. * Creates a new PredicateCondition
  10819. * @param actionManager manager for the action the condition applies to
  10820. * @param predicate defines the predicate function used to validate the condition
  10821. */
  10822. constructor(actionManager: ActionManager,
  10823. /** defines the predicate function used to validate the condition */
  10824. predicate: () => boolean);
  10825. /**
  10826. * @returns the validity of the predicate condition
  10827. */
  10828. isValid(): boolean;
  10829. }
  10830. /**
  10831. * Defines a state condition as an extension of Condition
  10832. */
  10833. export class StateCondition extends Condition {
  10834. /** Value to compare with target state */
  10835. value: string;
  10836. /**
  10837. * Internal only - manager for action
  10838. * @hidden
  10839. */
  10840. _actionManager: ActionManager;
  10841. /**
  10842. * Internal only
  10843. * @hidden
  10844. */
  10845. private _target;
  10846. /**
  10847. * Creates a new StateCondition
  10848. * @param actionManager manager for the action the condition applies to
  10849. * @param target of the condition
  10850. * @param value to compare with target state
  10851. */
  10852. constructor(actionManager: ActionManager, target: any,
  10853. /** Value to compare with target state */
  10854. value: string);
  10855. /**
  10856. * Gets a boolean indicating if the current condition is met
  10857. * @returns the validity of the state
  10858. */
  10859. isValid(): boolean;
  10860. /**
  10861. * Serialize the StateCondition into a JSON compatible object
  10862. * @returns serialization object
  10863. */
  10864. serialize(): any;
  10865. }
  10866. }
  10867. declare module BABYLON {
  10868. /**
  10869. * This defines an action responsible to toggle a boolean once triggered.
  10870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10871. */
  10872. export class SwitchBooleanAction extends Action {
  10873. /**
  10874. * The path to the boolean property in the target object
  10875. */
  10876. propertyPath: string;
  10877. private _target;
  10878. private _effectiveTarget;
  10879. private _property;
  10880. /**
  10881. * Instantiate the action
  10882. * @param triggerOptions defines the trigger options
  10883. * @param target defines the object containing the boolean
  10884. * @param propertyPath defines the path to the boolean property in the target object
  10885. * @param condition defines the trigger related conditions
  10886. */
  10887. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10888. /** @hidden */
  10889. _prepare(): void;
  10890. /**
  10891. * Execute the action toggle the boolean value.
  10892. */
  10893. execute(): void;
  10894. /**
  10895. * Serializes the actions and its related information.
  10896. * @param parent defines the object to serialize in
  10897. * @returns the serialized object
  10898. */
  10899. serialize(parent: any): any;
  10900. }
  10901. /**
  10902. * This defines an action responsible to set a the state field of the target
  10903. * to a desired value once triggered.
  10904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10905. */
  10906. export class SetStateAction extends Action {
  10907. /**
  10908. * The value to store in the state field.
  10909. */
  10910. value: string;
  10911. private _target;
  10912. /**
  10913. * Instantiate the action
  10914. * @param triggerOptions defines the trigger options
  10915. * @param target defines the object containing the state property
  10916. * @param value defines the value to store in the state field
  10917. * @param condition defines the trigger related conditions
  10918. */
  10919. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10920. /**
  10921. * Execute the action and store the value on the target state property.
  10922. */
  10923. execute(): void;
  10924. /**
  10925. * Serializes the actions and its related information.
  10926. * @param parent defines the object to serialize in
  10927. * @returns the serialized object
  10928. */
  10929. serialize(parent: any): any;
  10930. }
  10931. /**
  10932. * This defines an action responsible to set a property of the target
  10933. * to a desired value once triggered.
  10934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10935. */
  10936. export class SetValueAction extends Action {
  10937. /**
  10938. * The path of the property to set in the target.
  10939. */
  10940. propertyPath: string;
  10941. /**
  10942. * The value to set in the property
  10943. */
  10944. value: any;
  10945. private _target;
  10946. private _effectiveTarget;
  10947. private _property;
  10948. /**
  10949. * Instantiate the action
  10950. * @param triggerOptions defines the trigger options
  10951. * @param target defines the object containing the property
  10952. * @param propertyPath defines the path of the property to set in the target
  10953. * @param value defines the value to set in the property
  10954. * @param condition defines the trigger related conditions
  10955. */
  10956. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10957. /** @hidden */
  10958. _prepare(): void;
  10959. /**
  10960. * Execute the action and set the targetted property to the desired value.
  10961. */
  10962. execute(): void;
  10963. /**
  10964. * Serializes the actions and its related information.
  10965. * @param parent defines the object to serialize in
  10966. * @returns the serialized object
  10967. */
  10968. serialize(parent: any): any;
  10969. }
  10970. /**
  10971. * This defines an action responsible to increment the target value
  10972. * to a desired value once triggered.
  10973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10974. */
  10975. export class IncrementValueAction extends Action {
  10976. /**
  10977. * The path of the property to increment in the target.
  10978. */
  10979. propertyPath: string;
  10980. /**
  10981. * The value we should increment the property by.
  10982. */
  10983. value: any;
  10984. private _target;
  10985. private _effectiveTarget;
  10986. private _property;
  10987. /**
  10988. * Instantiate the action
  10989. * @param triggerOptions defines the trigger options
  10990. * @param target defines the object containing the property
  10991. * @param propertyPath defines the path of the property to increment in the target
  10992. * @param value defines the value value we should increment the property by
  10993. * @param condition defines the trigger related conditions
  10994. */
  10995. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10996. /** @hidden */
  10997. _prepare(): void;
  10998. /**
  10999. * Execute the action and increment the target of the value amount.
  11000. */
  11001. execute(): void;
  11002. /**
  11003. * Serializes the actions and its related information.
  11004. * @param parent defines the object to serialize in
  11005. * @returns the serialized object
  11006. */
  11007. serialize(parent: any): any;
  11008. }
  11009. /**
  11010. * This defines an action responsible to start an animation once triggered.
  11011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11012. */
  11013. export class PlayAnimationAction extends Action {
  11014. /**
  11015. * Where the animation should start (animation frame)
  11016. */
  11017. from: number;
  11018. /**
  11019. * Where the animation should stop (animation frame)
  11020. */
  11021. to: number;
  11022. /**
  11023. * Define if the animation should loop or stop after the first play.
  11024. */
  11025. loop?: boolean;
  11026. private _target;
  11027. /**
  11028. * Instantiate the action
  11029. * @param triggerOptions defines the trigger options
  11030. * @param target defines the target animation or animation name
  11031. * @param from defines from where the animation should start (animation frame)
  11032. * @param end defines where the animation should stop (animation frame)
  11033. * @param loop defines if the animation should loop or stop after the first play
  11034. * @param condition defines the trigger related conditions
  11035. */
  11036. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11037. /** @hidden */
  11038. _prepare(): void;
  11039. /**
  11040. * Execute the action and play the animation.
  11041. */
  11042. execute(): void;
  11043. /**
  11044. * Serializes the actions and its related information.
  11045. * @param parent defines the object to serialize in
  11046. * @returns the serialized object
  11047. */
  11048. serialize(parent: any): any;
  11049. }
  11050. /**
  11051. * This defines an action responsible to stop an animation once triggered.
  11052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11053. */
  11054. export class StopAnimationAction extends Action {
  11055. private _target;
  11056. /**
  11057. * Instantiate the action
  11058. * @param triggerOptions defines the trigger options
  11059. * @param target defines the target animation or animation name
  11060. * @param condition defines the trigger related conditions
  11061. */
  11062. constructor(triggerOptions: any, target: any, condition?: Condition);
  11063. /** @hidden */
  11064. _prepare(): void;
  11065. /**
  11066. * Execute the action and stop the animation.
  11067. */
  11068. execute(): void;
  11069. /**
  11070. * Serializes the actions and its related information.
  11071. * @param parent defines the object to serialize in
  11072. * @returns the serialized object
  11073. */
  11074. serialize(parent: any): any;
  11075. }
  11076. /**
  11077. * This defines an action responsible that does nothing once triggered.
  11078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11079. */
  11080. export class DoNothingAction extends Action {
  11081. /**
  11082. * Instantiate the action
  11083. * @param triggerOptions defines the trigger options
  11084. * @param condition defines the trigger related conditions
  11085. */
  11086. constructor(triggerOptions?: any, condition?: Condition);
  11087. /**
  11088. * Execute the action and do nothing.
  11089. */
  11090. execute(): void;
  11091. /**
  11092. * Serializes the actions and its related information.
  11093. * @param parent defines the object to serialize in
  11094. * @returns the serialized object
  11095. */
  11096. serialize(parent: any): any;
  11097. }
  11098. /**
  11099. * This defines an action responsible to trigger several actions once triggered.
  11100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11101. */
  11102. export class CombineAction extends Action {
  11103. /**
  11104. * The list of aggregated animations to run.
  11105. */
  11106. children: Action[];
  11107. /**
  11108. * Instantiate the action
  11109. * @param triggerOptions defines the trigger options
  11110. * @param children defines the list of aggregated animations to run
  11111. * @param condition defines the trigger related conditions
  11112. */
  11113. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11114. /** @hidden */
  11115. _prepare(): void;
  11116. /**
  11117. * Execute the action and executes all the aggregated actions.
  11118. */
  11119. execute(evt: ActionEvent): void;
  11120. /**
  11121. * Serializes the actions and its related information.
  11122. * @param parent defines the object to serialize in
  11123. * @returns the serialized object
  11124. */
  11125. serialize(parent: any): any;
  11126. }
  11127. /**
  11128. * This defines an action responsible to run code (external event) once triggered.
  11129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11130. */
  11131. export class ExecuteCodeAction extends Action {
  11132. /**
  11133. * The callback function to run.
  11134. */
  11135. func: (evt: ActionEvent) => void;
  11136. /**
  11137. * Instantiate the action
  11138. * @param triggerOptions defines the trigger options
  11139. * @param func defines the callback function to run
  11140. * @param condition defines the trigger related conditions
  11141. */
  11142. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11143. /**
  11144. * Execute the action and run the attached code.
  11145. */
  11146. execute(evt: ActionEvent): void;
  11147. }
  11148. /**
  11149. * This defines an action responsible to set the parent property of the target once triggered.
  11150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11151. */
  11152. export class SetParentAction extends Action {
  11153. private _parent;
  11154. private _target;
  11155. /**
  11156. * Instantiate the action
  11157. * @param triggerOptions defines the trigger options
  11158. * @param target defines the target containing the parent property
  11159. * @param parent defines from where the animation should start (animation frame)
  11160. * @param condition defines the trigger related conditions
  11161. */
  11162. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11163. /** @hidden */
  11164. _prepare(): void;
  11165. /**
  11166. * Execute the action and set the parent property.
  11167. */
  11168. execute(): void;
  11169. /**
  11170. * Serializes the actions and its related information.
  11171. * @param parent defines the object to serialize in
  11172. * @returns the serialized object
  11173. */
  11174. serialize(parent: any): any;
  11175. }
  11176. }
  11177. declare module BABYLON {
  11178. /**
  11179. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11180. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11182. */
  11183. export class ActionManager extends AbstractActionManager {
  11184. /**
  11185. * Nothing
  11186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11187. */
  11188. static readonly NothingTrigger: number;
  11189. /**
  11190. * On pick
  11191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11192. */
  11193. static readonly OnPickTrigger: number;
  11194. /**
  11195. * On left pick
  11196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11197. */
  11198. static readonly OnLeftPickTrigger: number;
  11199. /**
  11200. * On right pick
  11201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11202. */
  11203. static readonly OnRightPickTrigger: number;
  11204. /**
  11205. * On center pick
  11206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11207. */
  11208. static readonly OnCenterPickTrigger: number;
  11209. /**
  11210. * On pick down
  11211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11212. */
  11213. static readonly OnPickDownTrigger: number;
  11214. /**
  11215. * On double pick
  11216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11217. */
  11218. static readonly OnDoublePickTrigger: number;
  11219. /**
  11220. * On pick up
  11221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11222. */
  11223. static readonly OnPickUpTrigger: number;
  11224. /**
  11225. * On pick out.
  11226. * This trigger will only be raised if you also declared a OnPickDown
  11227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11228. */
  11229. static readonly OnPickOutTrigger: number;
  11230. /**
  11231. * On long press
  11232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11233. */
  11234. static readonly OnLongPressTrigger: number;
  11235. /**
  11236. * On pointer over
  11237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11238. */
  11239. static readonly OnPointerOverTrigger: number;
  11240. /**
  11241. * On pointer out
  11242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11243. */
  11244. static readonly OnPointerOutTrigger: number;
  11245. /**
  11246. * On every frame
  11247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11248. */
  11249. static readonly OnEveryFrameTrigger: number;
  11250. /**
  11251. * On intersection enter
  11252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11253. */
  11254. static readonly OnIntersectionEnterTrigger: number;
  11255. /**
  11256. * On intersection exit
  11257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11258. */
  11259. static readonly OnIntersectionExitTrigger: number;
  11260. /**
  11261. * On key down
  11262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11263. */
  11264. static readonly OnKeyDownTrigger: number;
  11265. /**
  11266. * On key up
  11267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11268. */
  11269. static readonly OnKeyUpTrigger: number;
  11270. private _scene;
  11271. /**
  11272. * Creates a new action manager
  11273. * @param scene defines the hosting scene
  11274. */
  11275. constructor(scene: Scene);
  11276. /**
  11277. * Releases all associated resources
  11278. */
  11279. dispose(): void;
  11280. /**
  11281. * Gets hosting scene
  11282. * @returns the hosting scene
  11283. */
  11284. getScene(): Scene;
  11285. /**
  11286. * Does this action manager handles actions of any of the given triggers
  11287. * @param triggers defines the triggers to be tested
  11288. * @return a boolean indicating whether one (or more) of the triggers is handled
  11289. */
  11290. hasSpecificTriggers(triggers: number[]): boolean;
  11291. /**
  11292. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11293. * speed.
  11294. * @param triggerA defines the trigger to be tested
  11295. * @param triggerB defines the trigger to be tested
  11296. * @return a boolean indicating whether one (or more) of the triggers is handled
  11297. */
  11298. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11299. /**
  11300. * Does this action manager handles actions of a given trigger
  11301. * @param trigger defines the trigger to be tested
  11302. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11303. * @return whether the trigger is handled
  11304. */
  11305. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11306. /**
  11307. * Does this action manager has pointer triggers
  11308. */
  11309. readonly hasPointerTriggers: boolean;
  11310. /**
  11311. * Does this action manager has pick triggers
  11312. */
  11313. readonly hasPickTriggers: boolean;
  11314. /**
  11315. * Registers an action to this action manager
  11316. * @param action defines the action to be registered
  11317. * @return the action amended (prepared) after registration
  11318. */
  11319. registerAction(action: IAction): Nullable<IAction>;
  11320. /**
  11321. * Unregisters an action to this action manager
  11322. * @param action defines the action to be unregistered
  11323. * @return a boolean indicating whether the action has been unregistered
  11324. */
  11325. unregisterAction(action: IAction): Boolean;
  11326. /**
  11327. * Process a specific trigger
  11328. * @param trigger defines the trigger to process
  11329. * @param evt defines the event details to be processed
  11330. */
  11331. processTrigger(trigger: number, evt?: IActionEvent): void;
  11332. /** @hidden */
  11333. _getEffectiveTarget(target: any, propertyPath: string): any;
  11334. /** @hidden */
  11335. _getProperty(propertyPath: string): string;
  11336. /**
  11337. * Serialize this manager to a JSON object
  11338. * @param name defines the property name to store this manager
  11339. * @returns a JSON representation of this manager
  11340. */
  11341. serialize(name: string): any;
  11342. /**
  11343. * Creates a new ActionManager from a JSON data
  11344. * @param parsedActions defines the JSON data to read from
  11345. * @param object defines the hosting mesh
  11346. * @param scene defines the hosting scene
  11347. */
  11348. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11349. /**
  11350. * Get a trigger name by index
  11351. * @param trigger defines the trigger index
  11352. * @returns a trigger name
  11353. */
  11354. static GetTriggerName(trigger: number): string;
  11355. }
  11356. }
  11357. declare module BABYLON {
  11358. /**
  11359. * Class representing a ray with position and direction
  11360. */
  11361. export class Ray {
  11362. /** origin point */
  11363. origin: Vector3;
  11364. /** direction */
  11365. direction: Vector3;
  11366. /** length of the ray */
  11367. length: number;
  11368. private static readonly TmpVector3;
  11369. private _tmpRay;
  11370. /**
  11371. * Creates a new ray
  11372. * @param origin origin point
  11373. * @param direction direction
  11374. * @param length length of the ray
  11375. */
  11376. constructor(
  11377. /** origin point */
  11378. origin: Vector3,
  11379. /** direction */
  11380. direction: Vector3,
  11381. /** length of the ray */
  11382. length?: number);
  11383. /**
  11384. * Checks if the ray intersects a box
  11385. * @param minimum bound of the box
  11386. * @param maximum bound of the box
  11387. * @param intersectionTreshold extra extend to be added to the box in all direction
  11388. * @returns if the box was hit
  11389. */
  11390. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11391. /**
  11392. * Checks if the ray intersects a box
  11393. * @param box the bounding box to check
  11394. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11395. * @returns if the box was hit
  11396. */
  11397. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11398. /**
  11399. * If the ray hits a sphere
  11400. * @param sphere the bounding sphere to check
  11401. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11402. * @returns true if it hits the sphere
  11403. */
  11404. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11405. /**
  11406. * If the ray hits a triange
  11407. * @param vertex0 triangle vertex
  11408. * @param vertex1 triangle vertex
  11409. * @param vertex2 triangle vertex
  11410. * @returns intersection information if hit
  11411. */
  11412. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11413. /**
  11414. * Checks if ray intersects a plane
  11415. * @param plane the plane to check
  11416. * @returns the distance away it was hit
  11417. */
  11418. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11419. /**
  11420. * Checks if ray intersects a mesh
  11421. * @param mesh the mesh to check
  11422. * @param fastCheck if only the bounding box should checked
  11423. * @returns picking info of the intersecton
  11424. */
  11425. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11426. /**
  11427. * Checks if ray intersects a mesh
  11428. * @param meshes the meshes to check
  11429. * @param fastCheck if only the bounding box should checked
  11430. * @param results array to store result in
  11431. * @returns Array of picking infos
  11432. */
  11433. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11434. private _comparePickingInfo;
  11435. private static smallnum;
  11436. private static rayl;
  11437. /**
  11438. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11439. * @param sega the first point of the segment to test the intersection against
  11440. * @param segb the second point of the segment to test the intersection against
  11441. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11442. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11443. */
  11444. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11445. /**
  11446. * Update the ray from viewport position
  11447. * @param x position
  11448. * @param y y position
  11449. * @param viewportWidth viewport width
  11450. * @param viewportHeight viewport height
  11451. * @param world world matrix
  11452. * @param view view matrix
  11453. * @param projection projection matrix
  11454. * @returns this ray updated
  11455. */
  11456. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11457. /**
  11458. * Creates a ray with origin and direction of 0,0,0
  11459. * @returns the new ray
  11460. */
  11461. static Zero(): Ray;
  11462. /**
  11463. * Creates a new ray from screen space and viewport
  11464. * @param x position
  11465. * @param y y position
  11466. * @param viewportWidth viewport width
  11467. * @param viewportHeight viewport height
  11468. * @param world world matrix
  11469. * @param view view matrix
  11470. * @param projection projection matrix
  11471. * @returns new ray
  11472. */
  11473. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11474. /**
  11475. * 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
  11476. * transformed to the given world matrix.
  11477. * @param origin The origin point
  11478. * @param end The end point
  11479. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11480. * @returns the new ray
  11481. */
  11482. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11483. /**
  11484. * Transforms a ray by a matrix
  11485. * @param ray ray to transform
  11486. * @param matrix matrix to apply
  11487. * @returns the resulting new ray
  11488. */
  11489. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11490. /**
  11491. * Transforms a ray by a matrix
  11492. * @param ray ray to transform
  11493. * @param matrix matrix to apply
  11494. * @param result ray to store result in
  11495. */
  11496. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11497. /**
  11498. * Unproject a ray from screen space to object space
  11499. * @param sourceX defines the screen space x coordinate to use
  11500. * @param sourceY defines the screen space y coordinate to use
  11501. * @param viewportWidth defines the current width of the viewport
  11502. * @param viewportHeight defines the current height of the viewport
  11503. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11504. * @param view defines the view matrix to use
  11505. * @param projection defines the projection matrix to use
  11506. */
  11507. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11508. }
  11509. /**
  11510. * Type used to define predicate used to select faces when a mesh intersection is detected
  11511. */
  11512. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11513. interface Scene {
  11514. /** @hidden */
  11515. _tempPickingRay: Nullable<Ray>;
  11516. /** @hidden */
  11517. _cachedRayForTransform: Ray;
  11518. /** @hidden */
  11519. _pickWithRayInverseMatrix: Matrix;
  11520. /** @hidden */
  11521. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11522. /** @hidden */
  11523. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11524. }
  11525. }
  11526. declare module BABYLON {
  11527. /**
  11528. * Groups all the scene component constants in one place to ease maintenance.
  11529. * @hidden
  11530. */
  11531. export class SceneComponentConstants {
  11532. static readonly NAME_EFFECTLAYER: string;
  11533. static readonly NAME_LAYER: string;
  11534. static readonly NAME_LENSFLARESYSTEM: string;
  11535. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11536. static readonly NAME_PARTICLESYSTEM: string;
  11537. static readonly NAME_GAMEPAD: string;
  11538. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11539. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11540. static readonly NAME_DEPTHRENDERER: string;
  11541. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11542. static readonly NAME_SPRITE: string;
  11543. static readonly NAME_OUTLINERENDERER: string;
  11544. static readonly NAME_PROCEDURALTEXTURE: string;
  11545. static readonly NAME_SHADOWGENERATOR: string;
  11546. static readonly NAME_OCTREE: string;
  11547. static readonly NAME_PHYSICSENGINE: string;
  11548. static readonly NAME_AUDIO: string;
  11549. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11550. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11551. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11552. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11553. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11554. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11555. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11556. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11557. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11558. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11559. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11560. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11561. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11562. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11563. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11564. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11565. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11566. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11567. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11568. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11569. static readonly STEP_AFTERRENDER_AUDIO: number;
  11570. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11571. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11572. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11573. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11574. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11575. static readonly STEP_POINTERMOVE_SPRITE: number;
  11576. static readonly STEP_POINTERDOWN_SPRITE: number;
  11577. static readonly STEP_POINTERUP_SPRITE: number;
  11578. }
  11579. /**
  11580. * This represents a scene component.
  11581. *
  11582. * This is used to decouple the dependency the scene is having on the different workloads like
  11583. * layers, post processes...
  11584. */
  11585. export interface ISceneComponent {
  11586. /**
  11587. * The name of the component. Each component must have a unique name.
  11588. */
  11589. name: string;
  11590. /**
  11591. * The scene the component belongs to.
  11592. */
  11593. scene: Scene;
  11594. /**
  11595. * Register the component to one instance of a scene.
  11596. */
  11597. register(): void;
  11598. /**
  11599. * Rebuilds the elements related to this component in case of
  11600. * context lost for instance.
  11601. */
  11602. rebuild(): void;
  11603. /**
  11604. * Disposes the component and the associated ressources.
  11605. */
  11606. dispose(): void;
  11607. }
  11608. /**
  11609. * This represents a SERIALIZABLE scene component.
  11610. *
  11611. * This extends Scene Component to add Serialization methods on top.
  11612. */
  11613. export interface ISceneSerializableComponent extends ISceneComponent {
  11614. /**
  11615. * Adds all the element from the container to the scene
  11616. * @param container the container holding the elements
  11617. */
  11618. addFromContainer(container: AbstractScene): void;
  11619. /**
  11620. * Removes all the elements in the container from the scene
  11621. * @param container contains the elements to remove
  11622. * @param dispose if the removed element should be disposed (default: false)
  11623. */
  11624. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11625. /**
  11626. * Serializes the component data to the specified json object
  11627. * @param serializationObject The object to serialize to
  11628. */
  11629. serialize(serializationObject: any): void;
  11630. }
  11631. /**
  11632. * Strong typing of a Mesh related stage step action
  11633. */
  11634. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11635. /**
  11636. * Strong typing of a Evaluate Sub Mesh related stage step action
  11637. */
  11638. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11639. /**
  11640. * Strong typing of a Active Mesh related stage step action
  11641. */
  11642. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11643. /**
  11644. * Strong typing of a Camera related stage step action
  11645. */
  11646. export type CameraStageAction = (camera: Camera) => void;
  11647. /**
  11648. * Strong typing of a Camera Frame buffer related stage step action
  11649. */
  11650. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11651. /**
  11652. * Strong typing of a Render Target related stage step action
  11653. */
  11654. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11655. /**
  11656. * Strong typing of a RenderingGroup related stage step action
  11657. */
  11658. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11659. /**
  11660. * Strong typing of a Mesh Render related stage step action
  11661. */
  11662. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11663. /**
  11664. * Strong typing of a simple stage step action
  11665. */
  11666. export type SimpleStageAction = () => void;
  11667. /**
  11668. * Strong typing of a render target action.
  11669. */
  11670. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11671. /**
  11672. * Strong typing of a pointer move action.
  11673. */
  11674. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11675. /**
  11676. * Strong typing of a pointer up/down action.
  11677. */
  11678. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11679. /**
  11680. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11681. * @hidden
  11682. */
  11683. export class Stage<T extends Function> extends Array<{
  11684. index: number;
  11685. component: ISceneComponent;
  11686. action: T;
  11687. }> {
  11688. /**
  11689. * Hide ctor from the rest of the world.
  11690. * @param items The items to add.
  11691. */
  11692. private constructor();
  11693. /**
  11694. * Creates a new Stage.
  11695. * @returns A new instance of a Stage
  11696. */
  11697. static Create<T extends Function>(): Stage<T>;
  11698. /**
  11699. * Registers a step in an ordered way in the targeted stage.
  11700. * @param index Defines the position to register the step in
  11701. * @param component Defines the component attached to the step
  11702. * @param action Defines the action to launch during the step
  11703. */
  11704. registerStep(index: number, component: ISceneComponent, action: T): void;
  11705. /**
  11706. * Clears all the steps from the stage.
  11707. */
  11708. clear(): void;
  11709. }
  11710. }
  11711. declare module BABYLON {
  11712. interface Scene {
  11713. /** @hidden */
  11714. _pointerOverSprite: Nullable<Sprite>;
  11715. /** @hidden */
  11716. _pickedDownSprite: Nullable<Sprite>;
  11717. /** @hidden */
  11718. _tempSpritePickingRay: Nullable<Ray>;
  11719. /**
  11720. * All of the sprite managers added to this scene
  11721. * @see http://doc.babylonjs.com/babylon101/sprites
  11722. */
  11723. spriteManagers: Array<ISpriteManager>;
  11724. /**
  11725. * An event triggered when sprites rendering is about to start
  11726. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11727. */
  11728. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11729. /**
  11730. * An event triggered when sprites rendering is done
  11731. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11732. */
  11733. onAfterSpritesRenderingObservable: Observable<Scene>;
  11734. /** @hidden */
  11735. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11736. /** Launch a ray to try to pick a sprite in the scene
  11737. * @param x position on screen
  11738. * @param y position on screen
  11739. * @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
  11740. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11741. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11742. * @returns a PickingInfo
  11743. */
  11744. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11745. /** Use the given ray to pick a sprite in the scene
  11746. * @param ray The ray (in world space) to use to pick meshes
  11747. * @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
  11748. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11749. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11750. * @returns a PickingInfo
  11751. */
  11752. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11753. /**
  11754. * Force the sprite under the pointer
  11755. * @param sprite defines the sprite to use
  11756. */
  11757. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11758. /**
  11759. * Gets the sprite under the pointer
  11760. * @returns a Sprite or null if no sprite is under the pointer
  11761. */
  11762. getPointerOverSprite(): Nullable<Sprite>;
  11763. }
  11764. /**
  11765. * Defines the sprite scene component responsible to manage sprites
  11766. * in a given scene.
  11767. */
  11768. export class SpriteSceneComponent implements ISceneComponent {
  11769. /**
  11770. * The component name helpfull to identify the component in the list of scene components.
  11771. */
  11772. readonly name: string;
  11773. /**
  11774. * The scene the component belongs to.
  11775. */
  11776. scene: Scene;
  11777. /** @hidden */
  11778. private _spritePredicate;
  11779. /**
  11780. * Creates a new instance of the component for the given scene
  11781. * @param scene Defines the scene to register the component in
  11782. */
  11783. constructor(scene: Scene);
  11784. /**
  11785. * Registers the component in a given scene
  11786. */
  11787. register(): void;
  11788. /**
  11789. * Rebuilds the elements related to this component in case of
  11790. * context lost for instance.
  11791. */
  11792. rebuild(): void;
  11793. /**
  11794. * Disposes the component and the associated ressources.
  11795. */
  11796. dispose(): void;
  11797. private _pickSpriteButKeepRay;
  11798. private _pointerMove;
  11799. private _pointerDown;
  11800. private _pointerUp;
  11801. }
  11802. }
  11803. declare module BABYLON {
  11804. /** @hidden */
  11805. export var fogFragmentDeclaration: {
  11806. name: string;
  11807. shader: string;
  11808. };
  11809. }
  11810. declare module BABYLON {
  11811. /** @hidden */
  11812. export var fogFragment: {
  11813. name: string;
  11814. shader: string;
  11815. };
  11816. }
  11817. declare module BABYLON {
  11818. /** @hidden */
  11819. export var spritesPixelShader: {
  11820. name: string;
  11821. shader: string;
  11822. };
  11823. }
  11824. declare module BABYLON {
  11825. /** @hidden */
  11826. export var fogVertexDeclaration: {
  11827. name: string;
  11828. shader: string;
  11829. };
  11830. }
  11831. declare module BABYLON {
  11832. /** @hidden */
  11833. export var spritesVertexShader: {
  11834. name: string;
  11835. shader: string;
  11836. };
  11837. }
  11838. declare module BABYLON {
  11839. /**
  11840. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11841. */
  11842. export interface ISpriteManager extends IDisposable {
  11843. /**
  11844. * Restricts the camera to viewing objects with the same layerMask.
  11845. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11846. */
  11847. layerMask: number;
  11848. /**
  11849. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11850. */
  11851. isPickable: boolean;
  11852. /**
  11853. * Specifies the rendering group id for this mesh (0 by default)
  11854. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11855. */
  11856. renderingGroupId: number;
  11857. /**
  11858. * Defines the list of sprites managed by the manager.
  11859. */
  11860. sprites: Array<Sprite>;
  11861. /**
  11862. * Tests the intersection of a sprite with a specific ray.
  11863. * @param ray The ray we are sending to test the collision
  11864. * @param camera The camera space we are sending rays in
  11865. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11866. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11867. * @returns picking info or null.
  11868. */
  11869. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11870. /**
  11871. * Renders the list of sprites on screen.
  11872. */
  11873. render(): void;
  11874. }
  11875. /**
  11876. * Class used to manage multiple sprites on the same spritesheet
  11877. * @see http://doc.babylonjs.com/babylon101/sprites
  11878. */
  11879. export class SpriteManager implements ISpriteManager {
  11880. /** defines the manager's name */
  11881. name: string;
  11882. /** Gets the list of sprites */
  11883. sprites: Sprite[];
  11884. /** Gets or sets the rendering group id (0 by default) */
  11885. renderingGroupId: number;
  11886. /** Gets or sets camera layer mask */
  11887. layerMask: number;
  11888. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11889. fogEnabled: boolean;
  11890. /** Gets or sets a boolean indicating if the sprites are pickable */
  11891. isPickable: boolean;
  11892. /** Defines the default width of a cell in the spritesheet */
  11893. cellWidth: number;
  11894. /** Defines the default height of a cell in the spritesheet */
  11895. cellHeight: number;
  11896. /**
  11897. * An event triggered when the manager is disposed.
  11898. */
  11899. onDisposeObservable: Observable<SpriteManager>;
  11900. private _onDisposeObserver;
  11901. /**
  11902. * Callback called when the manager is disposed
  11903. */
  11904. onDispose: () => void;
  11905. private _capacity;
  11906. private _spriteTexture;
  11907. private _epsilon;
  11908. private _scene;
  11909. private _vertexData;
  11910. private _buffer;
  11911. private _vertexBuffers;
  11912. private _indexBuffer;
  11913. private _effectBase;
  11914. private _effectFog;
  11915. /**
  11916. * Gets or sets the spritesheet texture
  11917. */
  11918. texture: Texture;
  11919. /**
  11920. * Creates a new sprite manager
  11921. * @param name defines the manager's name
  11922. * @param imgUrl defines the sprite sheet url
  11923. * @param capacity defines the maximum allowed number of sprites
  11924. * @param cellSize defines the size of a sprite cell
  11925. * @param scene defines the hosting scene
  11926. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11927. * @param samplingMode defines the smapling mode to use with spritesheet
  11928. */
  11929. constructor(
  11930. /** defines the manager's name */
  11931. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11932. private _appendSpriteVertex;
  11933. /**
  11934. * Intersects the sprites with a ray
  11935. * @param ray defines the ray to intersect with
  11936. * @param camera defines the current active camera
  11937. * @param predicate defines a predicate used to select candidate sprites
  11938. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11939. * @returns null if no hit or a PickingInfo
  11940. */
  11941. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11942. /**
  11943. * Render all child sprites
  11944. */
  11945. render(): void;
  11946. /**
  11947. * Release associated resources
  11948. */
  11949. dispose(): void;
  11950. }
  11951. }
  11952. declare module BABYLON {
  11953. /**
  11954. * Class used to represent a sprite
  11955. * @see http://doc.babylonjs.com/babylon101/sprites
  11956. */
  11957. export class Sprite {
  11958. /** defines the name */
  11959. name: string;
  11960. /** Gets or sets the current world position */
  11961. position: Vector3;
  11962. /** Gets or sets the main color */
  11963. color: Color4;
  11964. /** Gets or sets the width */
  11965. width: number;
  11966. /** Gets or sets the height */
  11967. height: number;
  11968. /** Gets or sets rotation angle */
  11969. angle: number;
  11970. /** Gets or sets the cell index in the sprite sheet */
  11971. cellIndex: number;
  11972. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11973. invertU: number;
  11974. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11975. invertV: number;
  11976. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11977. disposeWhenFinishedAnimating: boolean;
  11978. /** Gets the list of attached animations */
  11979. animations: Animation[];
  11980. /** Gets or sets a boolean indicating if the sprite can be picked */
  11981. isPickable: boolean;
  11982. /**
  11983. * Gets or sets the associated action manager
  11984. */
  11985. actionManager: Nullable<ActionManager>;
  11986. private _animationStarted;
  11987. private _loopAnimation;
  11988. private _fromIndex;
  11989. private _toIndex;
  11990. private _delay;
  11991. private _direction;
  11992. private _manager;
  11993. private _time;
  11994. private _onAnimationEnd;
  11995. /**
  11996. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11997. */
  11998. isVisible: boolean;
  11999. /**
  12000. * Gets or sets the sprite size
  12001. */
  12002. size: number;
  12003. /**
  12004. * Creates a new Sprite
  12005. * @param name defines the name
  12006. * @param manager defines the manager
  12007. */
  12008. constructor(
  12009. /** defines the name */
  12010. name: string, manager: ISpriteManager);
  12011. /**
  12012. * Starts an animation
  12013. * @param from defines the initial key
  12014. * @param to defines the end key
  12015. * @param loop defines if the animation must loop
  12016. * @param delay defines the start delay (in ms)
  12017. * @param onAnimationEnd defines a callback to call when animation ends
  12018. */
  12019. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12020. /** Stops current animation (if any) */
  12021. stopAnimation(): void;
  12022. /** @hidden */
  12023. _animate(deltaTime: number): void;
  12024. /** Release associated resources */
  12025. dispose(): void;
  12026. }
  12027. }
  12028. declare module BABYLON {
  12029. /**
  12030. * Information about the result of picking within a scene
  12031. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12032. */
  12033. export class PickingInfo {
  12034. /** @hidden */
  12035. _pickingUnavailable: boolean;
  12036. /**
  12037. * If the pick collided with an object
  12038. */
  12039. hit: boolean;
  12040. /**
  12041. * Distance away where the pick collided
  12042. */
  12043. distance: number;
  12044. /**
  12045. * The location of pick collision
  12046. */
  12047. pickedPoint: Nullable<Vector3>;
  12048. /**
  12049. * The mesh corresponding the the pick collision
  12050. */
  12051. pickedMesh: Nullable<AbstractMesh>;
  12052. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12053. bu: number;
  12054. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12055. bv: number;
  12056. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12057. faceId: number;
  12058. /** Id of the the submesh that was picked */
  12059. subMeshId: number;
  12060. /** If a sprite was picked, this will be the sprite the pick collided with */
  12061. pickedSprite: Nullable<Sprite>;
  12062. /**
  12063. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12064. */
  12065. originMesh: Nullable<AbstractMesh>;
  12066. /**
  12067. * The ray that was used to perform the picking.
  12068. */
  12069. ray: Nullable<Ray>;
  12070. /**
  12071. * Gets the normal correspodning to the face the pick collided with
  12072. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12073. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12074. * @returns The normal correspodning to the face the pick collided with
  12075. */
  12076. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12077. /**
  12078. * Gets the texture coordinates of where the pick occured
  12079. * @returns the vector containing the coordnates of the texture
  12080. */
  12081. getTextureCoordinates(): Nullable<Vector2>;
  12082. }
  12083. }
  12084. declare module BABYLON {
  12085. /**
  12086. * Gather the list of pointer event types as constants.
  12087. */
  12088. export class PointerEventTypes {
  12089. /**
  12090. * 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.
  12091. */
  12092. static readonly POINTERDOWN: number;
  12093. /**
  12094. * The pointerup event is fired when a pointer is no longer active.
  12095. */
  12096. static readonly POINTERUP: number;
  12097. /**
  12098. * The pointermove event is fired when a pointer changes coordinates.
  12099. */
  12100. static readonly POINTERMOVE: number;
  12101. /**
  12102. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12103. */
  12104. static readonly POINTERWHEEL: number;
  12105. /**
  12106. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12107. */
  12108. static readonly POINTERPICK: number;
  12109. /**
  12110. * The pointertap event is fired when a the object has been touched and released without drag.
  12111. */
  12112. static readonly POINTERTAP: number;
  12113. /**
  12114. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12115. */
  12116. static readonly POINTERDOUBLETAP: number;
  12117. }
  12118. /**
  12119. * Base class of pointer info types.
  12120. */
  12121. export class PointerInfoBase {
  12122. /**
  12123. * Defines the type of event (PointerEventTypes)
  12124. */
  12125. type: number;
  12126. /**
  12127. * Defines the related dom event
  12128. */
  12129. event: PointerEvent | MouseWheelEvent;
  12130. /**
  12131. * Instantiates the base class of pointers info.
  12132. * @param type Defines the type of event (PointerEventTypes)
  12133. * @param event Defines the related dom event
  12134. */
  12135. constructor(
  12136. /**
  12137. * Defines the type of event (PointerEventTypes)
  12138. */
  12139. type: number,
  12140. /**
  12141. * Defines the related dom event
  12142. */
  12143. event: PointerEvent | MouseWheelEvent);
  12144. }
  12145. /**
  12146. * This class is used to store pointer related info for the onPrePointerObservable event.
  12147. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12148. */
  12149. export class PointerInfoPre extends PointerInfoBase {
  12150. /**
  12151. * Ray from a pointer if availible (eg. 6dof controller)
  12152. */
  12153. ray: Nullable<Ray>;
  12154. /**
  12155. * Defines the local position of the pointer on the canvas.
  12156. */
  12157. localPosition: Vector2;
  12158. /**
  12159. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12160. */
  12161. skipOnPointerObservable: boolean;
  12162. /**
  12163. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12164. * @param type Defines the type of event (PointerEventTypes)
  12165. * @param event Defines the related dom event
  12166. * @param localX Defines the local x coordinates of the pointer when the event occured
  12167. * @param localY Defines the local y coordinates of the pointer when the event occured
  12168. */
  12169. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12170. }
  12171. /**
  12172. * This type contains all the data related to a pointer event in Babylon.js.
  12173. * 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.
  12174. */
  12175. export class PointerInfo extends PointerInfoBase {
  12176. /**
  12177. * Defines the picking info associated to the info (if any)\
  12178. */
  12179. pickInfo: Nullable<PickingInfo>;
  12180. /**
  12181. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12182. * @param type Defines the type of event (PointerEventTypes)
  12183. * @param event Defines the related dom event
  12184. * @param pickInfo Defines the picking info associated to the info (if any)\
  12185. */
  12186. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12187. /**
  12188. * Defines the picking info associated to the info (if any)\
  12189. */
  12190. pickInfo: Nullable<PickingInfo>);
  12191. }
  12192. /**
  12193. * Data relating to a touch event on the screen.
  12194. */
  12195. export interface PointerTouch {
  12196. /**
  12197. * X coordinate of touch.
  12198. */
  12199. x: number;
  12200. /**
  12201. * Y coordinate of touch.
  12202. */
  12203. y: number;
  12204. /**
  12205. * Id of touch. Unique for each finger.
  12206. */
  12207. pointerId: number;
  12208. /**
  12209. * Event type passed from DOM.
  12210. */
  12211. type: any;
  12212. }
  12213. }
  12214. declare module BABYLON {
  12215. /**
  12216. * Manage the mouse inputs to control the movement of a free camera.
  12217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12218. */
  12219. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12220. /**
  12221. * Define if touch is enabled in the mouse input
  12222. */
  12223. touchEnabled: boolean;
  12224. /**
  12225. * Defines the camera the input is attached to.
  12226. */
  12227. camera: FreeCamera;
  12228. /**
  12229. * Defines the buttons associated with the input to handle camera move.
  12230. */
  12231. buttons: number[];
  12232. /**
  12233. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12234. */
  12235. angularSensibility: number;
  12236. private _pointerInput;
  12237. private _onMouseMove;
  12238. private _observer;
  12239. private previousPosition;
  12240. /**
  12241. * Observable for when a pointer move event occurs containing the move offset
  12242. */
  12243. onPointerMovedObservable: Observable<{
  12244. offsetX: number;
  12245. offsetY: number;
  12246. }>;
  12247. /**
  12248. * @hidden
  12249. * If the camera should be rotated automatically based on pointer movement
  12250. */
  12251. _allowCameraRotation: boolean;
  12252. /**
  12253. * Manage the mouse inputs to control the movement of a free camera.
  12254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12255. * @param touchEnabled Defines if touch is enabled or not
  12256. */
  12257. constructor(
  12258. /**
  12259. * Define if touch is enabled in the mouse input
  12260. */
  12261. touchEnabled?: boolean);
  12262. /**
  12263. * Attach the input controls to a specific dom element to get the input from.
  12264. * @param element Defines the element the controls should be listened from
  12265. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12266. */
  12267. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12268. /**
  12269. * Called on JS contextmenu event.
  12270. * Override this method to provide functionality.
  12271. */
  12272. protected onContextMenu(evt: PointerEvent): void;
  12273. /**
  12274. * Detach the current controls from the specified dom element.
  12275. * @param element Defines the element to stop listening the inputs from
  12276. */
  12277. detachControl(element: Nullable<HTMLElement>): void;
  12278. /**
  12279. * Gets the class name of the current intput.
  12280. * @returns the class name
  12281. */
  12282. getClassName(): string;
  12283. /**
  12284. * Get the friendly name associated with the input class.
  12285. * @returns the input friendly name
  12286. */
  12287. getSimpleName(): string;
  12288. }
  12289. }
  12290. declare module BABYLON {
  12291. /**
  12292. * Manage the touch inputs to control the movement of a free camera.
  12293. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12294. */
  12295. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12296. /**
  12297. * Defines the camera the input is attached to.
  12298. */
  12299. camera: FreeCamera;
  12300. /**
  12301. * Defines the touch sensibility for rotation.
  12302. * The higher the faster.
  12303. */
  12304. touchAngularSensibility: number;
  12305. /**
  12306. * Defines the touch sensibility for move.
  12307. * The higher the faster.
  12308. */
  12309. touchMoveSensibility: number;
  12310. private _offsetX;
  12311. private _offsetY;
  12312. private _pointerPressed;
  12313. private _pointerInput;
  12314. private _observer;
  12315. private _onLostFocus;
  12316. /**
  12317. * Attach the input controls to a specific dom element to get the input from.
  12318. * @param element Defines the element the controls should be listened from
  12319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12320. */
  12321. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12322. /**
  12323. * Detach the current controls from the specified dom element.
  12324. * @param element Defines the element to stop listening the inputs from
  12325. */
  12326. detachControl(element: Nullable<HTMLElement>): void;
  12327. /**
  12328. * Update the current camera state depending on the inputs that have been used this frame.
  12329. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12330. */
  12331. checkInputs(): void;
  12332. /**
  12333. * Gets the class name of the current intput.
  12334. * @returns the class name
  12335. */
  12336. getClassName(): string;
  12337. /**
  12338. * Get the friendly name associated with the input class.
  12339. * @returns the input friendly name
  12340. */
  12341. getSimpleName(): string;
  12342. }
  12343. }
  12344. declare module BABYLON {
  12345. /**
  12346. * Default Inputs manager for the FreeCamera.
  12347. * It groups all the default supported inputs for ease of use.
  12348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12349. */
  12350. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12351. /**
  12352. * @hidden
  12353. */
  12354. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12355. /**
  12356. * @hidden
  12357. */
  12358. _mouseInput: Nullable<FreeCameraMouseInput>;
  12359. /**
  12360. * Instantiates a new FreeCameraInputsManager.
  12361. * @param camera Defines the camera the inputs belong to
  12362. */
  12363. constructor(camera: FreeCamera);
  12364. /**
  12365. * Add keyboard input support to the input manager.
  12366. * @returns the current input manager
  12367. */
  12368. addKeyboard(): FreeCameraInputsManager;
  12369. /**
  12370. * Add mouse input support to the input manager.
  12371. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12372. * @returns the current input manager
  12373. */
  12374. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12375. /**
  12376. * Removes the mouse input support from the manager
  12377. * @returns the current input manager
  12378. */
  12379. removeMouse(): FreeCameraInputsManager;
  12380. /**
  12381. * Add touch input support to the input manager.
  12382. * @returns the current input manager
  12383. */
  12384. addTouch(): FreeCameraInputsManager;
  12385. }
  12386. }
  12387. declare module BABYLON {
  12388. /**
  12389. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12390. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12391. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12392. */
  12393. export class FreeCamera extends TargetCamera {
  12394. /**
  12395. * Define the collision ellipsoid of the camera.
  12396. * This is helpful to simulate a camera body like the player body around the camera
  12397. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12398. */
  12399. ellipsoid: Vector3;
  12400. /**
  12401. * Define an offset for the position of the ellipsoid around the camera.
  12402. * This can be helpful to determine the center of the body near the gravity center of the body
  12403. * instead of its head.
  12404. */
  12405. ellipsoidOffset: Vector3;
  12406. /**
  12407. * Enable or disable collisions of the camera with the rest of the scene objects.
  12408. */
  12409. checkCollisions: boolean;
  12410. /**
  12411. * Enable or disable gravity on the camera.
  12412. */
  12413. applyGravity: boolean;
  12414. /**
  12415. * Define the input manager associated to the camera.
  12416. */
  12417. inputs: FreeCameraInputsManager;
  12418. /**
  12419. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12420. * Higher values reduce sensitivity.
  12421. */
  12422. /**
  12423. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12424. * Higher values reduce sensitivity.
  12425. */
  12426. angularSensibility: number;
  12427. /**
  12428. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12429. */
  12430. keysUp: number[];
  12431. /**
  12432. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12433. */
  12434. keysDown: number[];
  12435. /**
  12436. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12437. */
  12438. keysLeft: number[];
  12439. /**
  12440. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12441. */
  12442. keysRight: number[];
  12443. /**
  12444. * Event raised when the camera collide with a mesh in the scene.
  12445. */
  12446. onCollide: (collidedMesh: AbstractMesh) => void;
  12447. private _collider;
  12448. private _needMoveForGravity;
  12449. private _oldPosition;
  12450. private _diffPosition;
  12451. private _newPosition;
  12452. /** @hidden */
  12453. _localDirection: Vector3;
  12454. /** @hidden */
  12455. _transformedDirection: Vector3;
  12456. /**
  12457. * Instantiates a Free Camera.
  12458. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12459. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12460. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12461. * @param name Define the name of the camera in the scene
  12462. * @param position Define the start position of the camera in the scene
  12463. * @param scene Define the scene the camera belongs to
  12464. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12465. */
  12466. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12467. /**
  12468. * Attached controls to the current camera.
  12469. * @param element Defines the element the controls should be listened from
  12470. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12471. */
  12472. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12473. /**
  12474. * Detach the current controls from the camera.
  12475. * The camera will stop reacting to inputs.
  12476. * @param element Defines the element to stop listening the inputs from
  12477. */
  12478. detachControl(element: HTMLElement): void;
  12479. private _collisionMask;
  12480. /**
  12481. * Define a collision mask to limit the list of object the camera can collide with
  12482. */
  12483. collisionMask: number;
  12484. /** @hidden */
  12485. _collideWithWorld(displacement: Vector3): void;
  12486. private _onCollisionPositionChange;
  12487. /** @hidden */
  12488. _checkInputs(): void;
  12489. /** @hidden */
  12490. _decideIfNeedsToMove(): boolean;
  12491. /** @hidden */
  12492. _updatePosition(): void;
  12493. /**
  12494. * Destroy the camera and release the current resources hold by it.
  12495. */
  12496. dispose(): void;
  12497. /**
  12498. * Gets the current object class name.
  12499. * @return the class name
  12500. */
  12501. getClassName(): string;
  12502. }
  12503. }
  12504. declare module BABYLON {
  12505. /**
  12506. * Represents a gamepad control stick position
  12507. */
  12508. export class StickValues {
  12509. /**
  12510. * The x component of the control stick
  12511. */
  12512. x: number;
  12513. /**
  12514. * The y component of the control stick
  12515. */
  12516. y: number;
  12517. /**
  12518. * Initializes the gamepad x and y control stick values
  12519. * @param x The x component of the gamepad control stick value
  12520. * @param y The y component of the gamepad control stick value
  12521. */
  12522. constructor(
  12523. /**
  12524. * The x component of the control stick
  12525. */
  12526. x: number,
  12527. /**
  12528. * The y component of the control stick
  12529. */
  12530. y: number);
  12531. }
  12532. /**
  12533. * An interface which manages callbacks for gamepad button changes
  12534. */
  12535. export interface GamepadButtonChanges {
  12536. /**
  12537. * Called when a gamepad has been changed
  12538. */
  12539. changed: boolean;
  12540. /**
  12541. * Called when a gamepad press event has been triggered
  12542. */
  12543. pressChanged: boolean;
  12544. /**
  12545. * Called when a touch event has been triggered
  12546. */
  12547. touchChanged: boolean;
  12548. /**
  12549. * Called when a value has changed
  12550. */
  12551. valueChanged: boolean;
  12552. }
  12553. /**
  12554. * Represents a gamepad
  12555. */
  12556. export class Gamepad {
  12557. /**
  12558. * The id of the gamepad
  12559. */
  12560. id: string;
  12561. /**
  12562. * The index of the gamepad
  12563. */
  12564. index: number;
  12565. /**
  12566. * The browser gamepad
  12567. */
  12568. browserGamepad: any;
  12569. /**
  12570. * Specifies what type of gamepad this represents
  12571. */
  12572. type: number;
  12573. private _leftStick;
  12574. private _rightStick;
  12575. /** @hidden */
  12576. _isConnected: boolean;
  12577. private _leftStickAxisX;
  12578. private _leftStickAxisY;
  12579. private _rightStickAxisX;
  12580. private _rightStickAxisY;
  12581. /**
  12582. * Triggered when the left control stick has been changed
  12583. */
  12584. private _onleftstickchanged;
  12585. /**
  12586. * Triggered when the right control stick has been changed
  12587. */
  12588. private _onrightstickchanged;
  12589. /**
  12590. * Represents a gamepad controller
  12591. */
  12592. static GAMEPAD: number;
  12593. /**
  12594. * Represents a generic controller
  12595. */
  12596. static GENERIC: number;
  12597. /**
  12598. * Represents an XBox controller
  12599. */
  12600. static XBOX: number;
  12601. /**
  12602. * Represents a pose-enabled controller
  12603. */
  12604. static POSE_ENABLED: number;
  12605. /**
  12606. * Specifies whether the left control stick should be Y-inverted
  12607. */
  12608. protected _invertLeftStickY: boolean;
  12609. /**
  12610. * Specifies if the gamepad has been connected
  12611. */
  12612. readonly isConnected: boolean;
  12613. /**
  12614. * Initializes the gamepad
  12615. * @param id The id of the gamepad
  12616. * @param index The index of the gamepad
  12617. * @param browserGamepad The browser gamepad
  12618. * @param leftStickX The x component of the left joystick
  12619. * @param leftStickY The y component of the left joystick
  12620. * @param rightStickX The x component of the right joystick
  12621. * @param rightStickY The y component of the right joystick
  12622. */
  12623. constructor(
  12624. /**
  12625. * The id of the gamepad
  12626. */
  12627. id: string,
  12628. /**
  12629. * The index of the gamepad
  12630. */
  12631. index: number,
  12632. /**
  12633. * The browser gamepad
  12634. */
  12635. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12636. /**
  12637. * Callback triggered when the left joystick has changed
  12638. * @param callback
  12639. */
  12640. onleftstickchanged(callback: (values: StickValues) => void): void;
  12641. /**
  12642. * Callback triggered when the right joystick has changed
  12643. * @param callback
  12644. */
  12645. onrightstickchanged(callback: (values: StickValues) => void): void;
  12646. /**
  12647. * Gets the left joystick
  12648. */
  12649. /**
  12650. * Sets the left joystick values
  12651. */
  12652. leftStick: StickValues;
  12653. /**
  12654. * Gets the right joystick
  12655. */
  12656. /**
  12657. * Sets the right joystick value
  12658. */
  12659. rightStick: StickValues;
  12660. /**
  12661. * Updates the gamepad joystick positions
  12662. */
  12663. update(): void;
  12664. /**
  12665. * Disposes the gamepad
  12666. */
  12667. dispose(): void;
  12668. }
  12669. /**
  12670. * Represents a generic gamepad
  12671. */
  12672. export class GenericPad extends Gamepad {
  12673. private _buttons;
  12674. private _onbuttondown;
  12675. private _onbuttonup;
  12676. /**
  12677. * Observable triggered when a button has been pressed
  12678. */
  12679. onButtonDownObservable: Observable<number>;
  12680. /**
  12681. * Observable triggered when a button has been released
  12682. */
  12683. onButtonUpObservable: Observable<number>;
  12684. /**
  12685. * Callback triggered when a button has been pressed
  12686. * @param callback Called when a button has been pressed
  12687. */
  12688. onbuttondown(callback: (buttonPressed: number) => void): void;
  12689. /**
  12690. * Callback triggered when a button has been released
  12691. * @param callback Called when a button has been released
  12692. */
  12693. onbuttonup(callback: (buttonReleased: number) => void): void;
  12694. /**
  12695. * Initializes the generic gamepad
  12696. * @param id The id of the generic gamepad
  12697. * @param index The index of the generic gamepad
  12698. * @param browserGamepad The browser gamepad
  12699. */
  12700. constructor(id: string, index: number, browserGamepad: any);
  12701. private _setButtonValue;
  12702. /**
  12703. * Updates the generic gamepad
  12704. */
  12705. update(): void;
  12706. /**
  12707. * Disposes the generic gamepad
  12708. */
  12709. dispose(): void;
  12710. }
  12711. }
  12712. declare module BABYLON {
  12713. /**
  12714. * Defines the types of pose enabled controllers that are supported
  12715. */
  12716. export enum PoseEnabledControllerType {
  12717. /**
  12718. * HTC Vive
  12719. */
  12720. VIVE = 0,
  12721. /**
  12722. * Oculus Rift
  12723. */
  12724. OCULUS = 1,
  12725. /**
  12726. * Windows mixed reality
  12727. */
  12728. WINDOWS = 2,
  12729. /**
  12730. * Samsung gear VR
  12731. */
  12732. GEAR_VR = 3,
  12733. /**
  12734. * Google Daydream
  12735. */
  12736. DAYDREAM = 4,
  12737. /**
  12738. * Generic
  12739. */
  12740. GENERIC = 5
  12741. }
  12742. /**
  12743. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12744. */
  12745. export interface MutableGamepadButton {
  12746. /**
  12747. * Value of the button/trigger
  12748. */
  12749. value: number;
  12750. /**
  12751. * If the button/trigger is currently touched
  12752. */
  12753. touched: boolean;
  12754. /**
  12755. * If the button/trigger is currently pressed
  12756. */
  12757. pressed: boolean;
  12758. }
  12759. /**
  12760. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12761. * @hidden
  12762. */
  12763. export interface ExtendedGamepadButton extends GamepadButton {
  12764. /**
  12765. * If the button/trigger is currently pressed
  12766. */
  12767. readonly pressed: boolean;
  12768. /**
  12769. * If the button/trigger is currently touched
  12770. */
  12771. readonly touched: boolean;
  12772. /**
  12773. * Value of the button/trigger
  12774. */
  12775. readonly value: number;
  12776. }
  12777. /** @hidden */
  12778. export interface _GamePadFactory {
  12779. /**
  12780. * Returns wether or not the current gamepad can be created for this type of controller.
  12781. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12782. * @returns true if it can be created, otherwise false
  12783. */
  12784. canCreate(gamepadInfo: any): boolean;
  12785. /**
  12786. * Creates a new instance of the Gamepad.
  12787. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12788. * @returns the new gamepad instance
  12789. */
  12790. create(gamepadInfo: any): Gamepad;
  12791. }
  12792. /**
  12793. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12794. */
  12795. export class PoseEnabledControllerHelper {
  12796. /** @hidden */
  12797. static _ControllerFactories: _GamePadFactory[];
  12798. /** @hidden */
  12799. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12800. /**
  12801. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12802. * @param vrGamepad the gamepad to initialized
  12803. * @returns a vr controller of the type the gamepad identified as
  12804. */
  12805. static InitiateController(vrGamepad: any): Gamepad;
  12806. }
  12807. /**
  12808. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12809. */
  12810. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12811. private _deviceRoomPosition;
  12812. private _deviceRoomRotationQuaternion;
  12813. /**
  12814. * The device position in babylon space
  12815. */
  12816. devicePosition: Vector3;
  12817. /**
  12818. * The device rotation in babylon space
  12819. */
  12820. deviceRotationQuaternion: Quaternion;
  12821. /**
  12822. * The scale factor of the device in babylon space
  12823. */
  12824. deviceScaleFactor: number;
  12825. /**
  12826. * (Likely devicePosition should be used instead) The device position in its room space
  12827. */
  12828. position: Vector3;
  12829. /**
  12830. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12831. */
  12832. rotationQuaternion: Quaternion;
  12833. /**
  12834. * The type of controller (Eg. Windows mixed reality)
  12835. */
  12836. controllerType: PoseEnabledControllerType;
  12837. protected _calculatedPosition: Vector3;
  12838. private _calculatedRotation;
  12839. /**
  12840. * The raw pose from the device
  12841. */
  12842. rawPose: DevicePose;
  12843. private _trackPosition;
  12844. private _maxRotationDistFromHeadset;
  12845. private _draggedRoomRotation;
  12846. /**
  12847. * @hidden
  12848. */
  12849. _disableTrackPosition(fixedPosition: Vector3): void;
  12850. /**
  12851. * Internal, the mesh attached to the controller
  12852. * @hidden
  12853. */
  12854. _mesh: Nullable<AbstractMesh>;
  12855. private _poseControlledCamera;
  12856. private _leftHandSystemQuaternion;
  12857. /**
  12858. * Internal, matrix used to convert room space to babylon space
  12859. * @hidden
  12860. */
  12861. _deviceToWorld: Matrix;
  12862. /**
  12863. * Node to be used when casting a ray from the controller
  12864. * @hidden
  12865. */
  12866. _pointingPoseNode: Nullable<TransformNode>;
  12867. /**
  12868. * Name of the child mesh that can be used to cast a ray from the controller
  12869. */
  12870. static readonly POINTING_POSE: string;
  12871. /**
  12872. * Creates a new PoseEnabledController from a gamepad
  12873. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12874. */
  12875. constructor(browserGamepad: any);
  12876. private _workingMatrix;
  12877. /**
  12878. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12879. */
  12880. update(): void;
  12881. /**
  12882. * Updates only the pose device and mesh without doing any button event checking
  12883. */
  12884. protected _updatePoseAndMesh(): void;
  12885. /**
  12886. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12887. * @param poseData raw pose fromthe device
  12888. */
  12889. updateFromDevice(poseData: DevicePose): void;
  12890. /**
  12891. * @hidden
  12892. */
  12893. _meshAttachedObservable: Observable<AbstractMesh>;
  12894. /**
  12895. * Attaches a mesh to the controller
  12896. * @param mesh the mesh to be attached
  12897. */
  12898. attachToMesh(mesh: AbstractMesh): void;
  12899. /**
  12900. * Attaches the controllers mesh to a camera
  12901. * @param camera the camera the mesh should be attached to
  12902. */
  12903. attachToPoseControlledCamera(camera: TargetCamera): void;
  12904. /**
  12905. * Disposes of the controller
  12906. */
  12907. dispose(): void;
  12908. /**
  12909. * The mesh that is attached to the controller
  12910. */
  12911. readonly mesh: Nullable<AbstractMesh>;
  12912. /**
  12913. * Gets the ray of the controller in the direction the controller is pointing
  12914. * @param length the length the resulting ray should be
  12915. * @returns a ray in the direction the controller is pointing
  12916. */
  12917. getForwardRay(length?: number): Ray;
  12918. }
  12919. }
  12920. declare module BABYLON {
  12921. /**
  12922. * Defines the WebVRController object that represents controllers tracked in 3D space
  12923. */
  12924. export abstract class WebVRController extends PoseEnabledController {
  12925. /**
  12926. * Internal, the default controller model for the controller
  12927. */
  12928. protected _defaultModel: AbstractMesh;
  12929. /**
  12930. * Fired when the trigger state has changed
  12931. */
  12932. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12933. /**
  12934. * Fired when the main button state has changed
  12935. */
  12936. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12937. /**
  12938. * Fired when the secondary button state has changed
  12939. */
  12940. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12941. /**
  12942. * Fired when the pad state has changed
  12943. */
  12944. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12945. /**
  12946. * Fired when controllers stick values have changed
  12947. */
  12948. onPadValuesChangedObservable: Observable<StickValues>;
  12949. /**
  12950. * Array of button availible on the controller
  12951. */
  12952. protected _buttons: Array<MutableGamepadButton>;
  12953. private _onButtonStateChange;
  12954. /**
  12955. * Fired when a controller button's state has changed
  12956. * @param callback the callback containing the button that was modified
  12957. */
  12958. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12959. /**
  12960. * X and Y axis corrisponding to the controllers joystick
  12961. */
  12962. pad: StickValues;
  12963. /**
  12964. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12965. */
  12966. hand: string;
  12967. /**
  12968. * The default controller model for the controller
  12969. */
  12970. readonly defaultModel: AbstractMesh;
  12971. /**
  12972. * Creates a new WebVRController from a gamepad
  12973. * @param vrGamepad the gamepad that the WebVRController should be created from
  12974. */
  12975. constructor(vrGamepad: any);
  12976. /**
  12977. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12978. */
  12979. update(): void;
  12980. /**
  12981. * Function to be called when a button is modified
  12982. */
  12983. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12984. /**
  12985. * Loads a mesh and attaches it to the controller
  12986. * @param scene the scene the mesh should be added to
  12987. * @param meshLoaded callback for when the mesh has been loaded
  12988. */
  12989. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12990. private _setButtonValue;
  12991. private _changes;
  12992. private _checkChanges;
  12993. /**
  12994. * Disposes of th webVRCOntroller
  12995. */
  12996. dispose(): void;
  12997. }
  12998. }
  12999. declare module BABYLON {
  13000. /**
  13001. * The HemisphericLight simulates the ambient environment light,
  13002. * so the passed direction is the light reflection direction, not the incoming direction.
  13003. */
  13004. export class HemisphericLight extends Light {
  13005. /**
  13006. * The groundColor is the light in the opposite direction to the one specified during creation.
  13007. * 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.
  13008. */
  13009. groundColor: Color3;
  13010. /**
  13011. * The light reflection direction, not the incoming direction.
  13012. */
  13013. direction: Vector3;
  13014. /**
  13015. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13016. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13017. * The HemisphericLight can't cast shadows.
  13018. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13019. * @param name The friendly name of the light
  13020. * @param direction The direction of the light reflection
  13021. * @param scene The scene the light belongs to
  13022. */
  13023. constructor(name: string, direction: Vector3, scene: Scene);
  13024. protected _buildUniformLayout(): void;
  13025. /**
  13026. * Returns the string "HemisphericLight".
  13027. * @return The class name
  13028. */
  13029. getClassName(): string;
  13030. /**
  13031. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13032. * Returns the updated direction.
  13033. * @param target The target the direction should point to
  13034. * @return The computed direction
  13035. */
  13036. setDirectionToTarget(target: Vector3): Vector3;
  13037. /**
  13038. * Returns the shadow generator associated to the light.
  13039. * @returns Always null for hemispheric lights because it does not support shadows.
  13040. */
  13041. getShadowGenerator(): Nullable<IShadowGenerator>;
  13042. /**
  13043. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13044. * @param effect The effect to update
  13045. * @param lightIndex The index of the light in the effect to update
  13046. * @returns The hemispheric light
  13047. */
  13048. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13049. /**
  13050. * Computes the world matrix of the node
  13051. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13052. * @param useWasUpdatedFlag defines a reserved property
  13053. * @returns the world matrix
  13054. */
  13055. computeWorldMatrix(): Matrix;
  13056. /**
  13057. * Returns the integer 3.
  13058. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13059. */
  13060. getTypeID(): number;
  13061. /**
  13062. * Prepares the list of defines specific to the light type.
  13063. * @param defines the list of defines
  13064. * @param lightIndex defines the index of the light for the effect
  13065. */
  13066. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13067. }
  13068. }
  13069. declare module BABYLON {
  13070. /** @hidden */
  13071. export var vrMultiviewToSingleviewPixelShader: {
  13072. name: string;
  13073. shader: string;
  13074. };
  13075. }
  13076. declare module BABYLON {
  13077. /**
  13078. * Renders to multiple views with a single draw call
  13079. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13080. */
  13081. export class MultiviewRenderTarget extends RenderTargetTexture {
  13082. /**
  13083. * Creates a multiview render target
  13084. * @param scene scene used with the render target
  13085. * @param size the size of the render target (used for each view)
  13086. */
  13087. constructor(scene: Scene, size?: number | {
  13088. width: number;
  13089. height: number;
  13090. } | {
  13091. ratio: number;
  13092. });
  13093. /**
  13094. * @hidden
  13095. * @param faceIndex the face index, if its a cube texture
  13096. */
  13097. _bindFrameBuffer(faceIndex?: number): void;
  13098. /**
  13099. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13100. * @returns the view count
  13101. */
  13102. getViewCount(): number;
  13103. }
  13104. }
  13105. declare module BABYLON {
  13106. interface Engine {
  13107. /**
  13108. * Creates a new multiview render target
  13109. * @param width defines the width of the texture
  13110. * @param height defines the height of the texture
  13111. * @returns the created multiview texture
  13112. */
  13113. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13114. /**
  13115. * Binds a multiview framebuffer to be drawn to
  13116. * @param multiviewTexture texture to bind
  13117. */
  13118. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13119. }
  13120. interface Camera {
  13121. /**
  13122. * @hidden
  13123. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13124. */
  13125. _useMultiviewToSingleView: boolean;
  13126. /**
  13127. * @hidden
  13128. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13129. */
  13130. _multiviewTexture: Nullable<RenderTargetTexture>;
  13131. /**
  13132. * @hidden
  13133. * ensures the multiview texture of the camera exists and has the specified width/height
  13134. * @param width height to set on the multiview texture
  13135. * @param height width to set on the multiview texture
  13136. */
  13137. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13138. }
  13139. interface Scene {
  13140. /** @hidden */
  13141. _transformMatrixR: Matrix;
  13142. /** @hidden */
  13143. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13144. /** @hidden */
  13145. _createMultiviewUbo(): void;
  13146. /** @hidden */
  13147. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13148. /** @hidden */
  13149. _renderMultiviewToSingleView(camera: Camera): void;
  13150. }
  13151. }
  13152. declare module BABYLON {
  13153. /**
  13154. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13155. * This will not be used for webXR as it supports displaying texture arrays directly
  13156. */
  13157. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13158. /**
  13159. * Initializes a VRMultiviewToSingleview
  13160. * @param name name of the post process
  13161. * @param camera camera to be applied to
  13162. * @param scaleFactor scaling factor to the size of the output texture
  13163. */
  13164. constructor(name: string, camera: Camera, scaleFactor: number);
  13165. }
  13166. }
  13167. declare module BABYLON {
  13168. /**
  13169. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13170. * IMPORTANT!! The data is right-hand data.
  13171. * @export
  13172. * @interface DevicePose
  13173. */
  13174. export interface DevicePose {
  13175. /**
  13176. * The position of the device, values in array are [x,y,z].
  13177. */
  13178. readonly position: Nullable<Float32Array>;
  13179. /**
  13180. * The linearVelocity of the device, values in array are [x,y,z].
  13181. */
  13182. readonly linearVelocity: Nullable<Float32Array>;
  13183. /**
  13184. * The linearAcceleration of the device, values in array are [x,y,z].
  13185. */
  13186. readonly linearAcceleration: Nullable<Float32Array>;
  13187. /**
  13188. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13189. */
  13190. readonly orientation: Nullable<Float32Array>;
  13191. /**
  13192. * The angularVelocity of the device, values in array are [x,y,z].
  13193. */
  13194. readonly angularVelocity: Nullable<Float32Array>;
  13195. /**
  13196. * The angularAcceleration of the device, values in array are [x,y,z].
  13197. */
  13198. readonly angularAcceleration: Nullable<Float32Array>;
  13199. }
  13200. /**
  13201. * Interface representing a pose controlled object in Babylon.
  13202. * A pose controlled object has both regular pose values as well as pose values
  13203. * from an external device such as a VR head mounted display
  13204. */
  13205. export interface PoseControlled {
  13206. /**
  13207. * The position of the object in babylon space.
  13208. */
  13209. position: Vector3;
  13210. /**
  13211. * The rotation quaternion of the object in babylon space.
  13212. */
  13213. rotationQuaternion: Quaternion;
  13214. /**
  13215. * The position of the device in babylon space.
  13216. */
  13217. devicePosition?: Vector3;
  13218. /**
  13219. * The rotation quaternion of the device in babylon space.
  13220. */
  13221. deviceRotationQuaternion: Quaternion;
  13222. /**
  13223. * The raw pose coming from the device.
  13224. */
  13225. rawPose: Nullable<DevicePose>;
  13226. /**
  13227. * The scale of the device to be used when translating from device space to babylon space.
  13228. */
  13229. deviceScaleFactor: number;
  13230. /**
  13231. * Updates the poseControlled values based on the input device pose.
  13232. * @param poseData the pose data to update the object with
  13233. */
  13234. updateFromDevice(poseData: DevicePose): void;
  13235. }
  13236. /**
  13237. * Set of options to customize the webVRCamera
  13238. */
  13239. export interface WebVROptions {
  13240. /**
  13241. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13242. */
  13243. trackPosition?: boolean;
  13244. /**
  13245. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13246. */
  13247. positionScale?: number;
  13248. /**
  13249. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13250. */
  13251. displayName?: string;
  13252. /**
  13253. * Should the native controller meshes be initialized. (default: true)
  13254. */
  13255. controllerMeshes?: boolean;
  13256. /**
  13257. * Creating a default HemiLight only on controllers. (default: true)
  13258. */
  13259. defaultLightingOnControllers?: boolean;
  13260. /**
  13261. * If you don't want to use the default VR button of the helper. (default: false)
  13262. */
  13263. useCustomVRButton?: boolean;
  13264. /**
  13265. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13266. */
  13267. customVRButton?: HTMLButtonElement;
  13268. /**
  13269. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13270. */
  13271. rayLength?: number;
  13272. /**
  13273. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13274. */
  13275. defaultHeight?: number;
  13276. /**
  13277. * If multiview should be used if availible (default: false)
  13278. */
  13279. useMultiview?: boolean;
  13280. }
  13281. /**
  13282. * This represents a WebVR camera.
  13283. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13284. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13285. */
  13286. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13287. private webVROptions;
  13288. /**
  13289. * @hidden
  13290. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13291. */
  13292. _vrDevice: any;
  13293. /**
  13294. * The rawPose of the vrDevice.
  13295. */
  13296. rawPose: Nullable<DevicePose>;
  13297. private _onVREnabled;
  13298. private _specsVersion;
  13299. private _attached;
  13300. private _frameData;
  13301. protected _descendants: Array<Node>;
  13302. private _deviceRoomPosition;
  13303. /** @hidden */
  13304. _deviceRoomRotationQuaternion: Quaternion;
  13305. private _standingMatrix;
  13306. /**
  13307. * Represents device position in babylon space.
  13308. */
  13309. devicePosition: Vector3;
  13310. /**
  13311. * Represents device rotation in babylon space.
  13312. */
  13313. deviceRotationQuaternion: Quaternion;
  13314. /**
  13315. * The scale of the device to be used when translating from device space to babylon space.
  13316. */
  13317. deviceScaleFactor: number;
  13318. private _deviceToWorld;
  13319. private _worldToDevice;
  13320. /**
  13321. * References to the webVR controllers for the vrDevice.
  13322. */
  13323. controllers: Array<WebVRController>;
  13324. /**
  13325. * Emits an event when a controller is attached.
  13326. */
  13327. onControllersAttachedObservable: Observable<WebVRController[]>;
  13328. /**
  13329. * Emits an event when a controller's mesh has been loaded;
  13330. */
  13331. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13332. /**
  13333. * Emits an event when the HMD's pose has been updated.
  13334. */
  13335. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13336. private _poseSet;
  13337. /**
  13338. * If the rig cameras be used as parent instead of this camera.
  13339. */
  13340. rigParenting: boolean;
  13341. private _lightOnControllers;
  13342. private _defaultHeight?;
  13343. /**
  13344. * Instantiates a WebVRFreeCamera.
  13345. * @param name The name of the WebVRFreeCamera
  13346. * @param position The starting anchor position for the camera
  13347. * @param scene The scene the camera belongs to
  13348. * @param webVROptions a set of customizable options for the webVRCamera
  13349. */
  13350. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13351. /**
  13352. * Gets the device distance from the ground in meters.
  13353. * @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.
  13354. */
  13355. deviceDistanceToRoomGround(): number;
  13356. /**
  13357. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13358. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13359. */
  13360. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13361. /**
  13362. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13363. * @returns A promise with a boolean set to if the standing matrix is supported.
  13364. */
  13365. useStandingMatrixAsync(): Promise<boolean>;
  13366. /**
  13367. * Disposes the camera
  13368. */
  13369. dispose(): void;
  13370. /**
  13371. * Gets a vrController by name.
  13372. * @param name The name of the controller to retreive
  13373. * @returns the controller matching the name specified or null if not found
  13374. */
  13375. getControllerByName(name: string): Nullable<WebVRController>;
  13376. private _leftController;
  13377. /**
  13378. * The controller corrisponding to the users left hand.
  13379. */
  13380. readonly leftController: Nullable<WebVRController>;
  13381. private _rightController;
  13382. /**
  13383. * The controller corrisponding to the users right hand.
  13384. */
  13385. readonly rightController: Nullable<WebVRController>;
  13386. /**
  13387. * Casts a ray forward from the vrCamera's gaze.
  13388. * @param length Length of the ray (default: 100)
  13389. * @returns the ray corrisponding to the gaze
  13390. */
  13391. getForwardRay(length?: number): Ray;
  13392. /**
  13393. * @hidden
  13394. * Updates the camera based on device's frame data
  13395. */
  13396. _checkInputs(): void;
  13397. /**
  13398. * Updates the poseControlled values based on the input device pose.
  13399. * @param poseData Pose coming from the device
  13400. */
  13401. updateFromDevice(poseData: DevicePose): void;
  13402. private _htmlElementAttached;
  13403. private _detachIfAttached;
  13404. /**
  13405. * WebVR's attach control will start broadcasting frames to the device.
  13406. * Note that in certain browsers (chrome for example) this function must be called
  13407. * within a user-interaction callback. Example:
  13408. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13409. *
  13410. * @param element html element to attach the vrDevice to
  13411. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13412. */
  13413. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13414. /**
  13415. * Detaches the camera from the html element and disables VR
  13416. *
  13417. * @param element html element to detach from
  13418. */
  13419. detachControl(element: HTMLElement): void;
  13420. /**
  13421. * @returns the name of this class
  13422. */
  13423. getClassName(): string;
  13424. /**
  13425. * Calls resetPose on the vrDisplay
  13426. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13427. */
  13428. resetToCurrentRotation(): void;
  13429. /**
  13430. * @hidden
  13431. * Updates the rig cameras (left and right eye)
  13432. */
  13433. _updateRigCameras(): void;
  13434. private _workingVector;
  13435. private _oneVector;
  13436. private _workingMatrix;
  13437. private updateCacheCalled;
  13438. private _correctPositionIfNotTrackPosition;
  13439. /**
  13440. * @hidden
  13441. * Updates the cached values of the camera
  13442. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13443. */
  13444. _updateCache(ignoreParentClass?: boolean): void;
  13445. /**
  13446. * @hidden
  13447. * Get current device position in babylon world
  13448. */
  13449. _computeDevicePosition(): void;
  13450. /**
  13451. * Updates the current device position and rotation in the babylon world
  13452. */
  13453. update(): void;
  13454. /**
  13455. * @hidden
  13456. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13457. * @returns an identity matrix
  13458. */
  13459. _getViewMatrix(): Matrix;
  13460. private _tmpMatrix;
  13461. /**
  13462. * This function is called by the two RIG cameras.
  13463. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13464. * @hidden
  13465. */
  13466. _getWebVRViewMatrix(): Matrix;
  13467. /** @hidden */
  13468. _getWebVRProjectionMatrix(): Matrix;
  13469. private _onGamepadConnectedObserver;
  13470. private _onGamepadDisconnectedObserver;
  13471. private _updateCacheWhenTrackingDisabledObserver;
  13472. /**
  13473. * Initializes the controllers and their meshes
  13474. */
  13475. initControllers(): void;
  13476. }
  13477. }
  13478. declare module BABYLON {
  13479. /**
  13480. * Size options for a post process
  13481. */
  13482. export type PostProcessOptions = {
  13483. width: number;
  13484. height: number;
  13485. };
  13486. /**
  13487. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13488. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13489. */
  13490. export class PostProcess {
  13491. /** Name of the PostProcess. */
  13492. name: string;
  13493. /**
  13494. * Gets or sets the unique id of the post process
  13495. */
  13496. uniqueId: number;
  13497. /**
  13498. * Width of the texture to apply the post process on
  13499. */
  13500. width: number;
  13501. /**
  13502. * Height of the texture to apply the post process on
  13503. */
  13504. height: number;
  13505. /**
  13506. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13507. * @hidden
  13508. */
  13509. _outputTexture: Nullable<InternalTexture>;
  13510. /**
  13511. * Sampling mode used by the shader
  13512. * See https://doc.babylonjs.com/classes/3.1/texture
  13513. */
  13514. renderTargetSamplingMode: number;
  13515. /**
  13516. * Clear color to use when screen clearing
  13517. */
  13518. clearColor: Color4;
  13519. /**
  13520. * If the buffer needs to be cleared before applying the post process. (default: true)
  13521. * Should be set to false if shader will overwrite all previous pixels.
  13522. */
  13523. autoClear: boolean;
  13524. /**
  13525. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13526. */
  13527. alphaMode: number;
  13528. /**
  13529. * Sets the setAlphaBlendConstants of the babylon engine
  13530. */
  13531. alphaConstants: Color4;
  13532. /**
  13533. * Animations to be used for the post processing
  13534. */
  13535. animations: Animation[];
  13536. /**
  13537. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13538. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13539. */
  13540. enablePixelPerfectMode: boolean;
  13541. /**
  13542. * Force the postprocess to be applied without taking in account viewport
  13543. */
  13544. forceFullscreenViewport: boolean;
  13545. /**
  13546. * List of inspectable custom properties (used by the Inspector)
  13547. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13548. */
  13549. inspectableCustomProperties: IInspectable[];
  13550. /**
  13551. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13552. *
  13553. * | Value | Type | Description |
  13554. * | ----- | ----------------------------------- | ----------- |
  13555. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13556. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13557. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13558. *
  13559. */
  13560. scaleMode: number;
  13561. /**
  13562. * Force textures to be a power of two (default: false)
  13563. */
  13564. alwaysForcePOT: boolean;
  13565. private _samples;
  13566. /**
  13567. * Number of sample textures (default: 1)
  13568. */
  13569. samples: number;
  13570. /**
  13571. * Modify the scale of the post process to be the same as the viewport (default: false)
  13572. */
  13573. adaptScaleToCurrentViewport: boolean;
  13574. private _camera;
  13575. private _scene;
  13576. private _engine;
  13577. private _options;
  13578. private _reusable;
  13579. private _textureType;
  13580. /**
  13581. * Smart array of input and output textures for the post process.
  13582. * @hidden
  13583. */
  13584. _textures: SmartArray<InternalTexture>;
  13585. /**
  13586. * The index in _textures that corresponds to the output texture.
  13587. * @hidden
  13588. */
  13589. _currentRenderTextureInd: number;
  13590. private _effect;
  13591. private _samplers;
  13592. private _fragmentUrl;
  13593. private _vertexUrl;
  13594. private _parameters;
  13595. private _scaleRatio;
  13596. protected _indexParameters: any;
  13597. private _shareOutputWithPostProcess;
  13598. private _texelSize;
  13599. private _forcedOutputTexture;
  13600. /**
  13601. * Returns the fragment url or shader name used in the post process.
  13602. * @returns the fragment url or name in the shader store.
  13603. */
  13604. getEffectName(): string;
  13605. /**
  13606. * An event triggered when the postprocess is activated.
  13607. */
  13608. onActivateObservable: Observable<Camera>;
  13609. private _onActivateObserver;
  13610. /**
  13611. * A function that is added to the onActivateObservable
  13612. */
  13613. onActivate: Nullable<(camera: Camera) => void>;
  13614. /**
  13615. * An event triggered when the postprocess changes its size.
  13616. */
  13617. onSizeChangedObservable: Observable<PostProcess>;
  13618. private _onSizeChangedObserver;
  13619. /**
  13620. * A function that is added to the onSizeChangedObservable
  13621. */
  13622. onSizeChanged: (postProcess: PostProcess) => void;
  13623. /**
  13624. * An event triggered when the postprocess applies its effect.
  13625. */
  13626. onApplyObservable: Observable<Effect>;
  13627. private _onApplyObserver;
  13628. /**
  13629. * A function that is added to the onApplyObservable
  13630. */
  13631. onApply: (effect: Effect) => void;
  13632. /**
  13633. * An event triggered before rendering the postprocess
  13634. */
  13635. onBeforeRenderObservable: Observable<Effect>;
  13636. private _onBeforeRenderObserver;
  13637. /**
  13638. * A function that is added to the onBeforeRenderObservable
  13639. */
  13640. onBeforeRender: (effect: Effect) => void;
  13641. /**
  13642. * An event triggered after rendering the postprocess
  13643. */
  13644. onAfterRenderObservable: Observable<Effect>;
  13645. private _onAfterRenderObserver;
  13646. /**
  13647. * A function that is added to the onAfterRenderObservable
  13648. */
  13649. onAfterRender: (efect: Effect) => void;
  13650. /**
  13651. * 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
  13652. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13653. */
  13654. inputTexture: InternalTexture;
  13655. /**
  13656. * Gets the camera which post process is applied to.
  13657. * @returns The camera the post process is applied to.
  13658. */
  13659. getCamera(): Camera;
  13660. /**
  13661. * Gets the texel size of the postprocess.
  13662. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13663. */
  13664. readonly texelSize: Vector2;
  13665. /**
  13666. * Creates a new instance PostProcess
  13667. * @param name The name of the PostProcess.
  13668. * @param fragmentUrl The url of the fragment shader to be used.
  13669. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13670. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13671. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13672. * @param camera The camera to apply the render pass to.
  13673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13674. * @param engine The engine which the post process will be applied. (default: current engine)
  13675. * @param reusable If the post process can be reused on the same frame. (default: false)
  13676. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13677. * @param textureType Type of textures used when performing the post process. (default: 0)
  13678. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13679. * @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
  13680. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13681. */
  13682. constructor(
  13683. /** Name of the PostProcess. */
  13684. 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);
  13685. /**
  13686. * Gets a string idenfifying the name of the class
  13687. * @returns "PostProcess" string
  13688. */
  13689. getClassName(): string;
  13690. /**
  13691. * Gets the engine which this post process belongs to.
  13692. * @returns The engine the post process was enabled with.
  13693. */
  13694. getEngine(): Engine;
  13695. /**
  13696. * The effect that is created when initializing the post process.
  13697. * @returns The created effect corrisponding the the postprocess.
  13698. */
  13699. getEffect(): Effect;
  13700. /**
  13701. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13702. * @param postProcess The post process to share the output with.
  13703. * @returns This post process.
  13704. */
  13705. shareOutputWith(postProcess: PostProcess): PostProcess;
  13706. /**
  13707. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13708. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13709. */
  13710. useOwnOutput(): void;
  13711. /**
  13712. * Updates the effect with the current post process compile time values and recompiles the shader.
  13713. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13714. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13715. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13716. * @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
  13717. * @param onCompiled Called when the shader has been compiled.
  13718. * @param onError Called if there is an error when compiling a shader.
  13719. */
  13720. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13721. /**
  13722. * The post process is reusable if it can be used multiple times within one frame.
  13723. * @returns If the post process is reusable
  13724. */
  13725. isReusable(): boolean;
  13726. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13727. markTextureDirty(): void;
  13728. /**
  13729. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13730. * 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.
  13731. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13732. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13733. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13734. * @returns The target texture that was bound to be written to.
  13735. */
  13736. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13737. /**
  13738. * If the post process is supported.
  13739. */
  13740. readonly isSupported: boolean;
  13741. /**
  13742. * The aspect ratio of the output texture.
  13743. */
  13744. readonly aspectRatio: number;
  13745. /**
  13746. * Get a value indicating if the post-process is ready to be used
  13747. * @returns true if the post-process is ready (shader is compiled)
  13748. */
  13749. isReady(): boolean;
  13750. /**
  13751. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13752. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13753. */
  13754. apply(): Nullable<Effect>;
  13755. private _disposeTextures;
  13756. /**
  13757. * Disposes the post process.
  13758. * @param camera The camera to dispose the post process on.
  13759. */
  13760. dispose(camera?: Camera): void;
  13761. }
  13762. }
  13763. declare module BABYLON {
  13764. /**
  13765. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13766. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13767. */
  13768. export class PostProcessManager {
  13769. private _scene;
  13770. private _indexBuffer;
  13771. private _vertexBuffers;
  13772. /**
  13773. * Creates a new instance PostProcess
  13774. * @param scene The scene that the post process is associated with.
  13775. */
  13776. constructor(scene: Scene);
  13777. private _prepareBuffers;
  13778. private _buildIndexBuffer;
  13779. /**
  13780. * Rebuilds the vertex buffers of the manager.
  13781. * @hidden
  13782. */
  13783. _rebuild(): void;
  13784. /**
  13785. * Prepares a frame to be run through a post process.
  13786. * @param sourceTexture The input texture to the post procesess. (default: null)
  13787. * @param postProcesses An array of post processes to be run. (default: null)
  13788. * @returns True if the post processes were able to be run.
  13789. * @hidden
  13790. */
  13791. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13792. /**
  13793. * Manually render a set of post processes to a texture.
  13794. * @param postProcesses An array of post processes to be run.
  13795. * @param targetTexture The target texture to render to.
  13796. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13797. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13798. * @param lodLevel defines which lod of the texture to render to
  13799. */
  13800. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13801. /**
  13802. * Finalize the result of the output of the postprocesses.
  13803. * @param doNotPresent If true the result will not be displayed to the screen.
  13804. * @param targetTexture The target texture to render to.
  13805. * @param faceIndex The index of the face to bind the target texture to.
  13806. * @param postProcesses The array of post processes to render.
  13807. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13808. * @hidden
  13809. */
  13810. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13811. /**
  13812. * Disposes of the post process manager.
  13813. */
  13814. dispose(): void;
  13815. }
  13816. }
  13817. declare module BABYLON {
  13818. interface AbstractScene {
  13819. /**
  13820. * The list of layers (background and foreground) of the scene
  13821. */
  13822. layers: Array<Layer>;
  13823. }
  13824. /**
  13825. * Defines the layer scene component responsible to manage any layers
  13826. * in a given scene.
  13827. */
  13828. export class LayerSceneComponent implements ISceneComponent {
  13829. /**
  13830. * The component name helpfull to identify the component in the list of scene components.
  13831. */
  13832. readonly name: string;
  13833. /**
  13834. * The scene the component belongs to.
  13835. */
  13836. scene: Scene;
  13837. private _engine;
  13838. /**
  13839. * Creates a new instance of the component for the given scene
  13840. * @param scene Defines the scene to register the component in
  13841. */
  13842. constructor(scene: Scene);
  13843. /**
  13844. * Registers the component in a given scene
  13845. */
  13846. register(): void;
  13847. /**
  13848. * Rebuilds the elements related to this component in case of
  13849. * context lost for instance.
  13850. */
  13851. rebuild(): void;
  13852. /**
  13853. * Disposes the component and the associated ressources.
  13854. */
  13855. dispose(): void;
  13856. private _draw;
  13857. private _drawCameraPredicate;
  13858. private _drawCameraBackground;
  13859. private _drawCameraForeground;
  13860. private _drawRenderTargetPredicate;
  13861. private _drawRenderTargetBackground;
  13862. private _drawRenderTargetForeground;
  13863. }
  13864. }
  13865. declare module BABYLON {
  13866. /** @hidden */
  13867. export var layerPixelShader: {
  13868. name: string;
  13869. shader: string;
  13870. };
  13871. }
  13872. declare module BABYLON {
  13873. /** @hidden */
  13874. export var layerVertexShader: {
  13875. name: string;
  13876. shader: string;
  13877. };
  13878. }
  13879. declare module BABYLON {
  13880. /**
  13881. * This represents a full screen 2d layer.
  13882. * This can be useful to display a picture in the background of your scene for instance.
  13883. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13884. */
  13885. export class Layer {
  13886. /**
  13887. * Define the name of the layer.
  13888. */
  13889. name: string;
  13890. /**
  13891. * Define the texture the layer should display.
  13892. */
  13893. texture: Nullable<Texture>;
  13894. /**
  13895. * Is the layer in background or foreground.
  13896. */
  13897. isBackground: boolean;
  13898. /**
  13899. * Define the color of the layer (instead of texture).
  13900. */
  13901. color: Color4;
  13902. /**
  13903. * Define the scale of the layer in order to zoom in out of the texture.
  13904. */
  13905. scale: Vector2;
  13906. /**
  13907. * Define an offset for the layer in order to shift the texture.
  13908. */
  13909. offset: Vector2;
  13910. /**
  13911. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13912. */
  13913. alphaBlendingMode: number;
  13914. /**
  13915. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13916. * Alpha test will not mix with the background color in case of transparency.
  13917. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13918. */
  13919. alphaTest: boolean;
  13920. /**
  13921. * Define a mask to restrict the layer to only some of the scene cameras.
  13922. */
  13923. layerMask: number;
  13924. /**
  13925. * Define the list of render target the layer is visible into.
  13926. */
  13927. renderTargetTextures: RenderTargetTexture[];
  13928. /**
  13929. * Define if the layer is only used in renderTarget or if it also
  13930. * renders in the main frame buffer of the canvas.
  13931. */
  13932. renderOnlyInRenderTargetTextures: boolean;
  13933. private _scene;
  13934. private _vertexBuffers;
  13935. private _indexBuffer;
  13936. private _effect;
  13937. private _alphaTestEffect;
  13938. /**
  13939. * An event triggered when the layer is disposed.
  13940. */
  13941. onDisposeObservable: Observable<Layer>;
  13942. private _onDisposeObserver;
  13943. /**
  13944. * Back compatibility with callback before the onDisposeObservable existed.
  13945. * The set callback will be triggered when the layer has been disposed.
  13946. */
  13947. onDispose: () => void;
  13948. /**
  13949. * An event triggered before rendering the scene
  13950. */
  13951. onBeforeRenderObservable: Observable<Layer>;
  13952. private _onBeforeRenderObserver;
  13953. /**
  13954. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13955. * The set callback will be triggered just before rendering the layer.
  13956. */
  13957. onBeforeRender: () => void;
  13958. /**
  13959. * An event triggered after rendering the scene
  13960. */
  13961. onAfterRenderObservable: Observable<Layer>;
  13962. private _onAfterRenderObserver;
  13963. /**
  13964. * Back compatibility with callback before the onAfterRenderObservable existed.
  13965. * The set callback will be triggered just after rendering the layer.
  13966. */
  13967. onAfterRender: () => void;
  13968. /**
  13969. * Instantiates a new layer.
  13970. * This represents a full screen 2d layer.
  13971. * This can be useful to display a picture in the background of your scene for instance.
  13972. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13973. * @param name Define the name of the layer in the scene
  13974. * @param imgUrl Define the url of the texture to display in the layer
  13975. * @param scene Define the scene the layer belongs to
  13976. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13977. * @param color Defines a color for the layer
  13978. */
  13979. constructor(
  13980. /**
  13981. * Define the name of the layer.
  13982. */
  13983. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13984. private _createIndexBuffer;
  13985. /** @hidden */
  13986. _rebuild(): void;
  13987. /**
  13988. * Renders the layer in the scene.
  13989. */
  13990. render(): void;
  13991. /**
  13992. * Disposes and releases the associated ressources.
  13993. */
  13994. dispose(): void;
  13995. }
  13996. }
  13997. declare module BABYLON {
  13998. interface AbstractScene {
  13999. /**
  14000. * The list of procedural textures added to the scene
  14001. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14002. */
  14003. proceduralTextures: Array<ProceduralTexture>;
  14004. }
  14005. /**
  14006. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14007. * in a given scene.
  14008. */
  14009. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14010. /**
  14011. * The component name helpfull to identify the component in the list of scene components.
  14012. */
  14013. readonly name: string;
  14014. /**
  14015. * The scene the component belongs to.
  14016. */
  14017. scene: Scene;
  14018. /**
  14019. * Creates a new instance of the component for the given scene
  14020. * @param scene Defines the scene to register the component in
  14021. */
  14022. constructor(scene: Scene);
  14023. /**
  14024. * Registers the component in a given scene
  14025. */
  14026. register(): void;
  14027. /**
  14028. * Rebuilds the elements related to this component in case of
  14029. * context lost for instance.
  14030. */
  14031. rebuild(): void;
  14032. /**
  14033. * Disposes the component and the associated ressources.
  14034. */
  14035. dispose(): void;
  14036. private _beforeClear;
  14037. }
  14038. }
  14039. declare module BABYLON {
  14040. interface Engine {
  14041. /**
  14042. * Creates a new render target cube texture
  14043. * @param size defines the size of the texture
  14044. * @param options defines the options used to create the texture
  14045. * @returns a new render target cube texture stored in an InternalTexture
  14046. */
  14047. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14048. }
  14049. }
  14050. declare module BABYLON {
  14051. /** @hidden */
  14052. export var proceduralVertexShader: {
  14053. name: string;
  14054. shader: string;
  14055. };
  14056. }
  14057. declare module BABYLON {
  14058. /**
  14059. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  14060. * This is the base class of any Procedural texture and contains most of the shareable code.
  14061. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14062. */
  14063. export class ProceduralTexture extends Texture {
  14064. isCube: boolean;
  14065. /**
  14066. * Define if the texture is enabled or not (disabled texture will not render)
  14067. */
  14068. isEnabled: boolean;
  14069. /**
  14070. * Define if the texture must be cleared before rendering (default is true)
  14071. */
  14072. autoClear: boolean;
  14073. /**
  14074. * Callback called when the texture is generated
  14075. */
  14076. onGenerated: () => void;
  14077. /**
  14078. * Event raised when the texture is generated
  14079. */
  14080. onGeneratedObservable: Observable<ProceduralTexture>;
  14081. /** @hidden */
  14082. _generateMipMaps: boolean;
  14083. /** @hidden **/
  14084. _effect: Effect;
  14085. /** @hidden */
  14086. _textures: {
  14087. [key: string]: Texture;
  14088. };
  14089. private _size;
  14090. private _currentRefreshId;
  14091. private _refreshRate;
  14092. private _vertexBuffers;
  14093. private _indexBuffer;
  14094. private _uniforms;
  14095. private _samplers;
  14096. private _fragment;
  14097. private _floats;
  14098. private _ints;
  14099. private _floatsArrays;
  14100. private _colors3;
  14101. private _colors4;
  14102. private _vectors2;
  14103. private _vectors3;
  14104. private _matrices;
  14105. private _fallbackTexture;
  14106. private _fallbackTextureUsed;
  14107. private _engine;
  14108. private _cachedDefines;
  14109. private _contentUpdateId;
  14110. private _contentData;
  14111. /**
  14112. * Instantiates a new procedural texture.
  14113. * 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.
  14114. * This is the base class of any Procedural texture and contains most of the shareable code.
  14115. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14116. * @param name Define the name of the texture
  14117. * @param size Define the size of the texture to create
  14118. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14119. * @param scene Define the scene the texture belongs to
  14120. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14121. * @param generateMipMaps Define if the texture should creates mip maps or not
  14122. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14123. */
  14124. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14125. /**
  14126. * The effect that is created when initializing the post process.
  14127. * @returns The created effect corrisponding the the postprocess.
  14128. */
  14129. getEffect(): Effect;
  14130. /**
  14131. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14132. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14133. */
  14134. getContent(): Nullable<ArrayBufferView>;
  14135. private _createIndexBuffer;
  14136. /** @hidden */
  14137. _rebuild(): void;
  14138. /**
  14139. * Resets the texture in order to recreate its associated resources.
  14140. * This can be called in case of context loss
  14141. */
  14142. reset(): void;
  14143. protected _getDefines(): string;
  14144. /**
  14145. * Is the texture ready to be used ? (rendered at least once)
  14146. * @returns true if ready, otherwise, false.
  14147. */
  14148. isReady(): boolean;
  14149. /**
  14150. * Resets the refresh counter of the texture and start bak from scratch.
  14151. * Could be useful to regenerate the texture if it is setup to render only once.
  14152. */
  14153. resetRefreshCounter(): void;
  14154. /**
  14155. * Set the fragment shader to use in order to render the texture.
  14156. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14157. */
  14158. setFragment(fragment: any): void;
  14159. /**
  14160. * Define the refresh rate of the texture or the rendering frequency.
  14161. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14162. */
  14163. refreshRate: number;
  14164. /** @hidden */
  14165. _shouldRender(): boolean;
  14166. /**
  14167. * Get the size the texture is rendering at.
  14168. * @returns the size (texture is always squared)
  14169. */
  14170. getRenderSize(): number;
  14171. /**
  14172. * Resize the texture to new value.
  14173. * @param size Define the new size the texture should have
  14174. * @param generateMipMaps Define whether the new texture should create mip maps
  14175. */
  14176. resize(size: number, generateMipMaps: boolean): void;
  14177. private _checkUniform;
  14178. /**
  14179. * Set a texture in the shader program used to render.
  14180. * @param name Define the name of the uniform samplers as defined in the shader
  14181. * @param texture Define the texture to bind to this sampler
  14182. * @return the texture itself allowing "fluent" like uniform updates
  14183. */
  14184. setTexture(name: string, texture: Texture): ProceduralTexture;
  14185. /**
  14186. * Set a float in the shader.
  14187. * @param name Define the name of the uniform as defined in the shader
  14188. * @param value Define the value to give to the uniform
  14189. * @return the texture itself allowing "fluent" like uniform updates
  14190. */
  14191. setFloat(name: string, value: number): ProceduralTexture;
  14192. /**
  14193. * Set a int in the shader.
  14194. * @param name Define the name of the uniform as defined in the shader
  14195. * @param value Define the value to give to the uniform
  14196. * @return the texture itself allowing "fluent" like uniform updates
  14197. */
  14198. setInt(name: string, value: number): ProceduralTexture;
  14199. /**
  14200. * Set an array of floats in the shader.
  14201. * @param name Define the name of the uniform as defined in the shader
  14202. * @param value Define the value to give to the uniform
  14203. * @return the texture itself allowing "fluent" like uniform updates
  14204. */
  14205. setFloats(name: string, value: number[]): ProceduralTexture;
  14206. /**
  14207. * Set a vec3 in the shader from a Color3.
  14208. * @param name Define the name of the uniform as defined in the shader
  14209. * @param value Define the value to give to the uniform
  14210. * @return the texture itself allowing "fluent" like uniform updates
  14211. */
  14212. setColor3(name: string, value: Color3): ProceduralTexture;
  14213. /**
  14214. * Set a vec4 in the shader from a Color4.
  14215. * @param name Define the name of the uniform as defined in the shader
  14216. * @param value Define the value to give to the uniform
  14217. * @return the texture itself allowing "fluent" like uniform updates
  14218. */
  14219. setColor4(name: string, value: Color4): ProceduralTexture;
  14220. /**
  14221. * Set a vec2 in the shader from a Vector2.
  14222. * @param name Define the name of the uniform as defined in the shader
  14223. * @param value Define the value to give to the uniform
  14224. * @return the texture itself allowing "fluent" like uniform updates
  14225. */
  14226. setVector2(name: string, value: Vector2): ProceduralTexture;
  14227. /**
  14228. * Set a vec3 in the shader from a Vector3.
  14229. * @param name Define the name of the uniform as defined in the shader
  14230. * @param value Define the value to give to the uniform
  14231. * @return the texture itself allowing "fluent" like uniform updates
  14232. */
  14233. setVector3(name: string, value: Vector3): ProceduralTexture;
  14234. /**
  14235. * Set a mat4 in the shader from a MAtrix.
  14236. * @param name Define the name of the uniform as defined in the shader
  14237. * @param value Define the value to give to the uniform
  14238. * @return the texture itself allowing "fluent" like uniform updates
  14239. */
  14240. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14241. /**
  14242. * Render the texture to its associated render target.
  14243. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14244. */
  14245. render(useCameraPostProcess?: boolean): void;
  14246. /**
  14247. * Clone the texture.
  14248. * @returns the cloned texture
  14249. */
  14250. clone(): ProceduralTexture;
  14251. /**
  14252. * Dispose the texture and release its asoociated resources.
  14253. */
  14254. dispose(): void;
  14255. }
  14256. }
  14257. declare module BABYLON {
  14258. /**
  14259. * This represents the base class for particle system in Babylon.
  14260. * 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.
  14261. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14262. * @example https://doc.babylonjs.com/babylon101/particles
  14263. */
  14264. export class BaseParticleSystem {
  14265. /**
  14266. * Source color is added to the destination color without alpha affecting the result
  14267. */
  14268. static BLENDMODE_ONEONE: number;
  14269. /**
  14270. * Blend current color and particle color using particle’s alpha
  14271. */
  14272. static BLENDMODE_STANDARD: number;
  14273. /**
  14274. * Add current color and particle color multiplied by particle’s alpha
  14275. */
  14276. static BLENDMODE_ADD: number;
  14277. /**
  14278. * Multiply current color with particle color
  14279. */
  14280. static BLENDMODE_MULTIPLY: number;
  14281. /**
  14282. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14283. */
  14284. static BLENDMODE_MULTIPLYADD: number;
  14285. /**
  14286. * List of animations used by the particle system.
  14287. */
  14288. animations: Animation[];
  14289. /**
  14290. * The id of the Particle system.
  14291. */
  14292. id: string;
  14293. /**
  14294. * The friendly name of the Particle system.
  14295. */
  14296. name: string;
  14297. /**
  14298. * The rendering group used by the Particle system to chose when to render.
  14299. */
  14300. renderingGroupId: number;
  14301. /**
  14302. * The emitter represents the Mesh or position we are attaching the particle system to.
  14303. */
  14304. emitter: Nullable<AbstractMesh | Vector3>;
  14305. /**
  14306. * The maximum number of particles to emit per frame
  14307. */
  14308. emitRate: number;
  14309. /**
  14310. * If you want to launch only a few particles at once, that can be done, as well.
  14311. */
  14312. manualEmitCount: number;
  14313. /**
  14314. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14315. */
  14316. updateSpeed: number;
  14317. /**
  14318. * The amount of time the particle system is running (depends of the overall update speed).
  14319. */
  14320. targetStopDuration: number;
  14321. /**
  14322. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14323. */
  14324. disposeOnStop: boolean;
  14325. /**
  14326. * Minimum power of emitting particles.
  14327. */
  14328. minEmitPower: number;
  14329. /**
  14330. * Maximum power of emitting particles.
  14331. */
  14332. maxEmitPower: number;
  14333. /**
  14334. * Minimum life time of emitting particles.
  14335. */
  14336. minLifeTime: number;
  14337. /**
  14338. * Maximum life time of emitting particles.
  14339. */
  14340. maxLifeTime: number;
  14341. /**
  14342. * Minimum Size of emitting particles.
  14343. */
  14344. minSize: number;
  14345. /**
  14346. * Maximum Size of emitting particles.
  14347. */
  14348. maxSize: number;
  14349. /**
  14350. * Minimum scale of emitting particles on X axis.
  14351. */
  14352. minScaleX: number;
  14353. /**
  14354. * Maximum scale of emitting particles on X axis.
  14355. */
  14356. maxScaleX: number;
  14357. /**
  14358. * Minimum scale of emitting particles on Y axis.
  14359. */
  14360. minScaleY: number;
  14361. /**
  14362. * Maximum scale of emitting particles on Y axis.
  14363. */
  14364. maxScaleY: number;
  14365. /**
  14366. * Gets or sets the minimal initial rotation in radians.
  14367. */
  14368. minInitialRotation: number;
  14369. /**
  14370. * Gets or sets the maximal initial rotation in radians.
  14371. */
  14372. maxInitialRotation: number;
  14373. /**
  14374. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14375. */
  14376. minAngularSpeed: number;
  14377. /**
  14378. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14379. */
  14380. maxAngularSpeed: number;
  14381. /**
  14382. * The texture used to render each particle. (this can be a spritesheet)
  14383. */
  14384. particleTexture: Nullable<Texture>;
  14385. /**
  14386. * The layer mask we are rendering the particles through.
  14387. */
  14388. layerMask: number;
  14389. /**
  14390. * This can help using your own shader to render the particle system.
  14391. * The according effect will be created
  14392. */
  14393. customShader: any;
  14394. /**
  14395. * By default particle system starts as soon as they are created. This prevents the
  14396. * automatic start to happen and let you decide when to start emitting particles.
  14397. */
  14398. preventAutoStart: boolean;
  14399. private _noiseTexture;
  14400. /**
  14401. * Gets or sets a texture used to add random noise to particle positions
  14402. */
  14403. noiseTexture: Nullable<ProceduralTexture>;
  14404. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14405. noiseStrength: Vector3;
  14406. /**
  14407. * Callback triggered when the particle animation is ending.
  14408. */
  14409. onAnimationEnd: Nullable<() => void>;
  14410. /**
  14411. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14412. */
  14413. blendMode: number;
  14414. /**
  14415. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14416. * to override the particles.
  14417. */
  14418. forceDepthWrite: boolean;
  14419. /** 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 */
  14420. preWarmCycles: number;
  14421. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14422. preWarmStepOffset: number;
  14423. /**
  14424. * 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)
  14425. */
  14426. spriteCellChangeSpeed: number;
  14427. /**
  14428. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14429. */
  14430. startSpriteCellID: number;
  14431. /**
  14432. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14433. */
  14434. endSpriteCellID: number;
  14435. /**
  14436. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14437. */
  14438. spriteCellWidth: number;
  14439. /**
  14440. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14441. */
  14442. spriteCellHeight: number;
  14443. /**
  14444. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14445. */
  14446. spriteRandomStartCell: boolean;
  14447. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14448. translationPivot: Vector2;
  14449. /** @hidden */
  14450. protected _isAnimationSheetEnabled: boolean;
  14451. /**
  14452. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14453. */
  14454. beginAnimationOnStart: boolean;
  14455. /**
  14456. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14457. */
  14458. beginAnimationFrom: number;
  14459. /**
  14460. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14461. */
  14462. beginAnimationTo: number;
  14463. /**
  14464. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14465. */
  14466. beginAnimationLoop: boolean;
  14467. /**
  14468. * Gets or sets a world offset applied to all particles
  14469. */
  14470. worldOffset: Vector3;
  14471. /**
  14472. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14473. */
  14474. isAnimationSheetEnabled: boolean;
  14475. /**
  14476. * Get hosting scene
  14477. * @returns the scene
  14478. */
  14479. getScene(): Scene;
  14480. /**
  14481. * You can use gravity if you want to give an orientation to your particles.
  14482. */
  14483. gravity: Vector3;
  14484. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14485. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14486. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14487. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14488. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14489. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14490. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14491. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14492. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14493. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14494. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14495. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14496. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14497. /**
  14498. * Defines the delay in milliseconds before starting the system (0 by default)
  14499. */
  14500. startDelay: number;
  14501. /**
  14502. * Gets the current list of drag gradients.
  14503. * You must use addDragGradient and removeDragGradient to udpate this list
  14504. * @returns the list of drag gradients
  14505. */
  14506. getDragGradients(): Nullable<Array<FactorGradient>>;
  14507. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14508. limitVelocityDamping: number;
  14509. /**
  14510. * Gets the current list of limit velocity gradients.
  14511. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14512. * @returns the list of limit velocity gradients
  14513. */
  14514. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14515. /**
  14516. * Gets the current list of color gradients.
  14517. * You must use addColorGradient and removeColorGradient to udpate this list
  14518. * @returns the list of color gradients
  14519. */
  14520. getColorGradients(): Nullable<Array<ColorGradient>>;
  14521. /**
  14522. * Gets the current list of size gradients.
  14523. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14524. * @returns the list of size gradients
  14525. */
  14526. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14527. /**
  14528. * Gets the current list of color remap gradients.
  14529. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14530. * @returns the list of color remap gradients
  14531. */
  14532. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14533. /**
  14534. * Gets the current list of alpha remap gradients.
  14535. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14536. * @returns the list of alpha remap gradients
  14537. */
  14538. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14539. /**
  14540. * Gets the current list of life time gradients.
  14541. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14542. * @returns the list of life time gradients
  14543. */
  14544. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14545. /**
  14546. * Gets the current list of angular speed gradients.
  14547. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14548. * @returns the list of angular speed gradients
  14549. */
  14550. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14551. /**
  14552. * Gets the current list of velocity gradients.
  14553. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14554. * @returns the list of velocity gradients
  14555. */
  14556. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14557. /**
  14558. * Gets the current list of start size gradients.
  14559. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14560. * @returns the list of start size gradients
  14561. */
  14562. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14563. /**
  14564. * Gets the current list of emit rate gradients.
  14565. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14566. * @returns the list of emit rate gradients
  14567. */
  14568. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14569. /**
  14570. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14571. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14572. */
  14573. direction1: Vector3;
  14574. /**
  14575. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14576. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14577. */
  14578. direction2: Vector3;
  14579. /**
  14580. * 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.
  14581. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14582. */
  14583. minEmitBox: Vector3;
  14584. /**
  14585. * 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.
  14586. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14587. */
  14588. maxEmitBox: Vector3;
  14589. /**
  14590. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14591. */
  14592. color1: Color4;
  14593. /**
  14594. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14595. */
  14596. color2: Color4;
  14597. /**
  14598. * Color the particle will have at the end of its lifetime
  14599. */
  14600. colorDead: Color4;
  14601. /**
  14602. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14603. */
  14604. textureMask: Color4;
  14605. /**
  14606. * The particle emitter type defines the emitter used by the particle system.
  14607. * It can be for example box, sphere, or cone...
  14608. */
  14609. particleEmitterType: IParticleEmitterType;
  14610. /** @hidden */
  14611. _isSubEmitter: boolean;
  14612. /**
  14613. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14614. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14615. */
  14616. billboardMode: number;
  14617. protected _isBillboardBased: boolean;
  14618. /**
  14619. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14620. */
  14621. isBillboardBased: boolean;
  14622. /**
  14623. * The scene the particle system belongs to.
  14624. */
  14625. protected _scene: Scene;
  14626. /**
  14627. * Local cache of defines for image processing.
  14628. */
  14629. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14630. /**
  14631. * Default configuration related to image processing available in the standard Material.
  14632. */
  14633. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14634. /**
  14635. * Gets the image processing configuration used either in this material.
  14636. */
  14637. /**
  14638. * Sets the Default image processing configuration used either in the this material.
  14639. *
  14640. * If sets to null, the scene one is in use.
  14641. */
  14642. imageProcessingConfiguration: ImageProcessingConfiguration;
  14643. /**
  14644. * Attaches a new image processing configuration to the Standard Material.
  14645. * @param configuration
  14646. */
  14647. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14648. /** @hidden */
  14649. protected _reset(): void;
  14650. /** @hidden */
  14651. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14652. /**
  14653. * Instantiates a particle system.
  14654. * 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.
  14655. * @param name The name of the particle system
  14656. */
  14657. constructor(name: string);
  14658. /**
  14659. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14660. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14661. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14662. * @returns the emitter
  14663. */
  14664. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14665. /**
  14666. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14667. * @param radius The radius of the hemisphere to emit from
  14668. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14669. * @returns the emitter
  14670. */
  14671. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14672. /**
  14673. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14674. * @param radius The radius of the sphere to emit from
  14675. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14676. * @returns the emitter
  14677. */
  14678. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14679. /**
  14680. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14681. * @param radius The radius of the sphere to emit from
  14682. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14683. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14684. * @returns the emitter
  14685. */
  14686. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14687. /**
  14688. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14689. * @param radius The radius of the emission cylinder
  14690. * @param height The height of the emission cylinder
  14691. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14692. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14693. * @returns the emitter
  14694. */
  14695. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14696. /**
  14697. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14698. * @param radius The radius of the cylinder to emit from
  14699. * @param height The height of the emission cylinder
  14700. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14701. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14702. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14703. * @returns the emitter
  14704. */
  14705. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14706. /**
  14707. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14708. * @param radius The radius of the cone to emit from
  14709. * @param angle The base angle of the cone
  14710. * @returns the emitter
  14711. */
  14712. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14713. /**
  14714. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14715. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14716. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14717. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14718. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14719. * @returns the emitter
  14720. */
  14721. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14722. }
  14723. }
  14724. declare module BABYLON {
  14725. /**
  14726. * Type of sub emitter
  14727. */
  14728. export enum SubEmitterType {
  14729. /**
  14730. * Attached to the particle over it's lifetime
  14731. */
  14732. ATTACHED = 0,
  14733. /**
  14734. * Created when the particle dies
  14735. */
  14736. END = 1
  14737. }
  14738. /**
  14739. * Sub emitter class used to emit particles from an existing particle
  14740. */
  14741. export class SubEmitter {
  14742. /**
  14743. * the particle system to be used by the sub emitter
  14744. */
  14745. particleSystem: ParticleSystem;
  14746. /**
  14747. * Type of the submitter (Default: END)
  14748. */
  14749. type: SubEmitterType;
  14750. /**
  14751. * 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)
  14752. * Note: This only is supported when using an emitter of type Mesh
  14753. */
  14754. inheritDirection: boolean;
  14755. /**
  14756. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14757. */
  14758. inheritedVelocityAmount: number;
  14759. /**
  14760. * Creates a sub emitter
  14761. * @param particleSystem the particle system to be used by the sub emitter
  14762. */
  14763. constructor(
  14764. /**
  14765. * the particle system to be used by the sub emitter
  14766. */
  14767. particleSystem: ParticleSystem);
  14768. /**
  14769. * Clones the sub emitter
  14770. * @returns the cloned sub emitter
  14771. */
  14772. clone(): SubEmitter;
  14773. /**
  14774. * Serialize current object to a JSON object
  14775. * @returns the serialized object
  14776. */
  14777. serialize(): any;
  14778. /** @hidden */
  14779. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14780. /**
  14781. * Creates a new SubEmitter from a serialized JSON version
  14782. * @param serializationObject defines the JSON object to read from
  14783. * @param scene defines the hosting scene
  14784. * @param rootUrl defines the rootUrl for data loading
  14785. * @returns a new SubEmitter
  14786. */
  14787. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14788. /** Release associated resources */
  14789. dispose(): void;
  14790. }
  14791. }
  14792. declare module BABYLON {
  14793. /** @hidden */
  14794. export var clipPlaneFragmentDeclaration: {
  14795. name: string;
  14796. shader: string;
  14797. };
  14798. }
  14799. declare module BABYLON {
  14800. /** @hidden */
  14801. export var imageProcessingDeclaration: {
  14802. name: string;
  14803. shader: string;
  14804. };
  14805. }
  14806. declare module BABYLON {
  14807. /** @hidden */
  14808. export var imageProcessingFunctions: {
  14809. name: string;
  14810. shader: string;
  14811. };
  14812. }
  14813. declare module BABYLON {
  14814. /** @hidden */
  14815. export var clipPlaneFragment: {
  14816. name: string;
  14817. shader: string;
  14818. };
  14819. }
  14820. declare module BABYLON {
  14821. /** @hidden */
  14822. export var particlesPixelShader: {
  14823. name: string;
  14824. shader: string;
  14825. };
  14826. }
  14827. declare module BABYLON {
  14828. /** @hidden */
  14829. export var clipPlaneVertexDeclaration: {
  14830. name: string;
  14831. shader: string;
  14832. };
  14833. }
  14834. declare module BABYLON {
  14835. /** @hidden */
  14836. export var clipPlaneVertex: {
  14837. name: string;
  14838. shader: string;
  14839. };
  14840. }
  14841. declare module BABYLON {
  14842. /** @hidden */
  14843. export var particlesVertexShader: {
  14844. name: string;
  14845. shader: string;
  14846. };
  14847. }
  14848. declare module BABYLON {
  14849. /**
  14850. * This represents a particle system in Babylon.
  14851. * 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.
  14852. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14853. * @example https://doc.babylonjs.com/babylon101/particles
  14854. */
  14855. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14856. /**
  14857. * Billboard mode will only apply to Y axis
  14858. */
  14859. static readonly BILLBOARDMODE_Y: number;
  14860. /**
  14861. * Billboard mode will apply to all axes
  14862. */
  14863. static readonly BILLBOARDMODE_ALL: number;
  14864. /**
  14865. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14866. */
  14867. static readonly BILLBOARDMODE_STRETCHED: number;
  14868. /**
  14869. * This function can be defined to provide custom update for active particles.
  14870. * This function will be called instead of regular update (age, position, color, etc.).
  14871. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14872. */
  14873. updateFunction: (particles: Particle[]) => void;
  14874. private _emitterWorldMatrix;
  14875. /**
  14876. * This function can be defined to specify initial direction for every new particle.
  14877. * It by default use the emitterType defined function
  14878. */
  14879. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14880. /**
  14881. * This function can be defined to specify initial position for every new particle.
  14882. * It by default use the emitterType defined function
  14883. */
  14884. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14885. /**
  14886. * @hidden
  14887. */
  14888. _inheritedVelocityOffset: Vector3;
  14889. /**
  14890. * An event triggered when the system is disposed
  14891. */
  14892. onDisposeObservable: Observable<ParticleSystem>;
  14893. private _onDisposeObserver;
  14894. /**
  14895. * Sets a callback that will be triggered when the system is disposed
  14896. */
  14897. onDispose: () => void;
  14898. private _particles;
  14899. private _epsilon;
  14900. private _capacity;
  14901. private _stockParticles;
  14902. private _newPartsExcess;
  14903. private _vertexData;
  14904. private _vertexBuffer;
  14905. private _vertexBuffers;
  14906. private _spriteBuffer;
  14907. private _indexBuffer;
  14908. private _effect;
  14909. private _customEffect;
  14910. private _cachedDefines;
  14911. private _scaledColorStep;
  14912. private _colorDiff;
  14913. private _scaledDirection;
  14914. private _scaledGravity;
  14915. private _currentRenderId;
  14916. private _alive;
  14917. private _useInstancing;
  14918. private _started;
  14919. private _stopped;
  14920. private _actualFrame;
  14921. private _scaledUpdateSpeed;
  14922. private _vertexBufferSize;
  14923. /** @hidden */
  14924. _currentEmitRateGradient: Nullable<FactorGradient>;
  14925. /** @hidden */
  14926. _currentEmitRate1: number;
  14927. /** @hidden */
  14928. _currentEmitRate2: number;
  14929. /** @hidden */
  14930. _currentStartSizeGradient: Nullable<FactorGradient>;
  14931. /** @hidden */
  14932. _currentStartSize1: number;
  14933. /** @hidden */
  14934. _currentStartSize2: number;
  14935. private readonly _rawTextureWidth;
  14936. private _rampGradientsTexture;
  14937. private _useRampGradients;
  14938. /** Gets or sets a boolean indicating that ramp gradients must be used
  14939. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14940. */
  14941. useRampGradients: boolean;
  14942. /**
  14943. * 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.
  14944. * 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: [])
  14945. */
  14946. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14947. private _subEmitters;
  14948. /**
  14949. * @hidden
  14950. * If the particle systems emitter should be disposed when the particle system is disposed
  14951. */
  14952. _disposeEmitterOnDispose: boolean;
  14953. /**
  14954. * The current active Sub-systems, this property is used by the root particle system only.
  14955. */
  14956. activeSubSystems: Array<ParticleSystem>;
  14957. private _rootParticleSystem;
  14958. /**
  14959. * Gets the current list of active particles
  14960. */
  14961. readonly particles: Particle[];
  14962. /**
  14963. * Returns the string "ParticleSystem"
  14964. * @returns a string containing the class name
  14965. */
  14966. getClassName(): string;
  14967. /**
  14968. * Instantiates a particle system.
  14969. * 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.
  14970. * @param name The name of the particle system
  14971. * @param capacity The max number of particles alive at the same time
  14972. * @param scene The scene the particle system belongs to
  14973. * @param customEffect a custom effect used to change the way particles are rendered by default
  14974. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14975. * @param epsilon Offset used to render the particles
  14976. */
  14977. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14978. private _addFactorGradient;
  14979. private _removeFactorGradient;
  14980. /**
  14981. * Adds a new life time gradient
  14982. * @param gradient defines the gradient to use (between 0 and 1)
  14983. * @param factor defines the life time factor to affect to the specified gradient
  14984. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14985. * @returns the current particle system
  14986. */
  14987. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14988. /**
  14989. * Remove a specific life time gradient
  14990. * @param gradient defines the gradient to remove
  14991. * @returns the current particle system
  14992. */
  14993. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14994. /**
  14995. * Adds a new size gradient
  14996. * @param gradient defines the gradient to use (between 0 and 1)
  14997. * @param factor defines the size factor to affect to the specified gradient
  14998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14999. * @returns the current particle system
  15000. */
  15001. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15002. /**
  15003. * Remove a specific size gradient
  15004. * @param gradient defines the gradient to remove
  15005. * @returns the current particle system
  15006. */
  15007. removeSizeGradient(gradient: number): IParticleSystem;
  15008. /**
  15009. * Adds a new color remap gradient
  15010. * @param gradient defines the gradient to use (between 0 and 1)
  15011. * @param min defines the color remap minimal range
  15012. * @param max defines the color remap maximal range
  15013. * @returns the current particle system
  15014. */
  15015. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15016. /**
  15017. * Remove a specific color remap gradient
  15018. * @param gradient defines the gradient to remove
  15019. * @returns the current particle system
  15020. */
  15021. removeColorRemapGradient(gradient: number): IParticleSystem;
  15022. /**
  15023. * Adds a new alpha remap gradient
  15024. * @param gradient defines the gradient to use (between 0 and 1)
  15025. * @param min defines the alpha remap minimal range
  15026. * @param max defines the alpha remap maximal range
  15027. * @returns the current particle system
  15028. */
  15029. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15030. /**
  15031. * Remove a specific alpha remap gradient
  15032. * @param gradient defines the gradient to remove
  15033. * @returns the current particle system
  15034. */
  15035. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15036. /**
  15037. * Adds a new angular speed gradient
  15038. * @param gradient defines the gradient to use (between 0 and 1)
  15039. * @param factor defines the angular speed to affect to the specified gradient
  15040. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15041. * @returns the current particle system
  15042. */
  15043. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15044. /**
  15045. * Remove a specific angular speed gradient
  15046. * @param gradient defines the gradient to remove
  15047. * @returns the current particle system
  15048. */
  15049. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15050. /**
  15051. * Adds a new velocity gradient
  15052. * @param gradient defines the gradient to use (between 0 and 1)
  15053. * @param factor defines the velocity to affect to the specified gradient
  15054. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15055. * @returns the current particle system
  15056. */
  15057. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15058. /**
  15059. * Remove a specific velocity gradient
  15060. * @param gradient defines the gradient to remove
  15061. * @returns the current particle system
  15062. */
  15063. removeVelocityGradient(gradient: number): IParticleSystem;
  15064. /**
  15065. * Adds a new limit velocity gradient
  15066. * @param gradient defines the gradient to use (between 0 and 1)
  15067. * @param factor defines the limit velocity value to affect to the specified gradient
  15068. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15069. * @returns the current particle system
  15070. */
  15071. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15072. /**
  15073. * Remove a specific limit velocity gradient
  15074. * @param gradient defines the gradient to remove
  15075. * @returns the current particle system
  15076. */
  15077. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15078. /**
  15079. * Adds a new drag gradient
  15080. * @param gradient defines the gradient to use (between 0 and 1)
  15081. * @param factor defines the drag value to affect to the specified gradient
  15082. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15083. * @returns the current particle system
  15084. */
  15085. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15086. /**
  15087. * Remove a specific drag gradient
  15088. * @param gradient defines the gradient to remove
  15089. * @returns the current particle system
  15090. */
  15091. removeDragGradient(gradient: number): IParticleSystem;
  15092. /**
  15093. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15094. * @param gradient defines the gradient to use (between 0 and 1)
  15095. * @param factor defines the emit rate value to affect to the specified gradient
  15096. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15097. * @returns the current particle system
  15098. */
  15099. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15100. /**
  15101. * Remove a specific emit rate gradient
  15102. * @param gradient defines the gradient to remove
  15103. * @returns the current particle system
  15104. */
  15105. removeEmitRateGradient(gradient: number): IParticleSystem;
  15106. /**
  15107. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15108. * @param gradient defines the gradient to use (between 0 and 1)
  15109. * @param factor defines the start size value to affect to the specified gradient
  15110. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15111. * @returns the current particle system
  15112. */
  15113. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15114. /**
  15115. * Remove a specific start size gradient
  15116. * @param gradient defines the gradient to remove
  15117. * @returns the current particle system
  15118. */
  15119. removeStartSizeGradient(gradient: number): IParticleSystem;
  15120. private _createRampGradientTexture;
  15121. /**
  15122. * Gets the current list of ramp gradients.
  15123. * You must use addRampGradient and removeRampGradient to udpate this list
  15124. * @returns the list of ramp gradients
  15125. */
  15126. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15127. /**
  15128. * Adds a new ramp gradient used to remap particle colors
  15129. * @param gradient defines the gradient to use (between 0 and 1)
  15130. * @param color defines the color to affect to the specified gradient
  15131. * @returns the current particle system
  15132. */
  15133. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15134. /**
  15135. * Remove a specific ramp gradient
  15136. * @param gradient defines the gradient to remove
  15137. * @returns the current particle system
  15138. */
  15139. removeRampGradient(gradient: number): ParticleSystem;
  15140. /**
  15141. * Adds a new color gradient
  15142. * @param gradient defines the gradient to use (between 0 and 1)
  15143. * @param color1 defines the color to affect to the specified gradient
  15144. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15145. * @returns this particle system
  15146. */
  15147. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15148. /**
  15149. * Remove a specific color gradient
  15150. * @param gradient defines the gradient to remove
  15151. * @returns this particle system
  15152. */
  15153. removeColorGradient(gradient: number): IParticleSystem;
  15154. private _fetchR;
  15155. protected _reset(): void;
  15156. private _resetEffect;
  15157. private _createVertexBuffers;
  15158. private _createIndexBuffer;
  15159. /**
  15160. * Gets the maximum number of particles active at the same time.
  15161. * @returns The max number of active particles.
  15162. */
  15163. getCapacity(): number;
  15164. /**
  15165. * Gets whether there are still active particles in the system.
  15166. * @returns True if it is alive, otherwise false.
  15167. */
  15168. isAlive(): boolean;
  15169. /**
  15170. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15171. * @returns True if it has been started, otherwise false.
  15172. */
  15173. isStarted(): boolean;
  15174. private _prepareSubEmitterInternalArray;
  15175. /**
  15176. * Starts the particle system and begins to emit
  15177. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15178. */
  15179. start(delay?: number): void;
  15180. /**
  15181. * Stops the particle system.
  15182. * @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.
  15183. */
  15184. stop(stopSubEmitters?: boolean): void;
  15185. /**
  15186. * Remove all active particles
  15187. */
  15188. reset(): void;
  15189. /**
  15190. * @hidden (for internal use only)
  15191. */
  15192. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15193. /**
  15194. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15195. * Its lifetime will start back at 0.
  15196. */
  15197. recycleParticle: (particle: Particle) => void;
  15198. private _stopSubEmitters;
  15199. private _createParticle;
  15200. private _removeFromRoot;
  15201. private _emitFromParticle;
  15202. private _update;
  15203. /** @hidden */
  15204. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15205. /** @hidden */
  15206. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15207. /** @hidden */
  15208. private _getEffect;
  15209. /**
  15210. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15211. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15212. */
  15213. animate(preWarmOnly?: boolean): void;
  15214. private _appendParticleVertices;
  15215. /**
  15216. * Rebuilds the particle system.
  15217. */
  15218. rebuild(): void;
  15219. /**
  15220. * Is this system ready to be used/rendered
  15221. * @return true if the system is ready
  15222. */
  15223. isReady(): boolean;
  15224. private _render;
  15225. /**
  15226. * Renders the particle system in its current state.
  15227. * @returns the current number of particles
  15228. */
  15229. render(): number;
  15230. /**
  15231. * Disposes the particle system and free the associated resources
  15232. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15233. */
  15234. dispose(disposeTexture?: boolean): void;
  15235. /**
  15236. * Clones the particle system.
  15237. * @param name The name of the cloned object
  15238. * @param newEmitter The new emitter to use
  15239. * @returns the cloned particle system
  15240. */
  15241. clone(name: string, newEmitter: any): ParticleSystem;
  15242. /**
  15243. * Serializes the particle system to a JSON object.
  15244. * @returns the JSON object
  15245. */
  15246. serialize(): any;
  15247. /** @hidden */
  15248. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15249. /** @hidden */
  15250. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15251. /**
  15252. * Parses a JSON object to create a particle system.
  15253. * @param parsedParticleSystem The JSON object to parse
  15254. * @param scene The scene to create the particle system in
  15255. * @param rootUrl The root url to use to load external dependencies like texture
  15256. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15257. * @returns the Parsed particle system
  15258. */
  15259. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15260. }
  15261. }
  15262. declare module BABYLON {
  15263. /**
  15264. * A particle represents one of the element emitted by a particle system.
  15265. * This is mainly define by its coordinates, direction, velocity and age.
  15266. */
  15267. export class Particle {
  15268. /**
  15269. * The particle system the particle belongs to.
  15270. */
  15271. particleSystem: ParticleSystem;
  15272. private static _Count;
  15273. /**
  15274. * Unique ID of the particle
  15275. */
  15276. id: number;
  15277. /**
  15278. * The world position of the particle in the scene.
  15279. */
  15280. position: Vector3;
  15281. /**
  15282. * The world direction of the particle in the scene.
  15283. */
  15284. direction: Vector3;
  15285. /**
  15286. * The color of the particle.
  15287. */
  15288. color: Color4;
  15289. /**
  15290. * The color change of the particle per step.
  15291. */
  15292. colorStep: Color4;
  15293. /**
  15294. * Defines how long will the life of the particle be.
  15295. */
  15296. lifeTime: number;
  15297. /**
  15298. * The current age of the particle.
  15299. */
  15300. age: number;
  15301. /**
  15302. * The current size of the particle.
  15303. */
  15304. size: number;
  15305. /**
  15306. * The current scale of the particle.
  15307. */
  15308. scale: Vector2;
  15309. /**
  15310. * The current angle of the particle.
  15311. */
  15312. angle: number;
  15313. /**
  15314. * Defines how fast is the angle changing.
  15315. */
  15316. angularSpeed: number;
  15317. /**
  15318. * Defines the cell index used by the particle to be rendered from a sprite.
  15319. */
  15320. cellIndex: number;
  15321. /**
  15322. * The information required to support color remapping
  15323. */
  15324. remapData: Vector4;
  15325. /** @hidden */
  15326. _randomCellOffset?: number;
  15327. /** @hidden */
  15328. _initialDirection: Nullable<Vector3>;
  15329. /** @hidden */
  15330. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15331. /** @hidden */
  15332. _initialStartSpriteCellID: number;
  15333. /** @hidden */
  15334. _initialEndSpriteCellID: number;
  15335. /** @hidden */
  15336. _currentColorGradient: Nullable<ColorGradient>;
  15337. /** @hidden */
  15338. _currentColor1: Color4;
  15339. /** @hidden */
  15340. _currentColor2: Color4;
  15341. /** @hidden */
  15342. _currentSizeGradient: Nullable<FactorGradient>;
  15343. /** @hidden */
  15344. _currentSize1: number;
  15345. /** @hidden */
  15346. _currentSize2: number;
  15347. /** @hidden */
  15348. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15349. /** @hidden */
  15350. _currentAngularSpeed1: number;
  15351. /** @hidden */
  15352. _currentAngularSpeed2: number;
  15353. /** @hidden */
  15354. _currentVelocityGradient: Nullable<FactorGradient>;
  15355. /** @hidden */
  15356. _currentVelocity1: number;
  15357. /** @hidden */
  15358. _currentVelocity2: number;
  15359. /** @hidden */
  15360. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15361. /** @hidden */
  15362. _currentLimitVelocity1: number;
  15363. /** @hidden */
  15364. _currentLimitVelocity2: number;
  15365. /** @hidden */
  15366. _currentDragGradient: Nullable<FactorGradient>;
  15367. /** @hidden */
  15368. _currentDrag1: number;
  15369. /** @hidden */
  15370. _currentDrag2: number;
  15371. /** @hidden */
  15372. _randomNoiseCoordinates1: Vector3;
  15373. /** @hidden */
  15374. _randomNoiseCoordinates2: Vector3;
  15375. /**
  15376. * Creates a new instance Particle
  15377. * @param particleSystem the particle system the particle belongs to
  15378. */
  15379. constructor(
  15380. /**
  15381. * The particle system the particle belongs to.
  15382. */
  15383. particleSystem: ParticleSystem);
  15384. private updateCellInfoFromSystem;
  15385. /**
  15386. * Defines how the sprite cell index is updated for the particle
  15387. */
  15388. updateCellIndex(): void;
  15389. /** @hidden */
  15390. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15391. /** @hidden */
  15392. _inheritParticleInfoToSubEmitters(): void;
  15393. /** @hidden */
  15394. _reset(): void;
  15395. /**
  15396. * Copy the properties of particle to another one.
  15397. * @param other the particle to copy the information to.
  15398. */
  15399. copyTo(other: Particle): void;
  15400. }
  15401. }
  15402. declare module BABYLON {
  15403. /**
  15404. * Particle emitter represents a volume emitting particles.
  15405. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15406. */
  15407. export interface IParticleEmitterType {
  15408. /**
  15409. * Called by the particle System when the direction is computed for the created particle.
  15410. * @param worldMatrix is the world matrix of the particle system
  15411. * @param directionToUpdate is the direction vector to update with the result
  15412. * @param particle is the particle we are computed the direction for
  15413. */
  15414. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15415. /**
  15416. * Called by the particle System when the position is computed for the created particle.
  15417. * @param worldMatrix is the world matrix of the particle system
  15418. * @param positionToUpdate is the position vector to update with the result
  15419. * @param particle is the particle we are computed the position for
  15420. */
  15421. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15422. /**
  15423. * Clones the current emitter and returns a copy of it
  15424. * @returns the new emitter
  15425. */
  15426. clone(): IParticleEmitterType;
  15427. /**
  15428. * Called by the GPUParticleSystem to setup the update shader
  15429. * @param effect defines the update shader
  15430. */
  15431. applyToShader(effect: Effect): void;
  15432. /**
  15433. * Returns a string to use to update the GPU particles update shader
  15434. * @returns the effect defines string
  15435. */
  15436. getEffectDefines(): string;
  15437. /**
  15438. * Returns a string representing the class name
  15439. * @returns a string containing the class name
  15440. */
  15441. getClassName(): string;
  15442. /**
  15443. * Serializes the particle system to a JSON object.
  15444. * @returns the JSON object
  15445. */
  15446. serialize(): any;
  15447. /**
  15448. * Parse properties from a JSON object
  15449. * @param serializationObject defines the JSON object
  15450. */
  15451. parse(serializationObject: any): void;
  15452. }
  15453. }
  15454. declare module BABYLON {
  15455. /**
  15456. * Particle emitter emitting particles from the inside of a box.
  15457. * It emits the particles randomly between 2 given directions.
  15458. */
  15459. export class BoxParticleEmitter implements IParticleEmitterType {
  15460. /**
  15461. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15462. */
  15463. direction1: Vector3;
  15464. /**
  15465. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15466. */
  15467. direction2: Vector3;
  15468. /**
  15469. * 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.
  15470. */
  15471. minEmitBox: Vector3;
  15472. /**
  15473. * 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.
  15474. */
  15475. maxEmitBox: Vector3;
  15476. /**
  15477. * Creates a new instance BoxParticleEmitter
  15478. */
  15479. constructor();
  15480. /**
  15481. * Called by the particle System when the direction is computed for the created particle.
  15482. * @param worldMatrix is the world matrix of the particle system
  15483. * @param directionToUpdate is the direction vector to update with the result
  15484. * @param particle is the particle we are computed the direction for
  15485. */
  15486. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15487. /**
  15488. * Called by the particle System when the position is computed for the created particle.
  15489. * @param worldMatrix is the world matrix of the particle system
  15490. * @param positionToUpdate is the position vector to update with the result
  15491. * @param particle is the particle we are computed the position for
  15492. */
  15493. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15494. /**
  15495. * Clones the current emitter and returns a copy of it
  15496. * @returns the new emitter
  15497. */
  15498. clone(): BoxParticleEmitter;
  15499. /**
  15500. * Called by the GPUParticleSystem to setup the update shader
  15501. * @param effect defines the update shader
  15502. */
  15503. applyToShader(effect: Effect): void;
  15504. /**
  15505. * Returns a string to use to update the GPU particles update shader
  15506. * @returns a string containng the defines string
  15507. */
  15508. getEffectDefines(): string;
  15509. /**
  15510. * Returns the string "BoxParticleEmitter"
  15511. * @returns a string containing the class name
  15512. */
  15513. getClassName(): string;
  15514. /**
  15515. * Serializes the particle system to a JSON object.
  15516. * @returns the JSON object
  15517. */
  15518. serialize(): any;
  15519. /**
  15520. * Parse properties from a JSON object
  15521. * @param serializationObject defines the JSON object
  15522. */
  15523. parse(serializationObject: any): void;
  15524. }
  15525. }
  15526. declare module BABYLON {
  15527. /**
  15528. * Particle emitter emitting particles from the inside of a cone.
  15529. * It emits the particles alongside the cone volume from the base to the particle.
  15530. * The emission direction might be randomized.
  15531. */
  15532. export class ConeParticleEmitter implements IParticleEmitterType {
  15533. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15534. directionRandomizer: number;
  15535. private _radius;
  15536. private _angle;
  15537. private _height;
  15538. /**
  15539. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15540. */
  15541. radiusRange: number;
  15542. /**
  15543. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15544. */
  15545. heightRange: number;
  15546. /**
  15547. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15548. */
  15549. emitFromSpawnPointOnly: boolean;
  15550. /**
  15551. * Gets or sets the radius of the emission cone
  15552. */
  15553. radius: number;
  15554. /**
  15555. * Gets or sets the angle of the emission cone
  15556. */
  15557. angle: number;
  15558. private _buildHeight;
  15559. /**
  15560. * Creates a new instance ConeParticleEmitter
  15561. * @param radius the radius of the emission cone (1 by default)
  15562. * @param angle the cone base angle (PI by default)
  15563. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15564. */
  15565. constructor(radius?: number, angle?: number,
  15566. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15567. directionRandomizer?: number);
  15568. /**
  15569. * Called by the particle System when the direction is computed for the created particle.
  15570. * @param worldMatrix is the world matrix of the particle system
  15571. * @param directionToUpdate is the direction vector to update with the result
  15572. * @param particle is the particle we are computed the direction for
  15573. */
  15574. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15575. /**
  15576. * Called by the particle System when the position is computed for the created particle.
  15577. * @param worldMatrix is the world matrix of the particle system
  15578. * @param positionToUpdate is the position vector to update with the result
  15579. * @param particle is the particle we are computed the position for
  15580. */
  15581. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15582. /**
  15583. * Clones the current emitter and returns a copy of it
  15584. * @returns the new emitter
  15585. */
  15586. clone(): ConeParticleEmitter;
  15587. /**
  15588. * Called by the GPUParticleSystem to setup the update shader
  15589. * @param effect defines the update shader
  15590. */
  15591. applyToShader(effect: Effect): void;
  15592. /**
  15593. * Returns a string to use to update the GPU particles update shader
  15594. * @returns a string containng the defines string
  15595. */
  15596. getEffectDefines(): string;
  15597. /**
  15598. * Returns the string "ConeParticleEmitter"
  15599. * @returns a string containing the class name
  15600. */
  15601. getClassName(): string;
  15602. /**
  15603. * Serializes the particle system to a JSON object.
  15604. * @returns the JSON object
  15605. */
  15606. serialize(): any;
  15607. /**
  15608. * Parse properties from a JSON object
  15609. * @param serializationObject defines the JSON object
  15610. */
  15611. parse(serializationObject: any): void;
  15612. }
  15613. }
  15614. declare module BABYLON {
  15615. /**
  15616. * Particle emitter emitting particles from the inside of a cylinder.
  15617. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15618. */
  15619. export class CylinderParticleEmitter implements IParticleEmitterType {
  15620. /**
  15621. * The radius of the emission cylinder.
  15622. */
  15623. radius: number;
  15624. /**
  15625. * The height of the emission cylinder.
  15626. */
  15627. height: number;
  15628. /**
  15629. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15630. */
  15631. radiusRange: number;
  15632. /**
  15633. * How much to randomize the particle direction [0-1].
  15634. */
  15635. directionRandomizer: number;
  15636. /**
  15637. * Creates a new instance CylinderParticleEmitter
  15638. * @param radius the radius of the emission cylinder (1 by default)
  15639. * @param height the height of the emission cylinder (1 by default)
  15640. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15641. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15642. */
  15643. constructor(
  15644. /**
  15645. * The radius of the emission cylinder.
  15646. */
  15647. radius?: number,
  15648. /**
  15649. * The height of the emission cylinder.
  15650. */
  15651. height?: number,
  15652. /**
  15653. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15654. */
  15655. radiusRange?: number,
  15656. /**
  15657. * How much to randomize the particle direction [0-1].
  15658. */
  15659. directionRandomizer?: number);
  15660. /**
  15661. * Called by the particle System when the direction is computed for the created particle.
  15662. * @param worldMatrix is the world matrix of the particle system
  15663. * @param directionToUpdate is the direction vector to update with the result
  15664. * @param particle is the particle we are computed the direction for
  15665. */
  15666. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15667. /**
  15668. * Called by the particle System when the position is computed for the created particle.
  15669. * @param worldMatrix is the world matrix of the particle system
  15670. * @param positionToUpdate is the position vector to update with the result
  15671. * @param particle is the particle we are computed the position for
  15672. */
  15673. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15674. /**
  15675. * Clones the current emitter and returns a copy of it
  15676. * @returns the new emitter
  15677. */
  15678. clone(): CylinderParticleEmitter;
  15679. /**
  15680. * Called by the GPUParticleSystem to setup the update shader
  15681. * @param effect defines the update shader
  15682. */
  15683. applyToShader(effect: Effect): void;
  15684. /**
  15685. * Returns a string to use to update the GPU particles update shader
  15686. * @returns a string containng the defines string
  15687. */
  15688. getEffectDefines(): string;
  15689. /**
  15690. * Returns the string "CylinderParticleEmitter"
  15691. * @returns a string containing the class name
  15692. */
  15693. getClassName(): string;
  15694. /**
  15695. * Serializes the particle system to a JSON object.
  15696. * @returns the JSON object
  15697. */
  15698. serialize(): any;
  15699. /**
  15700. * Parse properties from a JSON object
  15701. * @param serializationObject defines the JSON object
  15702. */
  15703. parse(serializationObject: any): void;
  15704. }
  15705. /**
  15706. * Particle emitter emitting particles from the inside of a cylinder.
  15707. * It emits the particles randomly between two vectors.
  15708. */
  15709. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15710. /**
  15711. * The min limit of the emission direction.
  15712. */
  15713. direction1: Vector3;
  15714. /**
  15715. * The max limit of the emission direction.
  15716. */
  15717. direction2: Vector3;
  15718. /**
  15719. * Creates a new instance CylinderDirectedParticleEmitter
  15720. * @param radius the radius of the emission cylinder (1 by default)
  15721. * @param height the height of the emission cylinder (1 by default)
  15722. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15723. * @param direction1 the min limit of the emission direction (up vector by default)
  15724. * @param direction2 the max limit of the emission direction (up vector by default)
  15725. */
  15726. constructor(radius?: number, height?: number, radiusRange?: number,
  15727. /**
  15728. * The min limit of the emission direction.
  15729. */
  15730. direction1?: Vector3,
  15731. /**
  15732. * The max limit of the emission direction.
  15733. */
  15734. direction2?: Vector3);
  15735. /**
  15736. * Called by the particle System when the direction is computed for the created particle.
  15737. * @param worldMatrix is the world matrix of the particle system
  15738. * @param directionToUpdate is the direction vector to update with the result
  15739. * @param particle is the particle we are computed the direction for
  15740. */
  15741. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15742. /**
  15743. * Clones the current emitter and returns a copy of it
  15744. * @returns the new emitter
  15745. */
  15746. clone(): CylinderDirectedParticleEmitter;
  15747. /**
  15748. * Called by the GPUParticleSystem to setup the update shader
  15749. * @param effect defines the update shader
  15750. */
  15751. applyToShader(effect: Effect): void;
  15752. /**
  15753. * Returns a string to use to update the GPU particles update shader
  15754. * @returns a string containng the defines string
  15755. */
  15756. getEffectDefines(): string;
  15757. /**
  15758. * Returns the string "CylinderDirectedParticleEmitter"
  15759. * @returns a string containing the class name
  15760. */
  15761. getClassName(): string;
  15762. /**
  15763. * Serializes the particle system to a JSON object.
  15764. * @returns the JSON object
  15765. */
  15766. serialize(): any;
  15767. /**
  15768. * Parse properties from a JSON object
  15769. * @param serializationObject defines the JSON object
  15770. */
  15771. parse(serializationObject: any): void;
  15772. }
  15773. }
  15774. declare module BABYLON {
  15775. /**
  15776. * Particle emitter emitting particles from the inside of a hemisphere.
  15777. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15778. */
  15779. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15780. /**
  15781. * The radius of the emission hemisphere.
  15782. */
  15783. radius: number;
  15784. /**
  15785. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15786. */
  15787. radiusRange: number;
  15788. /**
  15789. * How much to randomize the particle direction [0-1].
  15790. */
  15791. directionRandomizer: number;
  15792. /**
  15793. * Creates a new instance HemisphericParticleEmitter
  15794. * @param radius the radius of the emission hemisphere (1 by default)
  15795. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15796. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15797. */
  15798. constructor(
  15799. /**
  15800. * The radius of the emission hemisphere.
  15801. */
  15802. radius?: number,
  15803. /**
  15804. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15805. */
  15806. radiusRange?: number,
  15807. /**
  15808. * How much to randomize the particle direction [0-1].
  15809. */
  15810. directionRandomizer?: number);
  15811. /**
  15812. * Called by the particle System when the direction is computed for the created particle.
  15813. * @param worldMatrix is the world matrix of the particle system
  15814. * @param directionToUpdate is the direction vector to update with the result
  15815. * @param particle is the particle we are computed the direction for
  15816. */
  15817. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15818. /**
  15819. * Called by the particle System when the position is computed for the created particle.
  15820. * @param worldMatrix is the world matrix of the particle system
  15821. * @param positionToUpdate is the position vector to update with the result
  15822. * @param particle is the particle we are computed the position for
  15823. */
  15824. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15825. /**
  15826. * Clones the current emitter and returns a copy of it
  15827. * @returns the new emitter
  15828. */
  15829. clone(): HemisphericParticleEmitter;
  15830. /**
  15831. * Called by the GPUParticleSystem to setup the update shader
  15832. * @param effect defines the update shader
  15833. */
  15834. applyToShader(effect: Effect): void;
  15835. /**
  15836. * Returns a string to use to update the GPU particles update shader
  15837. * @returns a string containng the defines string
  15838. */
  15839. getEffectDefines(): string;
  15840. /**
  15841. * Returns the string "HemisphericParticleEmitter"
  15842. * @returns a string containing the class name
  15843. */
  15844. getClassName(): string;
  15845. /**
  15846. * Serializes the particle system to a JSON object.
  15847. * @returns the JSON object
  15848. */
  15849. serialize(): any;
  15850. /**
  15851. * Parse properties from a JSON object
  15852. * @param serializationObject defines the JSON object
  15853. */
  15854. parse(serializationObject: any): void;
  15855. }
  15856. }
  15857. declare module BABYLON {
  15858. /**
  15859. * Particle emitter emitting particles from a point.
  15860. * It emits the particles randomly between 2 given directions.
  15861. */
  15862. export class PointParticleEmitter implements IParticleEmitterType {
  15863. /**
  15864. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15865. */
  15866. direction1: Vector3;
  15867. /**
  15868. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15869. */
  15870. direction2: Vector3;
  15871. /**
  15872. * Creates a new instance PointParticleEmitter
  15873. */
  15874. constructor();
  15875. /**
  15876. * Called by the particle System when the direction is computed for the created particle.
  15877. * @param worldMatrix is the world matrix of the particle system
  15878. * @param directionToUpdate is the direction vector to update with the result
  15879. * @param particle is the particle we are computed the direction for
  15880. */
  15881. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15882. /**
  15883. * Called by the particle System when the position is computed for the created particle.
  15884. * @param worldMatrix is the world matrix of the particle system
  15885. * @param positionToUpdate is the position vector to update with the result
  15886. * @param particle is the particle we are computed the position for
  15887. */
  15888. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15889. /**
  15890. * Clones the current emitter and returns a copy of it
  15891. * @returns the new emitter
  15892. */
  15893. clone(): PointParticleEmitter;
  15894. /**
  15895. * Called by the GPUParticleSystem to setup the update shader
  15896. * @param effect defines the update shader
  15897. */
  15898. applyToShader(effect: Effect): void;
  15899. /**
  15900. * Returns a string to use to update the GPU particles update shader
  15901. * @returns a string containng the defines string
  15902. */
  15903. getEffectDefines(): string;
  15904. /**
  15905. * Returns the string "PointParticleEmitter"
  15906. * @returns a string containing the class name
  15907. */
  15908. getClassName(): string;
  15909. /**
  15910. * Serializes the particle system to a JSON object.
  15911. * @returns the JSON object
  15912. */
  15913. serialize(): any;
  15914. /**
  15915. * Parse properties from a JSON object
  15916. * @param serializationObject defines the JSON object
  15917. */
  15918. parse(serializationObject: any): void;
  15919. }
  15920. }
  15921. declare module BABYLON {
  15922. /**
  15923. * Particle emitter emitting particles from the inside of a sphere.
  15924. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15925. */
  15926. export class SphereParticleEmitter implements IParticleEmitterType {
  15927. /**
  15928. * The radius of the emission sphere.
  15929. */
  15930. radius: number;
  15931. /**
  15932. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15933. */
  15934. radiusRange: number;
  15935. /**
  15936. * How much to randomize the particle direction [0-1].
  15937. */
  15938. directionRandomizer: number;
  15939. /**
  15940. * Creates a new instance SphereParticleEmitter
  15941. * @param radius the radius of the emission sphere (1 by default)
  15942. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15943. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15944. */
  15945. constructor(
  15946. /**
  15947. * The radius of the emission sphere.
  15948. */
  15949. radius?: number,
  15950. /**
  15951. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15952. */
  15953. radiusRange?: number,
  15954. /**
  15955. * How much to randomize the particle direction [0-1].
  15956. */
  15957. directionRandomizer?: number);
  15958. /**
  15959. * Called by the particle System when the direction is computed for the created particle.
  15960. * @param worldMatrix is the world matrix of the particle system
  15961. * @param directionToUpdate is the direction vector to update with the result
  15962. * @param particle is the particle we are computed the direction for
  15963. */
  15964. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15965. /**
  15966. * Called by the particle System when the position is computed for the created particle.
  15967. * @param worldMatrix is the world matrix of the particle system
  15968. * @param positionToUpdate is the position vector to update with the result
  15969. * @param particle is the particle we are computed the position for
  15970. */
  15971. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15972. /**
  15973. * Clones the current emitter and returns a copy of it
  15974. * @returns the new emitter
  15975. */
  15976. clone(): SphereParticleEmitter;
  15977. /**
  15978. * Called by the GPUParticleSystem to setup the update shader
  15979. * @param effect defines the update shader
  15980. */
  15981. applyToShader(effect: Effect): void;
  15982. /**
  15983. * Returns a string to use to update the GPU particles update shader
  15984. * @returns a string containng the defines string
  15985. */
  15986. getEffectDefines(): string;
  15987. /**
  15988. * Returns the string "SphereParticleEmitter"
  15989. * @returns a string containing the class name
  15990. */
  15991. getClassName(): string;
  15992. /**
  15993. * Serializes the particle system to a JSON object.
  15994. * @returns the JSON object
  15995. */
  15996. serialize(): any;
  15997. /**
  15998. * Parse properties from a JSON object
  15999. * @param serializationObject defines the JSON object
  16000. */
  16001. parse(serializationObject: any): void;
  16002. }
  16003. /**
  16004. * Particle emitter emitting particles from the inside of a sphere.
  16005. * It emits the particles randomly between two vectors.
  16006. */
  16007. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16008. /**
  16009. * The min limit of the emission direction.
  16010. */
  16011. direction1: Vector3;
  16012. /**
  16013. * The max limit of the emission direction.
  16014. */
  16015. direction2: Vector3;
  16016. /**
  16017. * Creates a new instance SphereDirectedParticleEmitter
  16018. * @param radius the radius of the emission sphere (1 by default)
  16019. * @param direction1 the min limit of the emission direction (up vector by default)
  16020. * @param direction2 the max limit of the emission direction (up vector by default)
  16021. */
  16022. constructor(radius?: number,
  16023. /**
  16024. * The min limit of the emission direction.
  16025. */
  16026. direction1?: Vector3,
  16027. /**
  16028. * The max limit of the emission direction.
  16029. */
  16030. direction2?: Vector3);
  16031. /**
  16032. * Called by the particle System when the direction is computed for the created particle.
  16033. * @param worldMatrix is the world matrix of the particle system
  16034. * @param directionToUpdate is the direction vector to update with the result
  16035. * @param particle is the particle we are computed the direction for
  16036. */
  16037. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16038. /**
  16039. * Clones the current emitter and returns a copy of it
  16040. * @returns the new emitter
  16041. */
  16042. clone(): SphereDirectedParticleEmitter;
  16043. /**
  16044. * Called by the GPUParticleSystem to setup the update shader
  16045. * @param effect defines the update shader
  16046. */
  16047. applyToShader(effect: Effect): void;
  16048. /**
  16049. * Returns a string to use to update the GPU particles update shader
  16050. * @returns a string containng the defines string
  16051. */
  16052. getEffectDefines(): string;
  16053. /**
  16054. * Returns the string "SphereDirectedParticleEmitter"
  16055. * @returns a string containing the class name
  16056. */
  16057. getClassName(): string;
  16058. /**
  16059. * Serializes the particle system to a JSON object.
  16060. * @returns the JSON object
  16061. */
  16062. serialize(): any;
  16063. /**
  16064. * Parse properties from a JSON object
  16065. * @param serializationObject defines the JSON object
  16066. */
  16067. parse(serializationObject: any): void;
  16068. }
  16069. }
  16070. declare module BABYLON {
  16071. /**
  16072. * Interface representing a particle system in Babylon.js.
  16073. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16074. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16075. */
  16076. export interface IParticleSystem {
  16077. /**
  16078. * List of animations used by the particle system.
  16079. */
  16080. animations: Animation[];
  16081. /**
  16082. * The id of the Particle system.
  16083. */
  16084. id: string;
  16085. /**
  16086. * The name of the Particle system.
  16087. */
  16088. name: string;
  16089. /**
  16090. * The emitter represents the Mesh or position we are attaching the particle system to.
  16091. */
  16092. emitter: Nullable<AbstractMesh | Vector3>;
  16093. /**
  16094. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16095. */
  16096. isBillboardBased: boolean;
  16097. /**
  16098. * The rendering group used by the Particle system to chose when to render.
  16099. */
  16100. renderingGroupId: number;
  16101. /**
  16102. * The layer mask we are rendering the particles through.
  16103. */
  16104. layerMask: number;
  16105. /**
  16106. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16107. */
  16108. updateSpeed: number;
  16109. /**
  16110. * The amount of time the particle system is running (depends of the overall update speed).
  16111. */
  16112. targetStopDuration: number;
  16113. /**
  16114. * The texture used to render each particle. (this can be a spritesheet)
  16115. */
  16116. particleTexture: Nullable<Texture>;
  16117. /**
  16118. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16119. */
  16120. blendMode: number;
  16121. /**
  16122. * Minimum life time of emitting particles.
  16123. */
  16124. minLifeTime: number;
  16125. /**
  16126. * Maximum life time of emitting particles.
  16127. */
  16128. maxLifeTime: number;
  16129. /**
  16130. * Minimum Size of emitting particles.
  16131. */
  16132. minSize: number;
  16133. /**
  16134. * Maximum Size of emitting particles.
  16135. */
  16136. maxSize: number;
  16137. /**
  16138. * Minimum scale of emitting particles on X axis.
  16139. */
  16140. minScaleX: number;
  16141. /**
  16142. * Maximum scale of emitting particles on X axis.
  16143. */
  16144. maxScaleX: number;
  16145. /**
  16146. * Minimum scale of emitting particles on Y axis.
  16147. */
  16148. minScaleY: number;
  16149. /**
  16150. * Maximum scale of emitting particles on Y axis.
  16151. */
  16152. maxScaleY: number;
  16153. /**
  16154. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16155. */
  16156. color1: Color4;
  16157. /**
  16158. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16159. */
  16160. color2: Color4;
  16161. /**
  16162. * Color the particle will have at the end of its lifetime.
  16163. */
  16164. colorDead: Color4;
  16165. /**
  16166. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16167. */
  16168. emitRate: number;
  16169. /**
  16170. * You can use gravity if you want to give an orientation to your particles.
  16171. */
  16172. gravity: Vector3;
  16173. /**
  16174. * Minimum power of emitting particles.
  16175. */
  16176. minEmitPower: number;
  16177. /**
  16178. * Maximum power of emitting particles.
  16179. */
  16180. maxEmitPower: number;
  16181. /**
  16182. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16183. */
  16184. minAngularSpeed: number;
  16185. /**
  16186. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16187. */
  16188. maxAngularSpeed: number;
  16189. /**
  16190. * Gets or sets the minimal initial rotation in radians.
  16191. */
  16192. minInitialRotation: number;
  16193. /**
  16194. * Gets or sets the maximal initial rotation in radians.
  16195. */
  16196. maxInitialRotation: number;
  16197. /**
  16198. * The particle emitter type defines the emitter used by the particle system.
  16199. * It can be for example box, sphere, or cone...
  16200. */
  16201. particleEmitterType: Nullable<IParticleEmitterType>;
  16202. /**
  16203. * Defines the delay in milliseconds before starting the system (0 by default)
  16204. */
  16205. startDelay: number;
  16206. /**
  16207. * 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
  16208. */
  16209. preWarmCycles: number;
  16210. /**
  16211. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16212. */
  16213. preWarmStepOffset: number;
  16214. /**
  16215. * 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)
  16216. */
  16217. spriteCellChangeSpeed: number;
  16218. /**
  16219. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16220. */
  16221. startSpriteCellID: number;
  16222. /**
  16223. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16224. */
  16225. endSpriteCellID: number;
  16226. /**
  16227. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16228. */
  16229. spriteCellWidth: number;
  16230. /**
  16231. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16232. */
  16233. spriteCellHeight: number;
  16234. /**
  16235. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16236. */
  16237. spriteRandomStartCell: boolean;
  16238. /**
  16239. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16240. */
  16241. isAnimationSheetEnabled: boolean;
  16242. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16243. translationPivot: Vector2;
  16244. /**
  16245. * Gets or sets a texture used to add random noise to particle positions
  16246. */
  16247. noiseTexture: Nullable<BaseTexture>;
  16248. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16249. noiseStrength: Vector3;
  16250. /**
  16251. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16252. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16253. */
  16254. billboardMode: number;
  16255. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16256. limitVelocityDamping: number;
  16257. /**
  16258. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16259. */
  16260. beginAnimationOnStart: boolean;
  16261. /**
  16262. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16263. */
  16264. beginAnimationFrom: number;
  16265. /**
  16266. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16267. */
  16268. beginAnimationTo: number;
  16269. /**
  16270. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16271. */
  16272. beginAnimationLoop: boolean;
  16273. /**
  16274. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16275. */
  16276. disposeOnStop: boolean;
  16277. /**
  16278. * Gets the maximum number of particles active at the same time.
  16279. * @returns The max number of active particles.
  16280. */
  16281. getCapacity(): number;
  16282. /**
  16283. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16284. * @returns True if it has been started, otherwise false.
  16285. */
  16286. isStarted(): boolean;
  16287. /**
  16288. * Animates the particle system for this frame.
  16289. */
  16290. animate(): void;
  16291. /**
  16292. * Renders the particle system in its current state.
  16293. * @returns the current number of particles
  16294. */
  16295. render(): number;
  16296. /**
  16297. * Dispose the particle system and frees its associated resources.
  16298. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16299. */
  16300. dispose(disposeTexture?: boolean): void;
  16301. /**
  16302. * Clones the particle system.
  16303. * @param name The name of the cloned object
  16304. * @param newEmitter The new emitter to use
  16305. * @returns the cloned particle system
  16306. */
  16307. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16308. /**
  16309. * Serializes the particle system to a JSON object.
  16310. * @returns the JSON object
  16311. */
  16312. serialize(): any;
  16313. /**
  16314. * Rebuild the particle system
  16315. */
  16316. rebuild(): void;
  16317. /**
  16318. * Starts the particle system and begins to emit
  16319. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16320. */
  16321. start(delay?: number): void;
  16322. /**
  16323. * Stops the particle system.
  16324. */
  16325. stop(): void;
  16326. /**
  16327. * Remove all active particles
  16328. */
  16329. reset(): void;
  16330. /**
  16331. * Is this system ready to be used/rendered
  16332. * @return true if the system is ready
  16333. */
  16334. isReady(): boolean;
  16335. /**
  16336. * Adds a new color gradient
  16337. * @param gradient defines the gradient to use (between 0 and 1)
  16338. * @param color1 defines the color to affect to the specified gradient
  16339. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16340. * @returns the current particle system
  16341. */
  16342. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16343. /**
  16344. * Remove a specific color gradient
  16345. * @param gradient defines the gradient to remove
  16346. * @returns the current particle system
  16347. */
  16348. removeColorGradient(gradient: number): IParticleSystem;
  16349. /**
  16350. * Adds a new size gradient
  16351. * @param gradient defines the gradient to use (between 0 and 1)
  16352. * @param factor defines the size factor to affect to the specified gradient
  16353. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16354. * @returns the current particle system
  16355. */
  16356. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16357. /**
  16358. * Remove a specific size gradient
  16359. * @param gradient defines the gradient to remove
  16360. * @returns the current particle system
  16361. */
  16362. removeSizeGradient(gradient: number): IParticleSystem;
  16363. /**
  16364. * Gets the current list of color gradients.
  16365. * You must use addColorGradient and removeColorGradient to udpate this list
  16366. * @returns the list of color gradients
  16367. */
  16368. getColorGradients(): Nullable<Array<ColorGradient>>;
  16369. /**
  16370. * Gets the current list of size gradients.
  16371. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16372. * @returns the list of size gradients
  16373. */
  16374. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16375. /**
  16376. * Gets the current list of angular speed gradients.
  16377. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16378. * @returns the list of angular speed gradients
  16379. */
  16380. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16381. /**
  16382. * Adds a new angular speed gradient
  16383. * @param gradient defines the gradient to use (between 0 and 1)
  16384. * @param factor defines the angular speed to affect to the specified gradient
  16385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16386. * @returns the current particle system
  16387. */
  16388. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16389. /**
  16390. * Remove a specific angular speed gradient
  16391. * @param gradient defines the gradient to remove
  16392. * @returns the current particle system
  16393. */
  16394. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16395. /**
  16396. * Gets the current list of velocity gradients.
  16397. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16398. * @returns the list of velocity gradients
  16399. */
  16400. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16401. /**
  16402. * Adds a new velocity gradient
  16403. * @param gradient defines the gradient to use (between 0 and 1)
  16404. * @param factor defines the velocity to affect to the specified gradient
  16405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16406. * @returns the current particle system
  16407. */
  16408. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16409. /**
  16410. * Remove a specific velocity gradient
  16411. * @param gradient defines the gradient to remove
  16412. * @returns the current particle system
  16413. */
  16414. removeVelocityGradient(gradient: number): IParticleSystem;
  16415. /**
  16416. * Gets the current list of limit velocity gradients.
  16417. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16418. * @returns the list of limit velocity gradients
  16419. */
  16420. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16421. /**
  16422. * Adds a new limit velocity gradient
  16423. * @param gradient defines the gradient to use (between 0 and 1)
  16424. * @param factor defines the limit velocity to affect to the specified gradient
  16425. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16426. * @returns the current particle system
  16427. */
  16428. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16429. /**
  16430. * Remove a specific limit velocity gradient
  16431. * @param gradient defines the gradient to remove
  16432. * @returns the current particle system
  16433. */
  16434. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16435. /**
  16436. * Adds a new drag gradient
  16437. * @param gradient defines the gradient to use (between 0 and 1)
  16438. * @param factor defines the drag to affect to the specified gradient
  16439. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16440. * @returns the current particle system
  16441. */
  16442. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16443. /**
  16444. * Remove a specific drag gradient
  16445. * @param gradient defines the gradient to remove
  16446. * @returns the current particle system
  16447. */
  16448. removeDragGradient(gradient: number): IParticleSystem;
  16449. /**
  16450. * Gets the current list of drag gradients.
  16451. * You must use addDragGradient and removeDragGradient to udpate this list
  16452. * @returns the list of drag gradients
  16453. */
  16454. getDragGradients(): Nullable<Array<FactorGradient>>;
  16455. /**
  16456. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16457. * @param gradient defines the gradient to use (between 0 and 1)
  16458. * @param factor defines the emit rate to affect to the specified gradient
  16459. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16460. * @returns the current particle system
  16461. */
  16462. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16463. /**
  16464. * Remove a specific emit rate gradient
  16465. * @param gradient defines the gradient to remove
  16466. * @returns the current particle system
  16467. */
  16468. removeEmitRateGradient(gradient: number): IParticleSystem;
  16469. /**
  16470. * Gets the current list of emit rate gradients.
  16471. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16472. * @returns the list of emit rate gradients
  16473. */
  16474. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16475. /**
  16476. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16477. * @param gradient defines the gradient to use (between 0 and 1)
  16478. * @param factor defines the start size to affect to the specified gradient
  16479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16480. * @returns the current particle system
  16481. */
  16482. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16483. /**
  16484. * Remove a specific start size gradient
  16485. * @param gradient defines the gradient to remove
  16486. * @returns the current particle system
  16487. */
  16488. removeStartSizeGradient(gradient: number): IParticleSystem;
  16489. /**
  16490. * Gets the current list of start size gradients.
  16491. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16492. * @returns the list of start size gradients
  16493. */
  16494. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16495. /**
  16496. * Adds a new life time gradient
  16497. * @param gradient defines the gradient to use (between 0 and 1)
  16498. * @param factor defines the life time factor to affect to the specified gradient
  16499. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16500. * @returns the current particle system
  16501. */
  16502. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16503. /**
  16504. * Remove a specific life time gradient
  16505. * @param gradient defines the gradient to remove
  16506. * @returns the current particle system
  16507. */
  16508. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16509. /**
  16510. * Gets the current list of life time gradients.
  16511. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16512. * @returns the list of life time gradients
  16513. */
  16514. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16515. /**
  16516. * Gets the current list of color gradients.
  16517. * You must use addColorGradient and removeColorGradient to udpate this list
  16518. * @returns the list of color gradients
  16519. */
  16520. getColorGradients(): Nullable<Array<ColorGradient>>;
  16521. /**
  16522. * Adds a new ramp gradient used to remap particle colors
  16523. * @param gradient defines the gradient to use (between 0 and 1)
  16524. * @param color defines the color to affect to the specified gradient
  16525. * @returns the current particle system
  16526. */
  16527. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16528. /**
  16529. * Gets the current list of ramp gradients.
  16530. * You must use addRampGradient and removeRampGradient to udpate this list
  16531. * @returns the list of ramp gradients
  16532. */
  16533. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16534. /** Gets or sets a boolean indicating that ramp gradients must be used
  16535. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16536. */
  16537. useRampGradients: boolean;
  16538. /**
  16539. * Adds a new color remap gradient
  16540. * @param gradient defines the gradient to use (between 0 and 1)
  16541. * @param min defines the color remap minimal range
  16542. * @param max defines the color remap maximal range
  16543. * @returns the current particle system
  16544. */
  16545. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16546. /**
  16547. * Gets the current list of color remap gradients.
  16548. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16549. * @returns the list of color remap gradients
  16550. */
  16551. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16552. /**
  16553. * Adds a new alpha remap gradient
  16554. * @param gradient defines the gradient to use (between 0 and 1)
  16555. * @param min defines the alpha remap minimal range
  16556. * @param max defines the alpha remap maximal range
  16557. * @returns the current particle system
  16558. */
  16559. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16560. /**
  16561. * Gets the current list of alpha remap gradients.
  16562. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16563. * @returns the list of alpha remap gradients
  16564. */
  16565. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16566. /**
  16567. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16568. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16569. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16570. * @returns the emitter
  16571. */
  16572. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16573. /**
  16574. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16575. * @param radius The radius of the hemisphere to emit from
  16576. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16577. * @returns the emitter
  16578. */
  16579. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16580. /**
  16581. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16582. * @param radius The radius of the sphere to emit from
  16583. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16584. * @returns the emitter
  16585. */
  16586. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16587. /**
  16588. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16589. * @param radius The radius of the sphere to emit from
  16590. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16591. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16592. * @returns the emitter
  16593. */
  16594. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16595. /**
  16596. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16597. * @param radius The radius of the emission cylinder
  16598. * @param height The height of the emission cylinder
  16599. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16600. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16601. * @returns the emitter
  16602. */
  16603. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16604. /**
  16605. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16606. * @param radius The radius of the cylinder to emit from
  16607. * @param height The height of the emission cylinder
  16608. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16609. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16610. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16611. * @returns the emitter
  16612. */
  16613. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16614. /**
  16615. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16616. * @param radius The radius of the cone to emit from
  16617. * @param angle The base angle of the cone
  16618. * @returns the emitter
  16619. */
  16620. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16621. /**
  16622. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16623. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16624. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16625. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16626. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16627. * @returns the emitter
  16628. */
  16629. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16630. /**
  16631. * Get hosting scene
  16632. * @returns the scene
  16633. */
  16634. getScene(): Scene;
  16635. }
  16636. }
  16637. declare module BABYLON {
  16638. /**
  16639. * Creates an instance based on a source mesh.
  16640. */
  16641. export class InstancedMesh extends AbstractMesh {
  16642. private _sourceMesh;
  16643. private _currentLOD;
  16644. /** @hidden */
  16645. _indexInSourceMeshInstanceArray: number;
  16646. constructor(name: string, source: Mesh);
  16647. /**
  16648. * Returns the string "InstancedMesh".
  16649. */
  16650. getClassName(): string;
  16651. /**
  16652. * If the source mesh receives shadows
  16653. */
  16654. readonly receiveShadows: boolean;
  16655. /**
  16656. * The material of the source mesh
  16657. */
  16658. readonly material: Nullable<Material>;
  16659. /**
  16660. * Visibility of the source mesh
  16661. */
  16662. readonly visibility: number;
  16663. /**
  16664. * Skeleton of the source mesh
  16665. */
  16666. readonly skeleton: Nullable<Skeleton>;
  16667. /**
  16668. * Rendering ground id of the source mesh
  16669. */
  16670. renderingGroupId: number;
  16671. /**
  16672. * Returns the total number of vertices (integer).
  16673. */
  16674. getTotalVertices(): number;
  16675. /**
  16676. * Returns a positive integer : the total number of indices in this mesh geometry.
  16677. * @returns the numner of indices or zero if the mesh has no geometry.
  16678. */
  16679. getTotalIndices(): number;
  16680. /**
  16681. * The source mesh of the instance
  16682. */
  16683. readonly sourceMesh: Mesh;
  16684. /**
  16685. * Is this node ready to be used/rendered
  16686. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16687. * @return {boolean} is it ready
  16688. */
  16689. isReady(completeCheck?: boolean): boolean;
  16690. /**
  16691. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16692. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16693. * @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.
  16694. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16695. */
  16696. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16697. /**
  16698. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16699. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16700. * The `data` are either a numeric array either a Float32Array.
  16701. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16702. * 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).
  16703. * Note that a new underlying VertexBuffer object is created each call.
  16704. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16705. *
  16706. * Possible `kind` values :
  16707. * - VertexBuffer.PositionKind
  16708. * - VertexBuffer.UVKind
  16709. * - VertexBuffer.UV2Kind
  16710. * - VertexBuffer.UV3Kind
  16711. * - VertexBuffer.UV4Kind
  16712. * - VertexBuffer.UV5Kind
  16713. * - VertexBuffer.UV6Kind
  16714. * - VertexBuffer.ColorKind
  16715. * - VertexBuffer.MatricesIndicesKind
  16716. * - VertexBuffer.MatricesIndicesExtraKind
  16717. * - VertexBuffer.MatricesWeightsKind
  16718. * - VertexBuffer.MatricesWeightsExtraKind
  16719. *
  16720. * Returns the Mesh.
  16721. */
  16722. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16723. /**
  16724. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16725. * If the mesh has no geometry, it is simply returned as it is.
  16726. * The `data` are either a numeric array either a Float32Array.
  16727. * No new underlying VertexBuffer object is created.
  16728. * 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.
  16729. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16730. *
  16731. * Possible `kind` values :
  16732. * - VertexBuffer.PositionKind
  16733. * - VertexBuffer.UVKind
  16734. * - VertexBuffer.UV2Kind
  16735. * - VertexBuffer.UV3Kind
  16736. * - VertexBuffer.UV4Kind
  16737. * - VertexBuffer.UV5Kind
  16738. * - VertexBuffer.UV6Kind
  16739. * - VertexBuffer.ColorKind
  16740. * - VertexBuffer.MatricesIndicesKind
  16741. * - VertexBuffer.MatricesIndicesExtraKind
  16742. * - VertexBuffer.MatricesWeightsKind
  16743. * - VertexBuffer.MatricesWeightsExtraKind
  16744. *
  16745. * Returns the Mesh.
  16746. */
  16747. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16748. /**
  16749. * Sets the mesh indices.
  16750. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16751. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16752. * This method creates a new index buffer each call.
  16753. * Returns the Mesh.
  16754. */
  16755. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16756. /**
  16757. * Boolean : True if the mesh owns the requested kind of data.
  16758. */
  16759. isVerticesDataPresent(kind: string): boolean;
  16760. /**
  16761. * Returns an array of indices (IndicesArray).
  16762. */
  16763. getIndices(): Nullable<IndicesArray>;
  16764. readonly _positions: Nullable<Vector3[]>;
  16765. /**
  16766. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16767. * This means the mesh underlying bounding box and sphere are recomputed.
  16768. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16769. * @returns the current mesh
  16770. */
  16771. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16772. /** @hidden */
  16773. _preActivate(): InstancedMesh;
  16774. /** @hidden */
  16775. _activate(renderId: number): boolean;
  16776. getWorldMatrix(): Matrix;
  16777. /**
  16778. * Returns the current associated LOD AbstractMesh.
  16779. */
  16780. getLOD(camera: Camera): AbstractMesh;
  16781. /** @hidden */
  16782. _syncSubMeshes(): InstancedMesh;
  16783. /** @hidden */
  16784. _generatePointsArray(): boolean;
  16785. /**
  16786. * Creates a new InstancedMesh from the current mesh.
  16787. * - name (string) : the cloned mesh name
  16788. * - newParent (optional Node) : the optional Node to parent the clone to.
  16789. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16790. *
  16791. * Returns the clone.
  16792. */
  16793. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16794. /**
  16795. * Disposes the InstancedMesh.
  16796. * Returns nothing.
  16797. */
  16798. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16799. }
  16800. }
  16801. declare module BABYLON {
  16802. /**
  16803. * Defines the options associated with the creation of a shader material.
  16804. */
  16805. export interface IShaderMaterialOptions {
  16806. /**
  16807. * Does the material work in alpha blend mode
  16808. */
  16809. needAlphaBlending: boolean;
  16810. /**
  16811. * Does the material work in alpha test mode
  16812. */
  16813. needAlphaTesting: boolean;
  16814. /**
  16815. * The list of attribute names used in the shader
  16816. */
  16817. attributes: string[];
  16818. /**
  16819. * The list of unifrom names used in the shader
  16820. */
  16821. uniforms: string[];
  16822. /**
  16823. * The list of UBO names used in the shader
  16824. */
  16825. uniformBuffers: string[];
  16826. /**
  16827. * The list of sampler names used in the shader
  16828. */
  16829. samplers: string[];
  16830. /**
  16831. * The list of defines used in the shader
  16832. */
  16833. defines: string[];
  16834. }
  16835. /**
  16836. * 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.
  16837. *
  16838. * This returned material effects how the mesh will look based on the code in the shaders.
  16839. *
  16840. * @see http://doc.babylonjs.com/how_to/shader_material
  16841. */
  16842. export class ShaderMaterial extends Material {
  16843. private _shaderPath;
  16844. private _options;
  16845. private _textures;
  16846. private _textureArrays;
  16847. private _floats;
  16848. private _ints;
  16849. private _floatsArrays;
  16850. private _colors3;
  16851. private _colors3Arrays;
  16852. private _colors4;
  16853. private _vectors2;
  16854. private _vectors3;
  16855. private _vectors4;
  16856. private _matrices;
  16857. private _matrices3x3;
  16858. private _matrices2x2;
  16859. private _vectors2Arrays;
  16860. private _vectors3Arrays;
  16861. private _cachedWorldViewMatrix;
  16862. private _renderId;
  16863. /**
  16864. * Instantiate a new shader material.
  16865. * 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.
  16866. * This returned material effects how the mesh will look based on the code in the shaders.
  16867. * @see http://doc.babylonjs.com/how_to/shader_material
  16868. * @param name Define the name of the material in the scene
  16869. * @param scene Define the scene the material belongs to
  16870. * @param shaderPath Defines the route to the shader code in one of three ways:
  16871. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16872. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16873. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16874. * @param options Define the options used to create the shader
  16875. */
  16876. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16877. /**
  16878. * Gets the options used to compile the shader.
  16879. * They can be modified to trigger a new compilation
  16880. */
  16881. readonly options: IShaderMaterialOptions;
  16882. /**
  16883. * Gets the current class name of the material e.g. "ShaderMaterial"
  16884. * Mainly use in serialization.
  16885. * @returns the class name
  16886. */
  16887. getClassName(): string;
  16888. /**
  16889. * Specifies if the material will require alpha blending
  16890. * @returns a boolean specifying if alpha blending is needed
  16891. */
  16892. needAlphaBlending(): boolean;
  16893. /**
  16894. * Specifies if this material should be rendered in alpha test mode
  16895. * @returns a boolean specifying if an alpha test is needed.
  16896. */
  16897. needAlphaTesting(): boolean;
  16898. private _checkUniform;
  16899. /**
  16900. * Set a texture in the shader.
  16901. * @param name Define the name of the uniform samplers as defined in the shader
  16902. * @param texture Define the texture to bind to this sampler
  16903. * @return the material itself allowing "fluent" like uniform updates
  16904. */
  16905. setTexture(name: string, texture: Texture): ShaderMaterial;
  16906. /**
  16907. * Set a texture array in the shader.
  16908. * @param name Define the name of the uniform sampler array as defined in the shader
  16909. * @param textures Define the list of textures to bind to this sampler
  16910. * @return the material itself allowing "fluent" like uniform updates
  16911. */
  16912. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16913. /**
  16914. * Set a float in the shader.
  16915. * @param name Define the name of the uniform as defined in the shader
  16916. * @param value Define the value to give to the uniform
  16917. * @return the material itself allowing "fluent" like uniform updates
  16918. */
  16919. setFloat(name: string, value: number): ShaderMaterial;
  16920. /**
  16921. * Set a int in the shader.
  16922. * @param name Define the name of the uniform as defined in the shader
  16923. * @param value Define the value to give to the uniform
  16924. * @return the material itself allowing "fluent" like uniform updates
  16925. */
  16926. setInt(name: string, value: number): ShaderMaterial;
  16927. /**
  16928. * Set an array of floats in the shader.
  16929. * @param name Define the name of the uniform as defined in the shader
  16930. * @param value Define the value to give to the uniform
  16931. * @return the material itself allowing "fluent" like uniform updates
  16932. */
  16933. setFloats(name: string, value: number[]): ShaderMaterial;
  16934. /**
  16935. * Set a vec3 in the shader from a Color3.
  16936. * @param name Define the name of the uniform as defined in the shader
  16937. * @param value Define the value to give to the uniform
  16938. * @return the material itself allowing "fluent" like uniform updates
  16939. */
  16940. setColor3(name: string, value: Color3): ShaderMaterial;
  16941. /**
  16942. * Set a vec3 array in the shader from a Color3 array.
  16943. * @param name Define the name of the uniform as defined in the shader
  16944. * @param value Define the value to give to the uniform
  16945. * @return the material itself allowing "fluent" like uniform updates
  16946. */
  16947. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16948. /**
  16949. * Set a vec4 in the shader from a Color4.
  16950. * @param name Define the name of the uniform as defined in the shader
  16951. * @param value Define the value to give to the uniform
  16952. * @return the material itself allowing "fluent" like uniform updates
  16953. */
  16954. setColor4(name: string, value: Color4): ShaderMaterial;
  16955. /**
  16956. * Set a vec2 in the shader from a Vector2.
  16957. * @param name Define the name of the uniform as defined in the shader
  16958. * @param value Define the value to give to the uniform
  16959. * @return the material itself allowing "fluent" like uniform updates
  16960. */
  16961. setVector2(name: string, value: Vector2): ShaderMaterial;
  16962. /**
  16963. * Set a vec3 in the shader from a Vector3.
  16964. * @param name Define the name of the uniform as defined in the shader
  16965. * @param value Define the value to give to the uniform
  16966. * @return the material itself allowing "fluent" like uniform updates
  16967. */
  16968. setVector3(name: string, value: Vector3): ShaderMaterial;
  16969. /**
  16970. * Set a vec4 in the shader from a Vector4.
  16971. * @param name Define the name of the uniform as defined in the shader
  16972. * @param value Define the value to give to the uniform
  16973. * @return the material itself allowing "fluent" like uniform updates
  16974. */
  16975. setVector4(name: string, value: Vector4): ShaderMaterial;
  16976. /**
  16977. * Set a mat4 in the shader from a Matrix.
  16978. * @param name Define the name of the uniform as defined in the shader
  16979. * @param value Define the value to give to the uniform
  16980. * @return the material itself allowing "fluent" like uniform updates
  16981. */
  16982. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16983. /**
  16984. * Set a mat3 in the shader from a Float32Array.
  16985. * @param name Define the name of the uniform as defined in the shader
  16986. * @param value Define the value to give to the uniform
  16987. * @return the material itself allowing "fluent" like uniform updates
  16988. */
  16989. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16990. /**
  16991. * Set a mat2 in the shader from a Float32Array.
  16992. * @param name Define the name of the uniform as defined in the shader
  16993. * @param value Define the value to give to the uniform
  16994. * @return the material itself allowing "fluent" like uniform updates
  16995. */
  16996. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16997. /**
  16998. * Set a vec2 array in the shader from a number array.
  16999. * @param name Define the name of the uniform as defined in the shader
  17000. * @param value Define the value to give to the uniform
  17001. * @return the material itself allowing "fluent" like uniform updates
  17002. */
  17003. setArray2(name: string, value: number[]): ShaderMaterial;
  17004. /**
  17005. * Set a vec3 array in the shader from a number array.
  17006. * @param name Define the name of the uniform as defined in the shader
  17007. * @param value Define the value to give to the uniform
  17008. * @return the material itself allowing "fluent" like uniform updates
  17009. */
  17010. setArray3(name: string, value: number[]): ShaderMaterial;
  17011. private _checkCache;
  17012. /**
  17013. * Specifies that the submesh is ready to be used
  17014. * @param mesh defines the mesh to check
  17015. * @param subMesh defines which submesh to check
  17016. * @param useInstances specifies that instances should be used
  17017. * @returns a boolean indicating that the submesh is ready or not
  17018. */
  17019. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17020. /**
  17021. * Checks if the material is ready to render the requested mesh
  17022. * @param mesh Define the mesh to render
  17023. * @param useInstances Define whether or not the material is used with instances
  17024. * @returns true if ready, otherwise false
  17025. */
  17026. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17027. /**
  17028. * Binds the world matrix to the material
  17029. * @param world defines the world transformation matrix
  17030. */
  17031. bindOnlyWorldMatrix(world: Matrix): void;
  17032. /**
  17033. * Binds the material to the mesh
  17034. * @param world defines the world transformation matrix
  17035. * @param mesh defines the mesh to bind the material to
  17036. */
  17037. bind(world: Matrix, mesh?: Mesh): void;
  17038. /**
  17039. * Gets the active textures from the material
  17040. * @returns an array of textures
  17041. */
  17042. getActiveTextures(): BaseTexture[];
  17043. /**
  17044. * Specifies if the material uses a texture
  17045. * @param texture defines the texture to check against the material
  17046. * @returns a boolean specifying if the material uses the texture
  17047. */
  17048. hasTexture(texture: BaseTexture): boolean;
  17049. /**
  17050. * Makes a duplicate of the material, and gives it a new name
  17051. * @param name defines the new name for the duplicated material
  17052. * @returns the cloned material
  17053. */
  17054. clone(name: string): ShaderMaterial;
  17055. /**
  17056. * Disposes the material
  17057. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17058. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17059. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17060. */
  17061. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17062. /**
  17063. * Serializes this material in a JSON representation
  17064. * @returns the serialized material object
  17065. */
  17066. serialize(): any;
  17067. /**
  17068. * Creates a shader material from parsed shader material data
  17069. * @param source defines the JSON represnetation of the material
  17070. * @param scene defines the hosting scene
  17071. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17072. * @returns a new material
  17073. */
  17074. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17075. }
  17076. }
  17077. declare module BABYLON {
  17078. /** @hidden */
  17079. export var colorPixelShader: {
  17080. name: string;
  17081. shader: string;
  17082. };
  17083. }
  17084. declare module BABYLON {
  17085. /** @hidden */
  17086. export var colorVertexShader: {
  17087. name: string;
  17088. shader: string;
  17089. };
  17090. }
  17091. declare module BABYLON {
  17092. /**
  17093. * Line mesh
  17094. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17095. */
  17096. export class LinesMesh extends Mesh {
  17097. /**
  17098. * If vertex color should be applied to the mesh
  17099. */
  17100. useVertexColor?: boolean | undefined;
  17101. /**
  17102. * If vertex alpha should be applied to the mesh
  17103. */
  17104. useVertexAlpha?: boolean | undefined;
  17105. /**
  17106. * Color of the line (Default: White)
  17107. */
  17108. color: Color3;
  17109. /**
  17110. * Alpha of the line (Default: 1)
  17111. */
  17112. alpha: number;
  17113. /**
  17114. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17115. * This margin is expressed in world space coordinates, so its value may vary.
  17116. * Default value is 0.1
  17117. */
  17118. intersectionThreshold: number;
  17119. private _colorShader;
  17120. /**
  17121. * Creates a new LinesMesh
  17122. * @param name defines the name
  17123. * @param scene defines the hosting scene
  17124. * @param parent defines the parent mesh if any
  17125. * @param source defines the optional source LinesMesh used to clone data from
  17126. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17127. * When false, achieved by calling a clone(), also passing False.
  17128. * This will make creation of children, recursive.
  17129. * @param useVertexColor defines if this LinesMesh supports vertex color
  17130. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17131. */
  17132. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17133. /**
  17134. * If vertex color should be applied to the mesh
  17135. */
  17136. useVertexColor?: boolean | undefined,
  17137. /**
  17138. * If vertex alpha should be applied to the mesh
  17139. */
  17140. useVertexAlpha?: boolean | undefined);
  17141. private _addClipPlaneDefine;
  17142. private _removeClipPlaneDefine;
  17143. isReady(): boolean;
  17144. /**
  17145. * Returns the string "LineMesh"
  17146. */
  17147. getClassName(): string;
  17148. /**
  17149. * @hidden
  17150. */
  17151. /**
  17152. * @hidden
  17153. */
  17154. material: Material;
  17155. /**
  17156. * @hidden
  17157. */
  17158. readonly checkCollisions: boolean;
  17159. /** @hidden */
  17160. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17161. /** @hidden */
  17162. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17163. /**
  17164. * Disposes of the line mesh
  17165. * @param doNotRecurse If children should be disposed
  17166. */
  17167. dispose(doNotRecurse?: boolean): void;
  17168. /**
  17169. * Returns a new LineMesh object cloned from the current one.
  17170. */
  17171. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17172. /**
  17173. * Creates a new InstancedLinesMesh object from the mesh model.
  17174. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17175. * @param name defines the name of the new instance
  17176. * @returns a new InstancedLinesMesh
  17177. */
  17178. createInstance(name: string): InstancedLinesMesh;
  17179. }
  17180. /**
  17181. * Creates an instance based on a source LinesMesh
  17182. */
  17183. export class InstancedLinesMesh extends InstancedMesh {
  17184. /**
  17185. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17186. * This margin is expressed in world space coordinates, so its value may vary.
  17187. * Initilized with the intersectionThreshold value of the source LinesMesh
  17188. */
  17189. intersectionThreshold: number;
  17190. constructor(name: string, source: LinesMesh);
  17191. /**
  17192. * Returns the string "InstancedLinesMesh".
  17193. */
  17194. getClassName(): string;
  17195. }
  17196. }
  17197. declare module BABYLON {
  17198. /** @hidden */
  17199. export var linePixelShader: {
  17200. name: string;
  17201. shader: string;
  17202. };
  17203. }
  17204. declare module BABYLON {
  17205. /** @hidden */
  17206. export var lineVertexShader: {
  17207. name: string;
  17208. shader: string;
  17209. };
  17210. }
  17211. declare module BABYLON {
  17212. interface AbstractMesh {
  17213. /**
  17214. * Disables the mesh edge rendering mode
  17215. * @returns the currentAbstractMesh
  17216. */
  17217. disableEdgesRendering(): AbstractMesh;
  17218. /**
  17219. * Enables the edge rendering mode on the mesh.
  17220. * This mode makes the mesh edges visible
  17221. * @param epsilon defines the maximal distance between two angles to detect a face
  17222. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17223. * @returns the currentAbstractMesh
  17224. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17225. */
  17226. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17227. /**
  17228. * Gets the edgesRenderer associated with the mesh
  17229. */
  17230. edgesRenderer: Nullable<EdgesRenderer>;
  17231. }
  17232. interface LinesMesh {
  17233. /**
  17234. * Enables the edge rendering mode on the mesh.
  17235. * This mode makes the mesh edges visible
  17236. * @param epsilon defines the maximal distance between two angles to detect a face
  17237. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17238. * @returns the currentAbstractMesh
  17239. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17240. */
  17241. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17242. }
  17243. interface InstancedLinesMesh {
  17244. /**
  17245. * Enables the edge rendering mode on the mesh.
  17246. * This mode makes the mesh edges visible
  17247. * @param epsilon defines the maximal distance between two angles to detect a face
  17248. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17249. * @returns the current InstancedLinesMesh
  17250. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17251. */
  17252. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17253. }
  17254. /**
  17255. * Defines the minimum contract an Edges renderer should follow.
  17256. */
  17257. export interface IEdgesRenderer extends IDisposable {
  17258. /**
  17259. * Gets or sets a boolean indicating if the edgesRenderer is active
  17260. */
  17261. isEnabled: boolean;
  17262. /**
  17263. * Renders the edges of the attached mesh,
  17264. */
  17265. render(): void;
  17266. /**
  17267. * Checks wether or not the edges renderer is ready to render.
  17268. * @return true if ready, otherwise false.
  17269. */
  17270. isReady(): boolean;
  17271. }
  17272. /**
  17273. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17274. */
  17275. export class EdgesRenderer implements IEdgesRenderer {
  17276. /**
  17277. * Define the size of the edges with an orthographic camera
  17278. */
  17279. edgesWidthScalerForOrthographic: number;
  17280. /**
  17281. * Define the size of the edges with a perspective camera
  17282. */
  17283. edgesWidthScalerForPerspective: number;
  17284. protected _source: AbstractMesh;
  17285. protected _linesPositions: number[];
  17286. protected _linesNormals: number[];
  17287. protected _linesIndices: number[];
  17288. protected _epsilon: number;
  17289. protected _indicesCount: number;
  17290. protected _lineShader: ShaderMaterial;
  17291. protected _ib: DataBuffer;
  17292. protected _buffers: {
  17293. [key: string]: Nullable<VertexBuffer>;
  17294. };
  17295. protected _checkVerticesInsteadOfIndices: boolean;
  17296. private _meshRebuildObserver;
  17297. private _meshDisposeObserver;
  17298. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17299. isEnabled: boolean;
  17300. /**
  17301. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17302. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17303. * @param source Mesh used to create edges
  17304. * @param epsilon sum of angles in adjacency to check for edge
  17305. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17306. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17307. */
  17308. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17309. protected _prepareRessources(): void;
  17310. /** @hidden */
  17311. _rebuild(): void;
  17312. /**
  17313. * Releases the required resources for the edges renderer
  17314. */
  17315. dispose(): void;
  17316. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17317. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17318. /**
  17319. * Checks if the pair of p0 and p1 is en edge
  17320. * @param faceIndex
  17321. * @param edge
  17322. * @param faceNormals
  17323. * @param p0
  17324. * @param p1
  17325. * @private
  17326. */
  17327. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17328. /**
  17329. * push line into the position, normal and index buffer
  17330. * @protected
  17331. */
  17332. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17333. /**
  17334. * Generates lines edges from adjacencjes
  17335. * @private
  17336. */
  17337. _generateEdgesLines(): void;
  17338. /**
  17339. * Checks wether or not the edges renderer is ready to render.
  17340. * @return true if ready, otherwise false.
  17341. */
  17342. isReady(): boolean;
  17343. /**
  17344. * Renders the edges of the attached mesh,
  17345. */
  17346. render(): void;
  17347. }
  17348. /**
  17349. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17350. */
  17351. export class LineEdgesRenderer extends EdgesRenderer {
  17352. /**
  17353. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17354. * @param source LineMesh used to generate edges
  17355. * @param epsilon not important (specified angle for edge detection)
  17356. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17357. */
  17358. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17359. /**
  17360. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17361. */
  17362. _generateEdgesLines(): void;
  17363. }
  17364. }
  17365. declare module BABYLON {
  17366. /**
  17367. * This represents the object necessary to create a rendering group.
  17368. * This is exclusively used and created by the rendering manager.
  17369. * To modify the behavior, you use the available helpers in your scene or meshes.
  17370. * @hidden
  17371. */
  17372. export class RenderingGroup {
  17373. index: number;
  17374. private _scene;
  17375. private _opaqueSubMeshes;
  17376. private _transparentSubMeshes;
  17377. private _alphaTestSubMeshes;
  17378. private _depthOnlySubMeshes;
  17379. private _particleSystems;
  17380. private _spriteManagers;
  17381. private _opaqueSortCompareFn;
  17382. private _alphaTestSortCompareFn;
  17383. private _transparentSortCompareFn;
  17384. private _renderOpaque;
  17385. private _renderAlphaTest;
  17386. private _renderTransparent;
  17387. /** @hidden */
  17388. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17389. onBeforeTransparentRendering: () => void;
  17390. /**
  17391. * Set the opaque sort comparison function.
  17392. * If null the sub meshes will be render in the order they were created
  17393. */
  17394. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17395. /**
  17396. * Set the alpha test sort comparison function.
  17397. * If null the sub meshes will be render in the order they were created
  17398. */
  17399. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17400. /**
  17401. * Set the transparent sort comparison function.
  17402. * If null the sub meshes will be render in the order they were created
  17403. */
  17404. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17405. /**
  17406. * Creates a new rendering group.
  17407. * @param index The rendering group index
  17408. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17409. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17410. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17411. */
  17412. 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>);
  17413. /**
  17414. * Render all the sub meshes contained in the group.
  17415. * @param customRenderFunction Used to override the default render behaviour of the group.
  17416. * @returns true if rendered some submeshes.
  17417. */
  17418. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17419. /**
  17420. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17421. * @param subMeshes The submeshes to render
  17422. */
  17423. private renderOpaqueSorted;
  17424. /**
  17425. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17426. * @param subMeshes The submeshes to render
  17427. */
  17428. private renderAlphaTestSorted;
  17429. /**
  17430. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17431. * @param subMeshes The submeshes to render
  17432. */
  17433. private renderTransparentSorted;
  17434. /**
  17435. * Renders the submeshes in a specified order.
  17436. * @param subMeshes The submeshes to sort before render
  17437. * @param sortCompareFn The comparison function use to sort
  17438. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17439. * @param transparent Specifies to activate blending if true
  17440. */
  17441. private static renderSorted;
  17442. /**
  17443. * Renders the submeshes in the order they were dispatched (no sort applied).
  17444. * @param subMeshes The submeshes to render
  17445. */
  17446. private static renderUnsorted;
  17447. /**
  17448. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17449. * are rendered back to front if in the same alpha index.
  17450. *
  17451. * @param a The first submesh
  17452. * @param b The second submesh
  17453. * @returns The result of the comparison
  17454. */
  17455. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17456. /**
  17457. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17458. * are rendered back to front.
  17459. *
  17460. * @param a The first submesh
  17461. * @param b The second submesh
  17462. * @returns The result of the comparison
  17463. */
  17464. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17465. /**
  17466. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17467. * are rendered front to back (prevent overdraw).
  17468. *
  17469. * @param a The first submesh
  17470. * @param b The second submesh
  17471. * @returns The result of the comparison
  17472. */
  17473. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17474. /**
  17475. * Resets the different lists of submeshes to prepare a new frame.
  17476. */
  17477. prepare(): void;
  17478. dispose(): void;
  17479. /**
  17480. * Inserts the submesh in its correct queue depending on its material.
  17481. * @param subMesh The submesh to dispatch
  17482. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17483. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17484. */
  17485. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17486. dispatchSprites(spriteManager: ISpriteManager): void;
  17487. dispatchParticles(particleSystem: IParticleSystem): void;
  17488. private _renderParticles;
  17489. private _renderSprites;
  17490. }
  17491. }
  17492. declare module BABYLON {
  17493. /**
  17494. * Interface describing the different options available in the rendering manager
  17495. * regarding Auto Clear between groups.
  17496. */
  17497. export interface IRenderingManagerAutoClearSetup {
  17498. /**
  17499. * Defines whether or not autoclear is enable.
  17500. */
  17501. autoClear: boolean;
  17502. /**
  17503. * Defines whether or not to autoclear the depth buffer.
  17504. */
  17505. depth: boolean;
  17506. /**
  17507. * Defines whether or not to autoclear the stencil buffer.
  17508. */
  17509. stencil: boolean;
  17510. }
  17511. /**
  17512. * This class is used by the onRenderingGroupObservable
  17513. */
  17514. export class RenderingGroupInfo {
  17515. /**
  17516. * The Scene that being rendered
  17517. */
  17518. scene: Scene;
  17519. /**
  17520. * The camera currently used for the rendering pass
  17521. */
  17522. camera: Nullable<Camera>;
  17523. /**
  17524. * The ID of the renderingGroup being processed
  17525. */
  17526. renderingGroupId: number;
  17527. }
  17528. /**
  17529. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17530. * It is enable to manage the different groups as well as the different necessary sort functions.
  17531. * This should not be used directly aside of the few static configurations
  17532. */
  17533. export class RenderingManager {
  17534. /**
  17535. * The max id used for rendering groups (not included)
  17536. */
  17537. static MAX_RENDERINGGROUPS: number;
  17538. /**
  17539. * The min id used for rendering groups (included)
  17540. */
  17541. static MIN_RENDERINGGROUPS: number;
  17542. /**
  17543. * Used to globally prevent autoclearing scenes.
  17544. */
  17545. static AUTOCLEAR: boolean;
  17546. /**
  17547. * @hidden
  17548. */
  17549. _useSceneAutoClearSetup: boolean;
  17550. private _scene;
  17551. private _renderingGroups;
  17552. private _depthStencilBufferAlreadyCleaned;
  17553. private _autoClearDepthStencil;
  17554. private _customOpaqueSortCompareFn;
  17555. private _customAlphaTestSortCompareFn;
  17556. private _customTransparentSortCompareFn;
  17557. private _renderingGroupInfo;
  17558. /**
  17559. * Instantiates a new rendering group for a particular scene
  17560. * @param scene Defines the scene the groups belongs to
  17561. */
  17562. constructor(scene: Scene);
  17563. private _clearDepthStencilBuffer;
  17564. /**
  17565. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17566. * @hidden
  17567. */
  17568. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17569. /**
  17570. * Resets the different information of the group to prepare a new frame
  17571. * @hidden
  17572. */
  17573. reset(): void;
  17574. /**
  17575. * Dispose and release the group and its associated resources.
  17576. * @hidden
  17577. */
  17578. dispose(): void;
  17579. /**
  17580. * Clear the info related to rendering groups preventing retention points during dispose.
  17581. */
  17582. freeRenderingGroups(): void;
  17583. private _prepareRenderingGroup;
  17584. /**
  17585. * Add a sprite manager to the rendering manager in order to render it this frame.
  17586. * @param spriteManager Define the sprite manager to render
  17587. */
  17588. dispatchSprites(spriteManager: ISpriteManager): void;
  17589. /**
  17590. * Add a particle system to the rendering manager in order to render it this frame.
  17591. * @param particleSystem Define the particle system to render
  17592. */
  17593. dispatchParticles(particleSystem: IParticleSystem): void;
  17594. /**
  17595. * Add a submesh to the manager in order to render it this frame
  17596. * @param subMesh The submesh to dispatch
  17597. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17598. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17599. */
  17600. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17601. /**
  17602. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17603. * This allowed control for front to back rendering or reversly depending of the special needs.
  17604. *
  17605. * @param renderingGroupId The rendering group id corresponding to its index
  17606. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17607. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17608. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17609. */
  17610. 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;
  17611. /**
  17612. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17613. *
  17614. * @param renderingGroupId The rendering group id corresponding to its index
  17615. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17616. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17617. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17618. */
  17619. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17620. /**
  17621. * Gets the current auto clear configuration for one rendering group of the rendering
  17622. * manager.
  17623. * @param index the rendering group index to get the information for
  17624. * @returns The auto clear setup for the requested rendering group
  17625. */
  17626. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17627. }
  17628. }
  17629. declare module BABYLON {
  17630. /**
  17631. * This Helps creating a texture that will be created from a camera in your scene.
  17632. * It is basically a dynamic texture that could be used to create special effects for instance.
  17633. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17634. */
  17635. export class RenderTargetTexture extends Texture {
  17636. isCube: boolean;
  17637. /**
  17638. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17639. */
  17640. static readonly REFRESHRATE_RENDER_ONCE: number;
  17641. /**
  17642. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17643. */
  17644. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17645. /**
  17646. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17647. * the central point of your effect and can save a lot of performances.
  17648. */
  17649. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17650. /**
  17651. * Use this predicate to dynamically define the list of mesh you want to render.
  17652. * If set, the renderList property will be overwritten.
  17653. */
  17654. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17655. private _renderList;
  17656. /**
  17657. * Use this list to define the list of mesh you want to render.
  17658. */
  17659. renderList: Nullable<Array<AbstractMesh>>;
  17660. private _hookArray;
  17661. /**
  17662. * Define if particles should be rendered in your texture.
  17663. */
  17664. renderParticles: boolean;
  17665. /**
  17666. * Define if sprites should be rendered in your texture.
  17667. */
  17668. renderSprites: boolean;
  17669. /**
  17670. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17671. */
  17672. coordinatesMode: number;
  17673. /**
  17674. * Define the camera used to render the texture.
  17675. */
  17676. activeCamera: Nullable<Camera>;
  17677. /**
  17678. * Override the render function of the texture with your own one.
  17679. */
  17680. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17681. /**
  17682. * Define if camera post processes should be use while rendering the texture.
  17683. */
  17684. useCameraPostProcesses: boolean;
  17685. /**
  17686. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17687. */
  17688. ignoreCameraViewport: boolean;
  17689. private _postProcessManager;
  17690. private _postProcesses;
  17691. private _resizeObserver;
  17692. /**
  17693. * An event triggered when the texture is unbind.
  17694. */
  17695. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17696. /**
  17697. * An event triggered when the texture is unbind.
  17698. */
  17699. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17700. private _onAfterUnbindObserver;
  17701. /**
  17702. * Set a after unbind callback in the texture.
  17703. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17704. */
  17705. onAfterUnbind: () => void;
  17706. /**
  17707. * An event triggered before rendering the texture
  17708. */
  17709. onBeforeRenderObservable: Observable<number>;
  17710. private _onBeforeRenderObserver;
  17711. /**
  17712. * Set a before render callback in the texture.
  17713. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17714. */
  17715. onBeforeRender: (faceIndex: number) => void;
  17716. /**
  17717. * An event triggered after rendering the texture
  17718. */
  17719. onAfterRenderObservable: Observable<number>;
  17720. private _onAfterRenderObserver;
  17721. /**
  17722. * Set a after render callback in the texture.
  17723. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17724. */
  17725. onAfterRender: (faceIndex: number) => void;
  17726. /**
  17727. * An event triggered after the texture clear
  17728. */
  17729. onClearObservable: Observable<Engine>;
  17730. private _onClearObserver;
  17731. /**
  17732. * Set a clear callback in the texture.
  17733. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17734. */
  17735. onClear: (Engine: Engine) => void;
  17736. /**
  17737. * Define the clear color of the Render Target if it should be different from the scene.
  17738. */
  17739. clearColor: Color4;
  17740. protected _size: number | {
  17741. width: number;
  17742. height: number;
  17743. };
  17744. protected _initialSizeParameter: number | {
  17745. width: number;
  17746. height: number;
  17747. } | {
  17748. ratio: number;
  17749. };
  17750. protected _sizeRatio: Nullable<number>;
  17751. /** @hidden */
  17752. _generateMipMaps: boolean;
  17753. protected _renderingManager: RenderingManager;
  17754. /** @hidden */
  17755. _waitingRenderList: string[];
  17756. protected _doNotChangeAspectRatio: boolean;
  17757. protected _currentRefreshId: number;
  17758. protected _refreshRate: number;
  17759. protected _textureMatrix: Matrix;
  17760. protected _samples: number;
  17761. protected _renderTargetOptions: RenderTargetCreationOptions;
  17762. /**
  17763. * Gets render target creation options that were used.
  17764. */
  17765. readonly renderTargetOptions: RenderTargetCreationOptions;
  17766. protected _engine: Engine;
  17767. protected _onRatioRescale(): void;
  17768. /**
  17769. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17770. * It must define where the camera used to render the texture is set
  17771. */
  17772. boundingBoxPosition: Vector3;
  17773. private _boundingBoxSize;
  17774. /**
  17775. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17776. * When defined, the cubemap will switch to local mode
  17777. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17778. * @example https://www.babylonjs-playground.com/#RNASML
  17779. */
  17780. boundingBoxSize: Vector3;
  17781. /**
  17782. * In case the RTT has been created with a depth texture, get the associated
  17783. * depth texture.
  17784. * Otherwise, return null.
  17785. */
  17786. depthStencilTexture: Nullable<InternalTexture>;
  17787. /**
  17788. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17789. * or used a shadow, depth texture...
  17790. * @param name The friendly name of the texture
  17791. * @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)
  17792. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17793. * @param generateMipMaps True if mip maps need to be generated after render.
  17794. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17795. * @param type The type of the buffer in the RTT (int, half float, float...)
  17796. * @param isCube True if a cube texture needs to be created
  17797. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17798. * @param generateDepthBuffer True to generate a depth buffer
  17799. * @param generateStencilBuffer True to generate a stencil buffer
  17800. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17801. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17802. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17803. */
  17804. constructor(name: string, size: number | {
  17805. width: number;
  17806. height: number;
  17807. } | {
  17808. ratio: number;
  17809. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17810. /**
  17811. * Creates a depth stencil texture.
  17812. * This is only available in WebGL 2 or with the depth texture extension available.
  17813. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17814. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17815. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17816. */
  17817. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17818. private _processSizeParameter;
  17819. /**
  17820. * Define the number of samples to use in case of MSAA.
  17821. * It defaults to one meaning no MSAA has been enabled.
  17822. */
  17823. samples: number;
  17824. /**
  17825. * Resets the refresh counter of the texture and start bak from scratch.
  17826. * Could be useful to regenerate the texture if it is setup to render only once.
  17827. */
  17828. resetRefreshCounter(): void;
  17829. /**
  17830. * Define the refresh rate of the texture or the rendering frequency.
  17831. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17832. */
  17833. refreshRate: number;
  17834. /**
  17835. * Adds a post process to the render target rendering passes.
  17836. * @param postProcess define the post process to add
  17837. */
  17838. addPostProcess(postProcess: PostProcess): void;
  17839. /**
  17840. * Clear all the post processes attached to the render target
  17841. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17842. */
  17843. clearPostProcesses(dispose?: boolean): void;
  17844. /**
  17845. * Remove one of the post process from the list of attached post processes to the texture
  17846. * @param postProcess define the post process to remove from the list
  17847. */
  17848. removePostProcess(postProcess: PostProcess): void;
  17849. /** @hidden */
  17850. _shouldRender(): boolean;
  17851. /**
  17852. * Gets the actual render size of the texture.
  17853. * @returns the width of the render size
  17854. */
  17855. getRenderSize(): number;
  17856. /**
  17857. * Gets the actual render width of the texture.
  17858. * @returns the width of the render size
  17859. */
  17860. getRenderWidth(): number;
  17861. /**
  17862. * Gets the actual render height of the texture.
  17863. * @returns the height of the render size
  17864. */
  17865. getRenderHeight(): number;
  17866. /**
  17867. * Get if the texture can be rescaled or not.
  17868. */
  17869. readonly canRescale: boolean;
  17870. /**
  17871. * Resize the texture using a ratio.
  17872. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17873. */
  17874. scale(ratio: number): void;
  17875. /**
  17876. * Get the texture reflection matrix used to rotate/transform the reflection.
  17877. * @returns the reflection matrix
  17878. */
  17879. getReflectionTextureMatrix(): Matrix;
  17880. /**
  17881. * Resize the texture to a new desired size.
  17882. * Be carrefull as it will recreate all the data in the new texture.
  17883. * @param size Define the new size. It can be:
  17884. * - a number for squared texture,
  17885. * - an object containing { width: number, height: number }
  17886. * - or an object containing a ratio { ratio: number }
  17887. */
  17888. resize(size: number | {
  17889. width: number;
  17890. height: number;
  17891. } | {
  17892. ratio: number;
  17893. }): void;
  17894. /**
  17895. * Renders all the objects from the render list into the texture.
  17896. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17897. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17898. */
  17899. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17900. private _bestReflectionRenderTargetDimension;
  17901. /**
  17902. * @hidden
  17903. * @param faceIndex face index to bind to if this is a cubetexture
  17904. */
  17905. _bindFrameBuffer(faceIndex?: number): void;
  17906. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17907. private renderToTarget;
  17908. /**
  17909. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17910. * This allowed control for front to back rendering or reversly depending of the special needs.
  17911. *
  17912. * @param renderingGroupId The rendering group id corresponding to its index
  17913. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17914. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17915. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17916. */
  17917. 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;
  17918. /**
  17919. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17920. *
  17921. * @param renderingGroupId The rendering group id corresponding to its index
  17922. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17923. */
  17924. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17925. /**
  17926. * Clones the texture.
  17927. * @returns the cloned texture
  17928. */
  17929. clone(): RenderTargetTexture;
  17930. /**
  17931. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17932. * @returns The JSON representation of the texture
  17933. */
  17934. serialize(): any;
  17935. /**
  17936. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17937. */
  17938. disposeFramebufferObjects(): void;
  17939. /**
  17940. * Dispose the texture and release its associated resources.
  17941. */
  17942. dispose(): void;
  17943. /** @hidden */
  17944. _rebuild(): void;
  17945. /**
  17946. * Clear the info related to rendering groups preventing retention point in material dispose.
  17947. */
  17948. freeRenderingGroups(): void;
  17949. /**
  17950. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17951. * @returns the view count
  17952. */
  17953. getViewCount(): number;
  17954. }
  17955. }
  17956. declare module BABYLON {
  17957. /**
  17958. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17959. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17960. * You can then easily use it as a reflectionTexture on a flat surface.
  17961. * In case the surface is not a plane, please consider relying on reflection probes.
  17962. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17963. */
  17964. export class MirrorTexture extends RenderTargetTexture {
  17965. private scene;
  17966. /**
  17967. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17968. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  17969. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17970. */
  17971. mirrorPlane: Plane;
  17972. /**
  17973. * Define the blur ratio used to blur the reflection if needed.
  17974. */
  17975. blurRatio: number;
  17976. /**
  17977. * Define the adaptive blur kernel used to blur the reflection if needed.
  17978. * This will autocompute the closest best match for the `blurKernel`
  17979. */
  17980. adaptiveBlurKernel: number;
  17981. /**
  17982. * Define the blur kernel used to blur the reflection if needed.
  17983. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17984. */
  17985. blurKernel: number;
  17986. /**
  17987. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17988. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17989. */
  17990. blurKernelX: number;
  17991. /**
  17992. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17993. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17994. */
  17995. blurKernelY: number;
  17996. private _autoComputeBlurKernel;
  17997. protected _onRatioRescale(): void;
  17998. private _updateGammaSpace;
  17999. private _imageProcessingConfigChangeObserver;
  18000. private _transformMatrix;
  18001. private _mirrorMatrix;
  18002. private _savedViewMatrix;
  18003. private _blurX;
  18004. private _blurY;
  18005. private _adaptiveBlurKernel;
  18006. private _blurKernelX;
  18007. private _blurKernelY;
  18008. private _blurRatio;
  18009. /**
  18010. * Instantiates a Mirror Texture.
  18011. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18012. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18013. * You can then easily use it as a reflectionTexture on a flat surface.
  18014. * In case the surface is not a plane, please consider relying on reflection probes.
  18015. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18016. * @param name
  18017. * @param size
  18018. * @param scene
  18019. * @param generateMipMaps
  18020. * @param type
  18021. * @param samplingMode
  18022. * @param generateDepthBuffer
  18023. */
  18024. constructor(name: string, size: number | {
  18025. width: number;
  18026. height: number;
  18027. } | {
  18028. ratio: number;
  18029. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18030. private _preparePostProcesses;
  18031. /**
  18032. * Clone the mirror texture.
  18033. * @returns the cloned texture
  18034. */
  18035. clone(): MirrorTexture;
  18036. /**
  18037. * Serialize the texture to a JSON representation you could use in Parse later on
  18038. * @returns the serialized JSON representation
  18039. */
  18040. serialize(): any;
  18041. /**
  18042. * Dispose the texture and release its associated resources.
  18043. */
  18044. dispose(): void;
  18045. }
  18046. }
  18047. declare module BABYLON {
  18048. /**
  18049. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18050. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18051. */
  18052. export class Texture extends BaseTexture {
  18053. /** @hidden */
  18054. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18055. /** @hidden */
  18056. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18057. /** @hidden */
  18058. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18059. /** nearest is mag = nearest and min = nearest and mip = linear */
  18060. static readonly NEAREST_SAMPLINGMODE: number;
  18061. /** nearest is mag = nearest and min = nearest and mip = linear */
  18062. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18063. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18064. static readonly BILINEAR_SAMPLINGMODE: number;
  18065. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18066. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18067. /** Trilinear is mag = linear and min = linear and mip = linear */
  18068. static readonly TRILINEAR_SAMPLINGMODE: number;
  18069. /** Trilinear is mag = linear and min = linear and mip = linear */
  18070. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18071. /** mag = nearest and min = nearest and mip = nearest */
  18072. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18073. /** mag = nearest and min = linear and mip = nearest */
  18074. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18075. /** mag = nearest and min = linear and mip = linear */
  18076. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18077. /** mag = nearest and min = linear and mip = none */
  18078. static readonly NEAREST_LINEAR: number;
  18079. /** mag = nearest and min = nearest and mip = none */
  18080. static readonly NEAREST_NEAREST: number;
  18081. /** mag = linear and min = nearest and mip = nearest */
  18082. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18083. /** mag = linear and min = nearest and mip = linear */
  18084. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18085. /** mag = linear and min = linear and mip = none */
  18086. static readonly LINEAR_LINEAR: number;
  18087. /** mag = linear and min = nearest and mip = none */
  18088. static readonly LINEAR_NEAREST: number;
  18089. /** Explicit coordinates mode */
  18090. static readonly EXPLICIT_MODE: number;
  18091. /** Spherical coordinates mode */
  18092. static readonly SPHERICAL_MODE: number;
  18093. /** Planar coordinates mode */
  18094. static readonly PLANAR_MODE: number;
  18095. /** Cubic coordinates mode */
  18096. static readonly CUBIC_MODE: number;
  18097. /** Projection coordinates mode */
  18098. static readonly PROJECTION_MODE: number;
  18099. /** Inverse Cubic coordinates mode */
  18100. static readonly SKYBOX_MODE: number;
  18101. /** Inverse Cubic coordinates mode */
  18102. static readonly INVCUBIC_MODE: number;
  18103. /** Equirectangular coordinates mode */
  18104. static readonly EQUIRECTANGULAR_MODE: number;
  18105. /** Equirectangular Fixed coordinates mode */
  18106. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18107. /** Equirectangular Fixed Mirrored coordinates mode */
  18108. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18109. /** Texture is not repeating outside of 0..1 UVs */
  18110. static readonly CLAMP_ADDRESSMODE: number;
  18111. /** Texture is repeating outside of 0..1 UVs */
  18112. static readonly WRAP_ADDRESSMODE: number;
  18113. /** Texture is repeating and mirrored */
  18114. static readonly MIRROR_ADDRESSMODE: number;
  18115. /**
  18116. * 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
  18117. */
  18118. static UseSerializedUrlIfAny: boolean;
  18119. /**
  18120. * Define the url of the texture.
  18121. */
  18122. url: Nullable<string>;
  18123. /**
  18124. * Define an offset on the texture to offset the u coordinates of the UVs
  18125. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18126. */
  18127. uOffset: number;
  18128. /**
  18129. * Define an offset on the texture to offset the v coordinates of the UVs
  18130. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18131. */
  18132. vOffset: number;
  18133. /**
  18134. * Define an offset on the texture to scale the u coordinates of the UVs
  18135. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18136. */
  18137. uScale: number;
  18138. /**
  18139. * Define an offset on the texture to scale the v coordinates of the UVs
  18140. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18141. */
  18142. vScale: number;
  18143. /**
  18144. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18145. * @see http://doc.babylonjs.com/how_to/more_materials
  18146. */
  18147. uAng: number;
  18148. /**
  18149. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18150. * @see http://doc.babylonjs.com/how_to/more_materials
  18151. */
  18152. vAng: number;
  18153. /**
  18154. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18155. * @see http://doc.babylonjs.com/how_to/more_materials
  18156. */
  18157. wAng: number;
  18158. /**
  18159. * Defines the center of rotation (U)
  18160. */
  18161. uRotationCenter: number;
  18162. /**
  18163. * Defines the center of rotation (V)
  18164. */
  18165. vRotationCenter: number;
  18166. /**
  18167. * Defines the center of rotation (W)
  18168. */
  18169. wRotationCenter: number;
  18170. /**
  18171. * Are mip maps generated for this texture or not.
  18172. */
  18173. readonly noMipmap: boolean;
  18174. /**
  18175. * List of inspectable custom properties (used by the Inspector)
  18176. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18177. */
  18178. inspectableCustomProperties: Nullable<IInspectable[]>;
  18179. private _noMipmap;
  18180. /** @hidden */
  18181. _invertY: boolean;
  18182. private _rowGenerationMatrix;
  18183. private _cachedTextureMatrix;
  18184. private _projectionModeMatrix;
  18185. private _t0;
  18186. private _t1;
  18187. private _t2;
  18188. private _cachedUOffset;
  18189. private _cachedVOffset;
  18190. private _cachedUScale;
  18191. private _cachedVScale;
  18192. private _cachedUAng;
  18193. private _cachedVAng;
  18194. private _cachedWAng;
  18195. private _cachedProjectionMatrixId;
  18196. private _cachedCoordinatesMode;
  18197. /** @hidden */
  18198. protected _initialSamplingMode: number;
  18199. /** @hidden */
  18200. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18201. private _deleteBuffer;
  18202. protected _format: Nullable<number>;
  18203. private _delayedOnLoad;
  18204. private _delayedOnError;
  18205. /**
  18206. * Observable triggered once the texture has been loaded.
  18207. */
  18208. onLoadObservable: Observable<Texture>;
  18209. protected _isBlocking: boolean;
  18210. /**
  18211. * Is the texture preventing material to render while loading.
  18212. * If false, a default texture will be used instead of the loading one during the preparation step.
  18213. */
  18214. isBlocking: boolean;
  18215. /**
  18216. * Get the current sampling mode associated with the texture.
  18217. */
  18218. readonly samplingMode: number;
  18219. /**
  18220. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18221. */
  18222. readonly invertY: boolean;
  18223. /**
  18224. * Instantiates a new texture.
  18225. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18226. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18227. * @param url define the url of the picture to load as a texture
  18228. * @param scene define the scene the texture will belong to
  18229. * @param noMipmap define if the texture will require mip maps or not
  18230. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18231. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18232. * @param onLoad define a callback triggered when the texture has been loaded
  18233. * @param onError define a callback triggered when an error occurred during the loading session
  18234. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18235. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18236. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18237. */
  18238. 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);
  18239. /**
  18240. * Update the url (and optional buffer) of this texture if url was null during construction.
  18241. * @param url the url of the texture
  18242. * @param buffer the buffer of the texture (defaults to null)
  18243. * @param onLoad callback called when the texture is loaded (defaults to null)
  18244. */
  18245. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18246. /**
  18247. * Finish the loading sequence of a texture flagged as delayed load.
  18248. * @hidden
  18249. */
  18250. delayLoad(): void;
  18251. private _prepareRowForTextureGeneration;
  18252. /**
  18253. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18254. * @returns the transform matrix of the texture.
  18255. */
  18256. getTextureMatrix(): Matrix;
  18257. /**
  18258. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18259. * @returns The reflection texture transform
  18260. */
  18261. getReflectionTextureMatrix(): Matrix;
  18262. /**
  18263. * Clones the texture.
  18264. * @returns the cloned texture
  18265. */
  18266. clone(): Texture;
  18267. /**
  18268. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18269. * @returns The JSON representation of the texture
  18270. */
  18271. serialize(): any;
  18272. /**
  18273. * Get the current class name of the texture useful for serialization or dynamic coding.
  18274. * @returns "Texture"
  18275. */
  18276. getClassName(): string;
  18277. /**
  18278. * Dispose the texture and release its associated resources.
  18279. */
  18280. dispose(): void;
  18281. /**
  18282. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18283. * @param parsedTexture Define the JSON representation of the texture
  18284. * @param scene Define the scene the parsed texture should be instantiated in
  18285. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18286. * @returns The parsed texture if successful
  18287. */
  18288. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18289. /**
  18290. * Creates a texture from its base 64 representation.
  18291. * @param data Define the base64 payload without the data: prefix
  18292. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18293. * @param scene Define the scene the texture should belong to
  18294. * @param noMipmap Forces the texture to not create mip map information if true
  18295. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18296. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18297. * @param onLoad define a callback triggered when the texture has been loaded
  18298. * @param onError define a callback triggered when an error occurred during the loading session
  18299. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18300. * @returns the created texture
  18301. */
  18302. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18303. /**
  18304. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18305. * @param data Define the base64 payload without the data: prefix
  18306. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18307. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18308. * @param scene Define the scene the texture should belong to
  18309. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18310. * @param noMipmap Forces the texture to not create mip map information if true
  18311. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18312. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18313. * @param onLoad define a callback triggered when the texture has been loaded
  18314. * @param onError define a callback triggered when an error occurred during the loading session
  18315. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18316. * @returns the created texture
  18317. */
  18318. 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;
  18319. }
  18320. }
  18321. declare module BABYLON {
  18322. interface Engine {
  18323. /**
  18324. * Creates a raw texture
  18325. * @param data defines the data to store in the texture
  18326. * @param width defines the width of the texture
  18327. * @param height defines the height of the texture
  18328. * @param format defines the format of the data
  18329. * @param generateMipMaps defines if the engine should generate the mip levels
  18330. * @param invertY defines if data must be stored with Y axis inverted
  18331. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18332. * @param compression defines the compression used (null by default)
  18333. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18334. * @returns the raw texture inside an InternalTexture
  18335. */
  18336. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18337. /**
  18338. * Update a raw texture
  18339. * @param texture defines the texture to update
  18340. * @param data defines the data to store in the texture
  18341. * @param format defines the format of the data
  18342. * @param invertY defines if data must be stored with Y axis inverted
  18343. */
  18344. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18345. /**
  18346. * Update a raw texture
  18347. * @param texture defines the texture to update
  18348. * @param data defines the data to store in the texture
  18349. * @param format defines the format of the data
  18350. * @param invertY defines if data must be stored with Y axis inverted
  18351. * @param compression defines the compression used (null by default)
  18352. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18353. */
  18354. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18355. /**
  18356. * Creates a new raw cube texture
  18357. * @param data defines the array of data to use to create each face
  18358. * @param size defines the size of the textures
  18359. * @param format defines the format of the data
  18360. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18361. * @param generateMipMaps defines if the engine should generate the mip levels
  18362. * @param invertY defines if data must be stored with Y axis inverted
  18363. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18364. * @param compression defines the compression used (null by default)
  18365. * @returns the cube texture as an InternalTexture
  18366. */
  18367. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18368. /**
  18369. * Update a raw cube texture
  18370. * @param texture defines the texture to udpdate
  18371. * @param data defines the data to store
  18372. * @param format defines the data format
  18373. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18374. * @param invertY defines if data must be stored with Y axis inverted
  18375. */
  18376. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18377. /**
  18378. * Update a raw cube texture
  18379. * @param texture defines the texture to udpdate
  18380. * @param data defines the data to store
  18381. * @param format defines the data format
  18382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18383. * @param invertY defines if data must be stored with Y axis inverted
  18384. * @param compression defines the compression used (null by default)
  18385. */
  18386. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18387. /**
  18388. * Update a raw cube texture
  18389. * @param texture defines the texture to udpdate
  18390. * @param data defines the data to store
  18391. * @param format defines the data format
  18392. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18393. * @param invertY defines if data must be stored with Y axis inverted
  18394. * @param compression defines the compression used (null by default)
  18395. * @param level defines which level of the texture to update
  18396. */
  18397. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18398. /**
  18399. * Creates a new raw cube texture from a specified url
  18400. * @param url defines the url where the data is located
  18401. * @param scene defines the current scene
  18402. * @param size defines the size of the textures
  18403. * @param format defines the format of the data
  18404. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18405. * @param noMipmap defines if the engine should avoid generating the mip levels
  18406. * @param callback defines a callback used to extract texture data from loaded data
  18407. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18408. * @param onLoad defines a callback called when texture is loaded
  18409. * @param onError defines a callback called if there is an error
  18410. * @returns the cube texture as an InternalTexture
  18411. */
  18412. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  18413. /**
  18414. * Creates a new raw cube texture from a specified url
  18415. * @param url defines the url where the data is located
  18416. * @param scene defines the current scene
  18417. * @param size defines the size of the textures
  18418. * @param format defines the format of the data
  18419. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18420. * @param noMipmap defines if the engine should avoid generating the mip levels
  18421. * @param callback defines a callback used to extract texture data from loaded data
  18422. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18423. * @param onLoad defines a callback called when texture is loaded
  18424. * @param onError defines a callback called if there is an error
  18425. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18426. * @param invertY defines if data must be stored with Y axis inverted
  18427. * @returns the cube texture as an InternalTexture
  18428. */
  18429. 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;
  18430. /**
  18431. * Creates a new raw 3D texture
  18432. * @param data defines the data used to create the texture
  18433. * @param width defines the width of the texture
  18434. * @param height defines the height of the texture
  18435. * @param depth defines the depth of the texture
  18436. * @param format defines the format of the texture
  18437. * @param generateMipMaps defines if the engine must generate mip levels
  18438. * @param invertY defines if data must be stored with Y axis inverted
  18439. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18440. * @param compression defines the compressed used (can be null)
  18441. * @param textureType defines the compressed used (can be null)
  18442. * @returns a new raw 3D texture (stored in an InternalTexture)
  18443. */
  18444. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18445. /**
  18446. * Update a raw 3D texture
  18447. * @param texture defines the texture to update
  18448. * @param data defines the data to store
  18449. * @param format defines the data format
  18450. * @param invertY defines if data must be stored with Y axis inverted
  18451. */
  18452. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18453. /**
  18454. * Update a raw 3D texture
  18455. * @param texture defines the texture to update
  18456. * @param data defines the data to store
  18457. * @param format defines the data format
  18458. * @param invertY defines if data must be stored with Y axis inverted
  18459. * @param compression defines the used compression (can be null)
  18460. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18461. */
  18462. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18463. }
  18464. }
  18465. declare module BABYLON {
  18466. /**
  18467. * Raw texture can help creating a texture directly from an array of data.
  18468. * This can be super useful if you either get the data from an uncompressed source or
  18469. * if you wish to create your texture pixel by pixel.
  18470. */
  18471. export class RawTexture extends Texture {
  18472. /**
  18473. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18474. */
  18475. format: number;
  18476. private _engine;
  18477. /**
  18478. * Instantiates a new RawTexture.
  18479. * Raw texture can help creating a texture directly from an array of data.
  18480. * This can be super useful if you either get the data from an uncompressed source or
  18481. * if you wish to create your texture pixel by pixel.
  18482. * @param data define the array of data to use to create the texture
  18483. * @param width define the width of the texture
  18484. * @param height define the height of the texture
  18485. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18486. * @param scene define the scene the texture belongs to
  18487. * @param generateMipMaps define whether mip maps should be generated or not
  18488. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18489. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18490. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18491. */
  18492. constructor(data: ArrayBufferView, width: number, height: number,
  18493. /**
  18494. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18495. */
  18496. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18497. /**
  18498. * Updates the texture underlying data.
  18499. * @param data Define the new data of the texture
  18500. */
  18501. update(data: ArrayBufferView): void;
  18502. /**
  18503. * Creates a luminance texture from some data.
  18504. * @param data Define the texture data
  18505. * @param width Define the width of the texture
  18506. * @param height Define the height of the texture
  18507. * @param scene Define the scene the texture belongs to
  18508. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18509. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18510. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18511. * @returns the luminance texture
  18512. */
  18513. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18514. /**
  18515. * Creates a luminance alpha texture from some data.
  18516. * @param data Define the texture data
  18517. * @param width Define the width of the texture
  18518. * @param height Define the height of the texture
  18519. * @param scene Define the scene the texture belongs to
  18520. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18521. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18522. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18523. * @returns the luminance alpha texture
  18524. */
  18525. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18526. /**
  18527. * Creates an alpha texture from some data.
  18528. * @param data Define the texture data
  18529. * @param width Define the width of the texture
  18530. * @param height Define the height of the texture
  18531. * @param scene Define the scene the texture belongs to
  18532. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18533. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18534. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18535. * @returns the alpha texture
  18536. */
  18537. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18538. /**
  18539. * Creates a RGB texture from some data.
  18540. * @param data Define the texture data
  18541. * @param width Define the width of the texture
  18542. * @param height Define the height of the texture
  18543. * @param scene Define the scene the texture belongs to
  18544. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18545. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18546. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18547. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18548. * @returns the RGB alpha texture
  18549. */
  18550. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18551. /**
  18552. * Creates a RGBA texture from some data.
  18553. * @param data Define the texture data
  18554. * @param width Define the width of the texture
  18555. * @param height Define the height of the texture
  18556. * @param scene Define the scene the texture belongs to
  18557. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18560. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18561. * @returns the RGBA texture
  18562. */
  18563. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18564. /**
  18565. * Creates a R texture from some data.
  18566. * @param data Define the texture data
  18567. * @param width Define the width of the texture
  18568. * @param height Define the height of the texture
  18569. * @param scene Define the scene the texture belongs to
  18570. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18571. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18572. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18573. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18574. * @returns the R texture
  18575. */
  18576. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18577. }
  18578. }
  18579. declare module BABYLON {
  18580. /**
  18581. * Defines a runtime animation
  18582. */
  18583. export class RuntimeAnimation {
  18584. private _events;
  18585. /**
  18586. * The current frame of the runtime animation
  18587. */
  18588. private _currentFrame;
  18589. /**
  18590. * The animation used by the runtime animation
  18591. */
  18592. private _animation;
  18593. /**
  18594. * The target of the runtime animation
  18595. */
  18596. private _target;
  18597. /**
  18598. * The initiating animatable
  18599. */
  18600. private _host;
  18601. /**
  18602. * The original value of the runtime animation
  18603. */
  18604. private _originalValue;
  18605. /**
  18606. * The original blend value of the runtime animation
  18607. */
  18608. private _originalBlendValue;
  18609. /**
  18610. * The offsets cache of the runtime animation
  18611. */
  18612. private _offsetsCache;
  18613. /**
  18614. * The high limits cache of the runtime animation
  18615. */
  18616. private _highLimitsCache;
  18617. /**
  18618. * Specifies if the runtime animation has been stopped
  18619. */
  18620. private _stopped;
  18621. /**
  18622. * The blending factor of the runtime animation
  18623. */
  18624. private _blendingFactor;
  18625. /**
  18626. * The BabylonJS scene
  18627. */
  18628. private _scene;
  18629. /**
  18630. * The current value of the runtime animation
  18631. */
  18632. private _currentValue;
  18633. /** @hidden */
  18634. _animationState: _IAnimationState;
  18635. /**
  18636. * The active target of the runtime animation
  18637. */
  18638. private _activeTargets;
  18639. private _currentActiveTarget;
  18640. private _directTarget;
  18641. /**
  18642. * The target path of the runtime animation
  18643. */
  18644. private _targetPath;
  18645. /**
  18646. * The weight of the runtime animation
  18647. */
  18648. private _weight;
  18649. /**
  18650. * The ratio offset of the runtime animation
  18651. */
  18652. private _ratioOffset;
  18653. /**
  18654. * The previous delay of the runtime animation
  18655. */
  18656. private _previousDelay;
  18657. /**
  18658. * The previous ratio of the runtime animation
  18659. */
  18660. private _previousRatio;
  18661. private _enableBlending;
  18662. private _keys;
  18663. private _minFrame;
  18664. private _maxFrame;
  18665. private _minValue;
  18666. private _maxValue;
  18667. private _targetIsArray;
  18668. /**
  18669. * Gets the current frame of the runtime animation
  18670. */
  18671. readonly currentFrame: number;
  18672. /**
  18673. * Gets the weight of the runtime animation
  18674. */
  18675. readonly weight: number;
  18676. /**
  18677. * Gets the current value of the runtime animation
  18678. */
  18679. readonly currentValue: any;
  18680. /**
  18681. * Gets the target path of the runtime animation
  18682. */
  18683. readonly targetPath: string;
  18684. /**
  18685. * Gets the actual target of the runtime animation
  18686. */
  18687. readonly target: any;
  18688. /** @hidden */
  18689. _onLoop: () => void;
  18690. /**
  18691. * Create a new RuntimeAnimation object
  18692. * @param target defines the target of the animation
  18693. * @param animation defines the source animation object
  18694. * @param scene defines the hosting scene
  18695. * @param host defines the initiating Animatable
  18696. */
  18697. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18698. private _preparePath;
  18699. /**
  18700. * Gets the animation from the runtime animation
  18701. */
  18702. readonly animation: Animation;
  18703. /**
  18704. * Resets the runtime animation to the beginning
  18705. * @param restoreOriginal defines whether to restore the target property to the original value
  18706. */
  18707. reset(restoreOriginal?: boolean): void;
  18708. /**
  18709. * Specifies if the runtime animation is stopped
  18710. * @returns Boolean specifying if the runtime animation is stopped
  18711. */
  18712. isStopped(): boolean;
  18713. /**
  18714. * Disposes of the runtime animation
  18715. */
  18716. dispose(): void;
  18717. /**
  18718. * Apply the interpolated value to the target
  18719. * @param currentValue defines the value computed by the animation
  18720. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18721. */
  18722. setValue(currentValue: any, weight: number): void;
  18723. private _getOriginalValues;
  18724. private _setValue;
  18725. /**
  18726. * Gets the loop pmode of the runtime animation
  18727. * @returns Loop Mode
  18728. */
  18729. private _getCorrectLoopMode;
  18730. /**
  18731. * Move the current animation to a given frame
  18732. * @param frame defines the frame to move to
  18733. */
  18734. goToFrame(frame: number): void;
  18735. /**
  18736. * @hidden Internal use only
  18737. */
  18738. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18739. /**
  18740. * Execute the current animation
  18741. * @param delay defines the delay to add to the current frame
  18742. * @param from defines the lower bound of the animation range
  18743. * @param to defines the upper bound of the animation range
  18744. * @param loop defines if the current animation must loop
  18745. * @param speedRatio defines the current speed ratio
  18746. * @param weight defines the weight of the animation (default is -1 so no weight)
  18747. * @param onLoop optional callback called when animation loops
  18748. * @returns a boolean indicating if the animation is running
  18749. */
  18750. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18751. }
  18752. }
  18753. declare module BABYLON {
  18754. /**
  18755. * Class used to store an actual running animation
  18756. */
  18757. export class Animatable {
  18758. /** defines the target object */
  18759. target: any;
  18760. /** defines the starting frame number (default is 0) */
  18761. fromFrame: number;
  18762. /** defines the ending frame number (default is 100) */
  18763. toFrame: number;
  18764. /** defines if the animation must loop (default is false) */
  18765. loopAnimation: boolean;
  18766. /** defines a callback to call when animation ends if it is not looping */
  18767. onAnimationEnd?: (() => void) | null | undefined;
  18768. /** defines a callback to call when animation loops */
  18769. onAnimationLoop?: (() => void) | null | undefined;
  18770. private _localDelayOffset;
  18771. private _pausedDelay;
  18772. private _runtimeAnimations;
  18773. private _paused;
  18774. private _scene;
  18775. private _speedRatio;
  18776. private _weight;
  18777. private _syncRoot;
  18778. /**
  18779. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18780. * This will only apply for non looping animation (default is true)
  18781. */
  18782. disposeOnEnd: boolean;
  18783. /**
  18784. * Gets a boolean indicating if the animation has started
  18785. */
  18786. animationStarted: boolean;
  18787. /**
  18788. * Observer raised when the animation ends
  18789. */
  18790. onAnimationEndObservable: Observable<Animatable>;
  18791. /**
  18792. * Observer raised when the animation loops
  18793. */
  18794. onAnimationLoopObservable: Observable<Animatable>;
  18795. /**
  18796. * Gets the root Animatable used to synchronize and normalize animations
  18797. */
  18798. readonly syncRoot: Nullable<Animatable>;
  18799. /**
  18800. * Gets the current frame of the first RuntimeAnimation
  18801. * Used to synchronize Animatables
  18802. */
  18803. readonly masterFrame: number;
  18804. /**
  18805. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18806. */
  18807. weight: number;
  18808. /**
  18809. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18810. */
  18811. speedRatio: number;
  18812. /**
  18813. * Creates a new Animatable
  18814. * @param scene defines the hosting scene
  18815. * @param target defines the target object
  18816. * @param fromFrame defines the starting frame number (default is 0)
  18817. * @param toFrame defines the ending frame number (default is 100)
  18818. * @param loopAnimation defines if the animation must loop (default is false)
  18819. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18820. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18821. * @param animations defines a group of animation to add to the new Animatable
  18822. * @param onAnimationLoop defines a callback to call when animation loops
  18823. */
  18824. constructor(scene: Scene,
  18825. /** defines the target object */
  18826. target: any,
  18827. /** defines the starting frame number (default is 0) */
  18828. fromFrame?: number,
  18829. /** defines the ending frame number (default is 100) */
  18830. toFrame?: number,
  18831. /** defines if the animation must loop (default is false) */
  18832. loopAnimation?: boolean, speedRatio?: number,
  18833. /** defines a callback to call when animation ends if it is not looping */
  18834. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18835. /** defines a callback to call when animation loops */
  18836. onAnimationLoop?: (() => void) | null | undefined);
  18837. /**
  18838. * Synchronize and normalize current Animatable with a source Animatable
  18839. * This is useful when using animation weights and when animations are not of the same length
  18840. * @param root defines the root Animatable to synchronize with
  18841. * @returns the current Animatable
  18842. */
  18843. syncWith(root: Animatable): Animatable;
  18844. /**
  18845. * Gets the list of runtime animations
  18846. * @returns an array of RuntimeAnimation
  18847. */
  18848. getAnimations(): RuntimeAnimation[];
  18849. /**
  18850. * Adds more animations to the current animatable
  18851. * @param target defines the target of the animations
  18852. * @param animations defines the new animations to add
  18853. */
  18854. appendAnimations(target: any, animations: Animation[]): void;
  18855. /**
  18856. * Gets the source animation for a specific property
  18857. * @param property defines the propertyu to look for
  18858. * @returns null or the source animation for the given property
  18859. */
  18860. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18861. /**
  18862. * Gets the runtime animation for a specific property
  18863. * @param property defines the propertyu to look for
  18864. * @returns null or the runtime animation for the given property
  18865. */
  18866. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18867. /**
  18868. * Resets the animatable to its original state
  18869. */
  18870. reset(): void;
  18871. /**
  18872. * Allows the animatable to blend with current running animations
  18873. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18874. * @param blendingSpeed defines the blending speed to use
  18875. */
  18876. enableBlending(blendingSpeed: number): void;
  18877. /**
  18878. * Disable animation blending
  18879. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18880. */
  18881. disableBlending(): void;
  18882. /**
  18883. * Jump directly to a given frame
  18884. * @param frame defines the frame to jump to
  18885. */
  18886. goToFrame(frame: number): void;
  18887. /**
  18888. * Pause the animation
  18889. */
  18890. pause(): void;
  18891. /**
  18892. * Restart the animation
  18893. */
  18894. restart(): void;
  18895. private _raiseOnAnimationEnd;
  18896. /**
  18897. * Stop and delete the current animation
  18898. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18899. * @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)
  18900. */
  18901. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18902. /**
  18903. * Wait asynchronously for the animation to end
  18904. * @returns a promise which will be fullfilled when the animation ends
  18905. */
  18906. waitAsync(): Promise<Animatable>;
  18907. /** @hidden */
  18908. _animate(delay: number): boolean;
  18909. }
  18910. interface Scene {
  18911. /** @hidden */
  18912. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18913. /** @hidden */
  18914. _processLateAnimationBindingsForMatrices(holder: {
  18915. totalWeight: number;
  18916. animations: RuntimeAnimation[];
  18917. originalValue: Matrix;
  18918. }): any;
  18919. /** @hidden */
  18920. _processLateAnimationBindingsForQuaternions(holder: {
  18921. totalWeight: number;
  18922. animations: RuntimeAnimation[];
  18923. originalValue: Quaternion;
  18924. }, refQuaternion: Quaternion): Quaternion;
  18925. /** @hidden */
  18926. _processLateAnimationBindings(): void;
  18927. /**
  18928. * Will start the animation sequence of a given target
  18929. * @param target defines the target
  18930. * @param from defines from which frame should animation start
  18931. * @param to defines until which frame should animation run.
  18932. * @param weight defines the weight to apply to the animation (1.0 by default)
  18933. * @param loop defines if the animation loops
  18934. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18935. * @param onAnimationEnd defines the function to be executed when the animation ends
  18936. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18937. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18938. * @param onAnimationLoop defines the callback to call when an animation loops
  18939. * @returns the animatable object created for this animation
  18940. */
  18941. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18942. /**
  18943. * Will start the animation sequence of a given target
  18944. * @param target defines the target
  18945. * @param from defines from which frame should animation start
  18946. * @param to defines until which frame should animation run.
  18947. * @param loop defines if the animation loops
  18948. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18949. * @param onAnimationEnd defines the function to be executed when the animation ends
  18950. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18951. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18952. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18953. * @param onAnimationLoop defines the callback to call when an animation loops
  18954. * @returns the animatable object created for this animation
  18955. */
  18956. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18957. /**
  18958. * Will start the animation sequence of a given target and its hierarchy
  18959. * @param target defines the target
  18960. * @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.
  18961. * @param from defines from which frame should animation start
  18962. * @param to defines until which frame should animation run.
  18963. * @param loop defines if the animation loops
  18964. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18965. * @param onAnimationEnd defines the function to be executed when the animation ends
  18966. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18967. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18968. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18969. * @param onAnimationLoop defines the callback to call when an animation loops
  18970. * @returns the list of created animatables
  18971. */
  18972. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  18973. /**
  18974. * Begin a new animation on a given node
  18975. * @param target defines the target where the animation will take place
  18976. * @param animations defines the list of animations to start
  18977. * @param from defines the initial value
  18978. * @param to defines the final value
  18979. * @param loop defines if you want animation to loop (off by default)
  18980. * @param speedRatio defines the speed ratio to apply to all animations
  18981. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18982. * @param onAnimationLoop defines the callback to call when an animation loops
  18983. * @returns the list of created animatables
  18984. */
  18985. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18986. /**
  18987. * Begin a new animation on a given node and its hierarchy
  18988. * @param target defines the root node where the animation will take place
  18989. * @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.
  18990. * @param animations defines the list of animations to start
  18991. * @param from defines the initial value
  18992. * @param to defines the final value
  18993. * @param loop defines if you want animation to loop (off by default)
  18994. * @param speedRatio defines the speed ratio to apply to all animations
  18995. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18996. * @param onAnimationLoop defines the callback to call when an animation loops
  18997. * @returns the list of animatables created for all nodes
  18998. */
  18999. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19000. /**
  19001. * Gets the animatable associated with a specific target
  19002. * @param target defines the target of the animatable
  19003. * @returns the required animatable if found
  19004. */
  19005. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19006. /**
  19007. * Gets all animatables associated with a given target
  19008. * @param target defines the target to look animatables for
  19009. * @returns an array of Animatables
  19010. */
  19011. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19012. /**
  19013. * Will stop the animation of the given target
  19014. * @param target - the target
  19015. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19016. * @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)
  19017. */
  19018. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19019. /**
  19020. * Stops and removes all animations that have been applied to the scene
  19021. */
  19022. stopAllAnimations(): void;
  19023. }
  19024. interface Bone {
  19025. /**
  19026. * Copy an animation range from another bone
  19027. * @param source defines the source bone
  19028. * @param rangeName defines the range name to copy
  19029. * @param frameOffset defines the frame offset
  19030. * @param rescaleAsRequired defines if rescaling must be applied if required
  19031. * @param skelDimensionsRatio defines the scaling ratio
  19032. * @returns true if operation was successful
  19033. */
  19034. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19035. }
  19036. }
  19037. declare module BABYLON {
  19038. /**
  19039. * Class used to handle skinning animations
  19040. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19041. */
  19042. export class Skeleton implements IAnimatable {
  19043. /** defines the skeleton name */
  19044. name: string;
  19045. /** defines the skeleton Id */
  19046. id: string;
  19047. /**
  19048. * Defines the list of child bones
  19049. */
  19050. bones: Bone[];
  19051. /**
  19052. * Defines an estimate of the dimension of the skeleton at rest
  19053. */
  19054. dimensionsAtRest: Vector3;
  19055. /**
  19056. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19057. */
  19058. needInitialSkinMatrix: boolean;
  19059. /**
  19060. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19061. */
  19062. overrideMesh: Nullable<AbstractMesh>;
  19063. /**
  19064. * Gets the list of animations attached to this skeleton
  19065. */
  19066. animations: Array<Animation>;
  19067. private _scene;
  19068. private _isDirty;
  19069. private _transformMatrices;
  19070. private _transformMatrixTexture;
  19071. private _meshesWithPoseMatrix;
  19072. private _animatables;
  19073. private _identity;
  19074. private _synchronizedWithMesh;
  19075. private _ranges;
  19076. private _lastAbsoluteTransformsUpdateId;
  19077. private _canUseTextureForBones;
  19078. private _uniqueId;
  19079. /** @hidden */
  19080. _numBonesWithLinkedTransformNode: number;
  19081. /**
  19082. * Specifies if the skeleton should be serialized
  19083. */
  19084. doNotSerialize: boolean;
  19085. private _useTextureToStoreBoneMatrices;
  19086. /**
  19087. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19088. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19089. */
  19090. useTextureToStoreBoneMatrices: boolean;
  19091. private _animationPropertiesOverride;
  19092. /**
  19093. * Gets or sets the animation properties override
  19094. */
  19095. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19096. /**
  19097. * List of inspectable custom properties (used by the Inspector)
  19098. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19099. */
  19100. inspectableCustomProperties: IInspectable[];
  19101. /**
  19102. * An observable triggered before computing the skeleton's matrices
  19103. */
  19104. onBeforeComputeObservable: Observable<Skeleton>;
  19105. /**
  19106. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19107. */
  19108. readonly isUsingTextureForMatrices: boolean;
  19109. /**
  19110. * Gets the unique ID of this skeleton
  19111. */
  19112. readonly uniqueId: number;
  19113. /**
  19114. * Creates a new skeleton
  19115. * @param name defines the skeleton name
  19116. * @param id defines the skeleton Id
  19117. * @param scene defines the hosting scene
  19118. */
  19119. constructor(
  19120. /** defines the skeleton name */
  19121. name: string,
  19122. /** defines the skeleton Id */
  19123. id: string, scene: Scene);
  19124. /**
  19125. * Gets the current object class name.
  19126. * @return the class name
  19127. */
  19128. getClassName(): string;
  19129. /**
  19130. * Returns an array containing the root bones
  19131. * @returns an array containing the root bones
  19132. */
  19133. getChildren(): Array<Bone>;
  19134. /**
  19135. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19136. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19137. * @returns a Float32Array containing matrices data
  19138. */
  19139. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19140. /**
  19141. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19142. * @returns a raw texture containing the data
  19143. */
  19144. getTransformMatrixTexture(): Nullable<RawTexture>;
  19145. /**
  19146. * Gets the current hosting scene
  19147. * @returns a scene object
  19148. */
  19149. getScene(): Scene;
  19150. /**
  19151. * Gets a string representing the current skeleton data
  19152. * @param fullDetails defines a boolean indicating if we want a verbose version
  19153. * @returns a string representing the current skeleton data
  19154. */
  19155. toString(fullDetails?: boolean): string;
  19156. /**
  19157. * Get bone's index searching by name
  19158. * @param name defines bone's name to search for
  19159. * @return the indice of the bone. Returns -1 if not found
  19160. */
  19161. getBoneIndexByName(name: string): number;
  19162. /**
  19163. * Creater a new animation range
  19164. * @param name defines the name of the range
  19165. * @param from defines the start key
  19166. * @param to defines the end key
  19167. */
  19168. createAnimationRange(name: string, from: number, to: number): void;
  19169. /**
  19170. * Delete a specific animation range
  19171. * @param name defines the name of the range
  19172. * @param deleteFrames defines if frames must be removed as well
  19173. */
  19174. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19175. /**
  19176. * Gets a specific animation range
  19177. * @param name defines the name of the range to look for
  19178. * @returns the requested animation range or null if not found
  19179. */
  19180. getAnimationRange(name: string): Nullable<AnimationRange>;
  19181. /**
  19182. * Gets the list of all animation ranges defined on this skeleton
  19183. * @returns an array
  19184. */
  19185. getAnimationRanges(): Nullable<AnimationRange>[];
  19186. /**
  19187. * Copy animation range from a source skeleton.
  19188. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19189. * @param source defines the source skeleton
  19190. * @param name defines the name of the range to copy
  19191. * @param rescaleAsRequired defines if rescaling must be applied if required
  19192. * @returns true if operation was successful
  19193. */
  19194. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19195. /**
  19196. * Forces the skeleton to go to rest pose
  19197. */
  19198. returnToRest(): void;
  19199. private _getHighestAnimationFrame;
  19200. /**
  19201. * Begin a specific animation range
  19202. * @param name defines the name of the range to start
  19203. * @param loop defines if looping must be turned on (false by default)
  19204. * @param speedRatio defines the speed ratio to apply (1 by default)
  19205. * @param onAnimationEnd defines a callback which will be called when animation will end
  19206. * @returns a new animatable
  19207. */
  19208. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19209. /** @hidden */
  19210. _markAsDirty(): void;
  19211. /** @hidden */
  19212. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19213. /** @hidden */
  19214. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19215. private _computeTransformMatrices;
  19216. /**
  19217. * Build all resources required to render a skeleton
  19218. */
  19219. prepare(): void;
  19220. /**
  19221. * Gets the list of animatables currently running for this skeleton
  19222. * @returns an array of animatables
  19223. */
  19224. getAnimatables(): IAnimatable[];
  19225. /**
  19226. * Clone the current skeleton
  19227. * @param name defines the name of the new skeleton
  19228. * @param id defines the id of the new skeleton
  19229. * @returns the new skeleton
  19230. */
  19231. clone(name: string, id: string): Skeleton;
  19232. /**
  19233. * Enable animation blending for this skeleton
  19234. * @param blendingSpeed defines the blending speed to apply
  19235. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19236. */
  19237. enableBlending(blendingSpeed?: number): void;
  19238. /**
  19239. * Releases all resources associated with the current skeleton
  19240. */
  19241. dispose(): void;
  19242. /**
  19243. * Serialize the skeleton in a JSON object
  19244. * @returns a JSON object
  19245. */
  19246. serialize(): any;
  19247. /**
  19248. * Creates a new skeleton from serialized data
  19249. * @param parsedSkeleton defines the serialized data
  19250. * @param scene defines the hosting scene
  19251. * @returns a new skeleton
  19252. */
  19253. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19254. /**
  19255. * Compute all node absolute transforms
  19256. * @param forceUpdate defines if computation must be done even if cache is up to date
  19257. */
  19258. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19259. /**
  19260. * Gets the root pose matrix
  19261. * @returns a matrix
  19262. */
  19263. getPoseMatrix(): Nullable<Matrix>;
  19264. /**
  19265. * Sorts bones per internal index
  19266. */
  19267. sortBones(): void;
  19268. private _sortBones;
  19269. }
  19270. }
  19271. declare module BABYLON {
  19272. /**
  19273. * Defines a target to use with MorphTargetManager
  19274. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19275. */
  19276. export class MorphTarget implements IAnimatable {
  19277. /** defines the name of the target */
  19278. name: string;
  19279. /**
  19280. * Gets or sets the list of animations
  19281. */
  19282. animations: Animation[];
  19283. private _scene;
  19284. private _positions;
  19285. private _normals;
  19286. private _tangents;
  19287. private _influence;
  19288. /**
  19289. * Observable raised when the influence changes
  19290. */
  19291. onInfluenceChanged: Observable<boolean>;
  19292. /** @hidden */
  19293. _onDataLayoutChanged: Observable<void>;
  19294. /**
  19295. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19296. */
  19297. influence: number;
  19298. /**
  19299. * Gets or sets the id of the morph Target
  19300. */
  19301. id: string;
  19302. private _animationPropertiesOverride;
  19303. /**
  19304. * Gets or sets the animation properties override
  19305. */
  19306. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19307. /**
  19308. * Creates a new MorphTarget
  19309. * @param name defines the name of the target
  19310. * @param influence defines the influence to use
  19311. * @param scene defines the scene the morphtarget belongs to
  19312. */
  19313. constructor(
  19314. /** defines the name of the target */
  19315. name: string, influence?: number, scene?: Nullable<Scene>);
  19316. /**
  19317. * Gets a boolean defining if the target contains position data
  19318. */
  19319. readonly hasPositions: boolean;
  19320. /**
  19321. * Gets a boolean defining if the target contains normal data
  19322. */
  19323. readonly hasNormals: boolean;
  19324. /**
  19325. * Gets a boolean defining if the target contains tangent data
  19326. */
  19327. readonly hasTangents: boolean;
  19328. /**
  19329. * Affects position data to this target
  19330. * @param data defines the position data to use
  19331. */
  19332. setPositions(data: Nullable<FloatArray>): void;
  19333. /**
  19334. * Gets the position data stored in this target
  19335. * @returns a FloatArray containing the position data (or null if not present)
  19336. */
  19337. getPositions(): Nullable<FloatArray>;
  19338. /**
  19339. * Affects normal data to this target
  19340. * @param data defines the normal data to use
  19341. */
  19342. setNormals(data: Nullable<FloatArray>): void;
  19343. /**
  19344. * Gets the normal data stored in this target
  19345. * @returns a FloatArray containing the normal data (or null if not present)
  19346. */
  19347. getNormals(): Nullable<FloatArray>;
  19348. /**
  19349. * Affects tangent data to this target
  19350. * @param data defines the tangent data to use
  19351. */
  19352. setTangents(data: Nullable<FloatArray>): void;
  19353. /**
  19354. * Gets the tangent data stored in this target
  19355. * @returns a FloatArray containing the tangent data (or null if not present)
  19356. */
  19357. getTangents(): Nullable<FloatArray>;
  19358. /**
  19359. * Serializes the current target into a Serialization object
  19360. * @returns the serialized object
  19361. */
  19362. serialize(): any;
  19363. /**
  19364. * Returns the string "MorphTarget"
  19365. * @returns "MorphTarget"
  19366. */
  19367. getClassName(): string;
  19368. /**
  19369. * Creates a new target from serialized data
  19370. * @param serializationObject defines the serialized data to use
  19371. * @returns a new MorphTarget
  19372. */
  19373. static Parse(serializationObject: any): MorphTarget;
  19374. /**
  19375. * Creates a MorphTarget from mesh data
  19376. * @param mesh defines the source mesh
  19377. * @param name defines the name to use for the new target
  19378. * @param influence defines the influence to attach to the target
  19379. * @returns a new MorphTarget
  19380. */
  19381. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19382. }
  19383. }
  19384. declare module BABYLON {
  19385. /**
  19386. * This class is used to deform meshes using morphing between different targets
  19387. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19388. */
  19389. export class MorphTargetManager {
  19390. private _targets;
  19391. private _targetInfluenceChangedObservers;
  19392. private _targetDataLayoutChangedObservers;
  19393. private _activeTargets;
  19394. private _scene;
  19395. private _influences;
  19396. private _supportsNormals;
  19397. private _supportsTangents;
  19398. private _vertexCount;
  19399. private _uniqueId;
  19400. private _tempInfluences;
  19401. /**
  19402. * Creates a new MorphTargetManager
  19403. * @param scene defines the current scene
  19404. */
  19405. constructor(scene?: Nullable<Scene>);
  19406. /**
  19407. * Gets the unique ID of this manager
  19408. */
  19409. readonly uniqueId: number;
  19410. /**
  19411. * Gets the number of vertices handled by this manager
  19412. */
  19413. readonly vertexCount: number;
  19414. /**
  19415. * Gets a boolean indicating if this manager supports morphing of normals
  19416. */
  19417. readonly supportsNormals: boolean;
  19418. /**
  19419. * Gets a boolean indicating if this manager supports morphing of tangents
  19420. */
  19421. readonly supportsTangents: boolean;
  19422. /**
  19423. * Gets the number of targets stored in this manager
  19424. */
  19425. readonly numTargets: number;
  19426. /**
  19427. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19428. */
  19429. readonly numInfluencers: number;
  19430. /**
  19431. * Gets the list of influences (one per target)
  19432. */
  19433. readonly influences: Float32Array;
  19434. /**
  19435. * Gets the active target at specified index. An active target is a target with an influence > 0
  19436. * @param index defines the index to check
  19437. * @returns the requested target
  19438. */
  19439. getActiveTarget(index: number): MorphTarget;
  19440. /**
  19441. * Gets the target at specified index
  19442. * @param index defines the index to check
  19443. * @returns the requested target
  19444. */
  19445. getTarget(index: number): MorphTarget;
  19446. /**
  19447. * Add a new target to this manager
  19448. * @param target defines the target to add
  19449. */
  19450. addTarget(target: MorphTarget): void;
  19451. /**
  19452. * Removes a target from the manager
  19453. * @param target defines the target to remove
  19454. */
  19455. removeTarget(target: MorphTarget): void;
  19456. /**
  19457. * Serializes the current manager into a Serialization object
  19458. * @returns the serialized object
  19459. */
  19460. serialize(): any;
  19461. private _syncActiveTargets;
  19462. /**
  19463. * Syncrhonize the targets with all the meshes using this morph target manager
  19464. */
  19465. synchronize(): void;
  19466. /**
  19467. * Creates a new MorphTargetManager from serialized data
  19468. * @param serializationObject defines the serialized data
  19469. * @param scene defines the hosting scene
  19470. * @returns the new MorphTargetManager
  19471. */
  19472. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19473. }
  19474. }
  19475. declare module BABYLON {
  19476. /**
  19477. * Class used to represent a specific level of detail of a mesh
  19478. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19479. */
  19480. export class MeshLODLevel {
  19481. /** Defines the distance where this level should star being displayed */
  19482. distance: number;
  19483. /** Defines the mesh to use to render this level */
  19484. mesh: Nullable<Mesh>;
  19485. /**
  19486. * Creates a new LOD level
  19487. * @param distance defines the distance where this level should star being displayed
  19488. * @param mesh defines the mesh to use to render this level
  19489. */
  19490. constructor(
  19491. /** Defines the distance where this level should star being displayed */
  19492. distance: number,
  19493. /** Defines the mesh to use to render this level */
  19494. mesh: Nullable<Mesh>);
  19495. }
  19496. }
  19497. declare module BABYLON {
  19498. /**
  19499. * Mesh representing the gorund
  19500. */
  19501. export class GroundMesh extends Mesh {
  19502. /** If octree should be generated */
  19503. generateOctree: boolean;
  19504. private _heightQuads;
  19505. /** @hidden */
  19506. _subdivisionsX: number;
  19507. /** @hidden */
  19508. _subdivisionsY: number;
  19509. /** @hidden */
  19510. _width: number;
  19511. /** @hidden */
  19512. _height: number;
  19513. /** @hidden */
  19514. _minX: number;
  19515. /** @hidden */
  19516. _maxX: number;
  19517. /** @hidden */
  19518. _minZ: number;
  19519. /** @hidden */
  19520. _maxZ: number;
  19521. constructor(name: string, scene: Scene);
  19522. /**
  19523. * "GroundMesh"
  19524. * @returns "GroundMesh"
  19525. */
  19526. getClassName(): string;
  19527. /**
  19528. * The minimum of x and y subdivisions
  19529. */
  19530. readonly subdivisions: number;
  19531. /**
  19532. * X subdivisions
  19533. */
  19534. readonly subdivisionsX: number;
  19535. /**
  19536. * Y subdivisions
  19537. */
  19538. readonly subdivisionsY: number;
  19539. /**
  19540. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19541. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19542. * @param chunksCount the number of subdivisions for x and y
  19543. * @param octreeBlocksSize (Default: 32)
  19544. */
  19545. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19546. /**
  19547. * Returns a height (y) value in the Worl system :
  19548. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19549. * @param x x coordinate
  19550. * @param z z coordinate
  19551. * @returns the ground y position if (x, z) are outside the ground surface.
  19552. */
  19553. getHeightAtCoordinates(x: number, z: number): number;
  19554. /**
  19555. * Returns a normalized vector (Vector3) orthogonal to the ground
  19556. * at the ground coordinates (x, z) expressed in the World system.
  19557. * @param x x coordinate
  19558. * @param z z coordinate
  19559. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19560. */
  19561. getNormalAtCoordinates(x: number, z: number): Vector3;
  19562. /**
  19563. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19564. * at the ground coordinates (x, z) expressed in the World system.
  19565. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19566. * @param x x coordinate
  19567. * @param z z coordinate
  19568. * @param ref vector to store the result
  19569. * @returns the GroundMesh.
  19570. */
  19571. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19572. /**
  19573. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19574. * if the ground has been updated.
  19575. * This can be used in the render loop.
  19576. * @returns the GroundMesh.
  19577. */
  19578. updateCoordinateHeights(): GroundMesh;
  19579. private _getFacetAt;
  19580. private _initHeightQuads;
  19581. private _computeHeightQuads;
  19582. /**
  19583. * Serializes this ground mesh
  19584. * @param serializationObject object to write serialization to
  19585. */
  19586. serialize(serializationObject: any): void;
  19587. /**
  19588. * Parses a serialized ground mesh
  19589. * @param parsedMesh the serialized mesh
  19590. * @param scene the scene to create the ground mesh in
  19591. * @returns the created ground mesh
  19592. */
  19593. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19594. }
  19595. }
  19596. declare module BABYLON {
  19597. /**
  19598. * Interface for Physics-Joint data
  19599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19600. */
  19601. export interface PhysicsJointData {
  19602. /**
  19603. * The main pivot of the joint
  19604. */
  19605. mainPivot?: Vector3;
  19606. /**
  19607. * The connected pivot of the joint
  19608. */
  19609. connectedPivot?: Vector3;
  19610. /**
  19611. * The main axis of the joint
  19612. */
  19613. mainAxis?: Vector3;
  19614. /**
  19615. * The connected axis of the joint
  19616. */
  19617. connectedAxis?: Vector3;
  19618. /**
  19619. * The collision of the joint
  19620. */
  19621. collision?: boolean;
  19622. /**
  19623. * Native Oimo/Cannon/Energy data
  19624. */
  19625. nativeParams?: any;
  19626. }
  19627. /**
  19628. * This is a holder class for the physics joint created by the physics plugin
  19629. * It holds a set of functions to control the underlying joint
  19630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19631. */
  19632. export class PhysicsJoint {
  19633. /**
  19634. * The type of the physics joint
  19635. */
  19636. type: number;
  19637. /**
  19638. * The data for the physics joint
  19639. */
  19640. jointData: PhysicsJointData;
  19641. private _physicsJoint;
  19642. protected _physicsPlugin: IPhysicsEnginePlugin;
  19643. /**
  19644. * Initializes the physics joint
  19645. * @param type The type of the physics joint
  19646. * @param jointData The data for the physics joint
  19647. */
  19648. constructor(
  19649. /**
  19650. * The type of the physics joint
  19651. */
  19652. type: number,
  19653. /**
  19654. * The data for the physics joint
  19655. */
  19656. jointData: PhysicsJointData);
  19657. /**
  19658. * Gets the physics joint
  19659. */
  19660. /**
  19661. * Sets the physics joint
  19662. */
  19663. physicsJoint: any;
  19664. /**
  19665. * Sets the physics plugin
  19666. */
  19667. physicsPlugin: IPhysicsEnginePlugin;
  19668. /**
  19669. * Execute a function that is physics-plugin specific.
  19670. * @param {Function} func the function that will be executed.
  19671. * It accepts two parameters: the physics world and the physics joint
  19672. */
  19673. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19674. /**
  19675. * Distance-Joint type
  19676. */
  19677. static DistanceJoint: number;
  19678. /**
  19679. * Hinge-Joint type
  19680. */
  19681. static HingeJoint: number;
  19682. /**
  19683. * Ball-and-Socket joint type
  19684. */
  19685. static BallAndSocketJoint: number;
  19686. /**
  19687. * Wheel-Joint type
  19688. */
  19689. static WheelJoint: number;
  19690. /**
  19691. * Slider-Joint type
  19692. */
  19693. static SliderJoint: number;
  19694. /**
  19695. * Prismatic-Joint type
  19696. */
  19697. static PrismaticJoint: number;
  19698. /**
  19699. * Universal-Joint type
  19700. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19701. */
  19702. static UniversalJoint: number;
  19703. /**
  19704. * Hinge-Joint 2 type
  19705. */
  19706. static Hinge2Joint: number;
  19707. /**
  19708. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19709. */
  19710. static PointToPointJoint: number;
  19711. /**
  19712. * Spring-Joint type
  19713. */
  19714. static SpringJoint: number;
  19715. /**
  19716. * Lock-Joint type
  19717. */
  19718. static LockJoint: number;
  19719. }
  19720. /**
  19721. * A class representing a physics distance joint
  19722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19723. */
  19724. export class DistanceJoint extends PhysicsJoint {
  19725. /**
  19726. *
  19727. * @param jointData The data for the Distance-Joint
  19728. */
  19729. constructor(jointData: DistanceJointData);
  19730. /**
  19731. * Update the predefined distance.
  19732. * @param maxDistance The maximum preferred distance
  19733. * @param minDistance The minimum preferred distance
  19734. */
  19735. updateDistance(maxDistance: number, minDistance?: number): void;
  19736. }
  19737. /**
  19738. * Represents a Motor-Enabled Joint
  19739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19740. */
  19741. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19742. /**
  19743. * Initializes the Motor-Enabled Joint
  19744. * @param type The type of the joint
  19745. * @param jointData The physica joint data for the joint
  19746. */
  19747. constructor(type: number, jointData: PhysicsJointData);
  19748. /**
  19749. * Set the motor values.
  19750. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19751. * @param force the force to apply
  19752. * @param maxForce max force for this motor.
  19753. */
  19754. setMotor(force?: number, maxForce?: number): void;
  19755. /**
  19756. * Set the motor's limits.
  19757. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19758. * @param upperLimit The upper limit of the motor
  19759. * @param lowerLimit The lower limit of the motor
  19760. */
  19761. setLimit(upperLimit: number, lowerLimit?: number): void;
  19762. }
  19763. /**
  19764. * This class represents a single physics Hinge-Joint
  19765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19766. */
  19767. export class HingeJoint extends MotorEnabledJoint {
  19768. /**
  19769. * Initializes the Hinge-Joint
  19770. * @param jointData The joint data for the Hinge-Joint
  19771. */
  19772. constructor(jointData: PhysicsJointData);
  19773. /**
  19774. * Set the motor values.
  19775. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19776. * @param {number} force the force to apply
  19777. * @param {number} maxForce max force for this motor.
  19778. */
  19779. setMotor(force?: number, maxForce?: number): void;
  19780. /**
  19781. * Set the motor's limits.
  19782. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19783. * @param upperLimit The upper limit of the motor
  19784. * @param lowerLimit The lower limit of the motor
  19785. */
  19786. setLimit(upperLimit: number, lowerLimit?: number): void;
  19787. }
  19788. /**
  19789. * This class represents a dual hinge physics joint (same as wheel joint)
  19790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19791. */
  19792. export class Hinge2Joint extends MotorEnabledJoint {
  19793. /**
  19794. * Initializes the Hinge2-Joint
  19795. * @param jointData The joint data for the Hinge2-Joint
  19796. */
  19797. constructor(jointData: PhysicsJointData);
  19798. /**
  19799. * Set the motor values.
  19800. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19801. * @param {number} targetSpeed the speed the motor is to reach
  19802. * @param {number} maxForce max force for this motor.
  19803. * @param {motorIndex} the motor's index, 0 or 1.
  19804. */
  19805. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19806. /**
  19807. * Set the motor limits.
  19808. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19809. * @param {number} upperLimit the upper limit
  19810. * @param {number} lowerLimit lower limit
  19811. * @param {motorIndex} the motor's index, 0 or 1.
  19812. */
  19813. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19814. }
  19815. /**
  19816. * Interface for a motor enabled joint
  19817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19818. */
  19819. export interface IMotorEnabledJoint {
  19820. /**
  19821. * Physics joint
  19822. */
  19823. physicsJoint: any;
  19824. /**
  19825. * Sets the motor of the motor-enabled joint
  19826. * @param force The force of the motor
  19827. * @param maxForce The maximum force of the motor
  19828. * @param motorIndex The index of the motor
  19829. */
  19830. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19831. /**
  19832. * Sets the limit of the motor
  19833. * @param upperLimit The upper limit of the motor
  19834. * @param lowerLimit The lower limit of the motor
  19835. * @param motorIndex The index of the motor
  19836. */
  19837. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19838. }
  19839. /**
  19840. * Joint data for a Distance-Joint
  19841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19842. */
  19843. export interface DistanceJointData extends PhysicsJointData {
  19844. /**
  19845. * Max distance the 2 joint objects can be apart
  19846. */
  19847. maxDistance: number;
  19848. }
  19849. /**
  19850. * Joint data from a spring joint
  19851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19852. */
  19853. export interface SpringJointData extends PhysicsJointData {
  19854. /**
  19855. * Length of the spring
  19856. */
  19857. length: number;
  19858. /**
  19859. * Stiffness of the spring
  19860. */
  19861. stiffness: number;
  19862. /**
  19863. * Damping of the spring
  19864. */
  19865. damping: number;
  19866. /** this callback will be called when applying the force to the impostors. */
  19867. forceApplicationCallback: () => void;
  19868. }
  19869. }
  19870. declare module BABYLON {
  19871. /**
  19872. * Holds the data for the raycast result
  19873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19874. */
  19875. export class PhysicsRaycastResult {
  19876. private _hasHit;
  19877. private _hitDistance;
  19878. private _hitNormalWorld;
  19879. private _hitPointWorld;
  19880. private _rayFromWorld;
  19881. private _rayToWorld;
  19882. /**
  19883. * Gets if there was a hit
  19884. */
  19885. readonly hasHit: boolean;
  19886. /**
  19887. * Gets the distance from the hit
  19888. */
  19889. readonly hitDistance: number;
  19890. /**
  19891. * Gets the hit normal/direction in the world
  19892. */
  19893. readonly hitNormalWorld: Vector3;
  19894. /**
  19895. * Gets the hit point in the world
  19896. */
  19897. readonly hitPointWorld: Vector3;
  19898. /**
  19899. * Gets the ray "start point" of the ray in the world
  19900. */
  19901. readonly rayFromWorld: Vector3;
  19902. /**
  19903. * Gets the ray "end point" of the ray in the world
  19904. */
  19905. readonly rayToWorld: Vector3;
  19906. /**
  19907. * Sets the hit data (normal & point in world space)
  19908. * @param hitNormalWorld defines the normal in world space
  19909. * @param hitPointWorld defines the point in world space
  19910. */
  19911. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19912. /**
  19913. * Sets the distance from the start point to the hit point
  19914. * @param distance
  19915. */
  19916. setHitDistance(distance: number): void;
  19917. /**
  19918. * Calculates the distance manually
  19919. */
  19920. calculateHitDistance(): void;
  19921. /**
  19922. * Resets all the values to default
  19923. * @param from The from point on world space
  19924. * @param to The to point on world space
  19925. */
  19926. reset(from?: Vector3, to?: Vector3): void;
  19927. }
  19928. /**
  19929. * Interface for the size containing width and height
  19930. */
  19931. interface IXYZ {
  19932. /**
  19933. * X
  19934. */
  19935. x: number;
  19936. /**
  19937. * Y
  19938. */
  19939. y: number;
  19940. /**
  19941. * Z
  19942. */
  19943. z: number;
  19944. }
  19945. }
  19946. declare module BABYLON {
  19947. /**
  19948. * Interface used to describe a physics joint
  19949. */
  19950. export interface PhysicsImpostorJoint {
  19951. /** Defines the main impostor to which the joint is linked */
  19952. mainImpostor: PhysicsImpostor;
  19953. /** Defines the impostor that is connected to the main impostor using this joint */
  19954. connectedImpostor: PhysicsImpostor;
  19955. /** Defines the joint itself */
  19956. joint: PhysicsJoint;
  19957. }
  19958. /** @hidden */
  19959. export interface IPhysicsEnginePlugin {
  19960. world: any;
  19961. name: string;
  19962. setGravity(gravity: Vector3): void;
  19963. setTimeStep(timeStep: number): void;
  19964. getTimeStep(): number;
  19965. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19966. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19967. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19968. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19969. removePhysicsBody(impostor: PhysicsImpostor): void;
  19970. generateJoint(joint: PhysicsImpostorJoint): void;
  19971. removeJoint(joint: PhysicsImpostorJoint): void;
  19972. isSupported(): boolean;
  19973. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19974. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19975. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19976. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19977. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19978. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19979. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19980. getBodyMass(impostor: PhysicsImpostor): number;
  19981. getBodyFriction(impostor: PhysicsImpostor): number;
  19982. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19983. getBodyRestitution(impostor: PhysicsImpostor): number;
  19984. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19985. getBodyPressure?(impostor: PhysicsImpostor): number;
  19986. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19987. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19988. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19989. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19990. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19991. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19992. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19993. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19994. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19995. sleepBody(impostor: PhysicsImpostor): void;
  19996. wakeUpBody(impostor: PhysicsImpostor): void;
  19997. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19998. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19999. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20000. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20001. getRadius(impostor: PhysicsImpostor): number;
  20002. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20003. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20004. dispose(): void;
  20005. }
  20006. /**
  20007. * Interface used to define a physics engine
  20008. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20009. */
  20010. export interface IPhysicsEngine {
  20011. /**
  20012. * Gets the gravity vector used by the simulation
  20013. */
  20014. gravity: Vector3;
  20015. /**
  20016. * Sets the gravity vector used by the simulation
  20017. * @param gravity defines the gravity vector to use
  20018. */
  20019. setGravity(gravity: Vector3): void;
  20020. /**
  20021. * Set the time step of the physics engine.
  20022. * Default is 1/60.
  20023. * To slow it down, enter 1/600 for example.
  20024. * To speed it up, 1/30
  20025. * @param newTimeStep the new timestep to apply to this world.
  20026. */
  20027. setTimeStep(newTimeStep: number): void;
  20028. /**
  20029. * Get the time step of the physics engine.
  20030. * @returns the current time step
  20031. */
  20032. getTimeStep(): number;
  20033. /**
  20034. * Release all resources
  20035. */
  20036. dispose(): void;
  20037. /**
  20038. * Gets the name of the current physics plugin
  20039. * @returns the name of the plugin
  20040. */
  20041. getPhysicsPluginName(): string;
  20042. /**
  20043. * Adding a new impostor for the impostor tracking.
  20044. * This will be done by the impostor itself.
  20045. * @param impostor the impostor to add
  20046. */
  20047. addImpostor(impostor: PhysicsImpostor): void;
  20048. /**
  20049. * Remove an impostor from the engine.
  20050. * This impostor and its mesh will not longer be updated by the physics engine.
  20051. * @param impostor the impostor to remove
  20052. */
  20053. removeImpostor(impostor: PhysicsImpostor): void;
  20054. /**
  20055. * Add a joint to the physics engine
  20056. * @param mainImpostor defines the main impostor to which the joint is added.
  20057. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20058. * @param joint defines the joint that will connect both impostors.
  20059. */
  20060. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20061. /**
  20062. * Removes a joint from the simulation
  20063. * @param mainImpostor defines the impostor used with the joint
  20064. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20065. * @param joint defines the joint to remove
  20066. */
  20067. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20068. /**
  20069. * Gets the current plugin used to run the simulation
  20070. * @returns current plugin
  20071. */
  20072. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20073. /**
  20074. * Gets the list of physic impostors
  20075. * @returns an array of PhysicsImpostor
  20076. */
  20077. getImpostors(): Array<PhysicsImpostor>;
  20078. /**
  20079. * Gets the impostor for a physics enabled object
  20080. * @param object defines the object impersonated by the impostor
  20081. * @returns the PhysicsImpostor or null if not found
  20082. */
  20083. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20084. /**
  20085. * Gets the impostor for a physics body object
  20086. * @param body defines physics body used by the impostor
  20087. * @returns the PhysicsImpostor or null if not found
  20088. */
  20089. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20090. /**
  20091. * Does a raycast in the physics world
  20092. * @param from when should the ray start?
  20093. * @param to when should the ray end?
  20094. * @returns PhysicsRaycastResult
  20095. */
  20096. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20097. /**
  20098. * Called by the scene. No need to call it.
  20099. * @param delta defines the timespam between frames
  20100. */
  20101. _step(delta: number): void;
  20102. }
  20103. }
  20104. declare module BABYLON {
  20105. /**
  20106. * The interface for the physics imposter parameters
  20107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20108. */
  20109. export interface PhysicsImpostorParameters {
  20110. /**
  20111. * The mass of the physics imposter
  20112. */
  20113. mass: number;
  20114. /**
  20115. * The friction of the physics imposter
  20116. */
  20117. friction?: number;
  20118. /**
  20119. * The coefficient of restitution of the physics imposter
  20120. */
  20121. restitution?: number;
  20122. /**
  20123. * The native options of the physics imposter
  20124. */
  20125. nativeOptions?: any;
  20126. /**
  20127. * Specifies if the parent should be ignored
  20128. */
  20129. ignoreParent?: boolean;
  20130. /**
  20131. * Specifies if bi-directional transformations should be disabled
  20132. */
  20133. disableBidirectionalTransformation?: boolean;
  20134. /**
  20135. * The pressure inside the physics imposter, soft object only
  20136. */
  20137. pressure?: number;
  20138. /**
  20139. * The stiffness the physics imposter, soft object only
  20140. */
  20141. stiffness?: number;
  20142. /**
  20143. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20144. */
  20145. velocityIterations?: number;
  20146. /**
  20147. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20148. */
  20149. positionIterations?: number;
  20150. /**
  20151. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20152. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20153. * Add to fix multiple points
  20154. */
  20155. fixedPoints?: number;
  20156. /**
  20157. * The collision margin around a soft object
  20158. */
  20159. margin?: number;
  20160. /**
  20161. * The collision margin around a soft object
  20162. */
  20163. damping?: number;
  20164. /**
  20165. * The path for a rope based on an extrusion
  20166. */
  20167. path?: any;
  20168. /**
  20169. * The shape of an extrusion used for a rope based on an extrusion
  20170. */
  20171. shape?: any;
  20172. }
  20173. /**
  20174. * Interface for a physics-enabled object
  20175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20176. */
  20177. export interface IPhysicsEnabledObject {
  20178. /**
  20179. * The position of the physics-enabled object
  20180. */
  20181. position: Vector3;
  20182. /**
  20183. * The rotation of the physics-enabled object
  20184. */
  20185. rotationQuaternion: Nullable<Quaternion>;
  20186. /**
  20187. * The scale of the physics-enabled object
  20188. */
  20189. scaling: Vector3;
  20190. /**
  20191. * The rotation of the physics-enabled object
  20192. */
  20193. rotation?: Vector3;
  20194. /**
  20195. * The parent of the physics-enabled object
  20196. */
  20197. parent?: any;
  20198. /**
  20199. * The bounding info of the physics-enabled object
  20200. * @returns The bounding info of the physics-enabled object
  20201. */
  20202. getBoundingInfo(): BoundingInfo;
  20203. /**
  20204. * Computes the world matrix
  20205. * @param force Specifies if the world matrix should be computed by force
  20206. * @returns A world matrix
  20207. */
  20208. computeWorldMatrix(force: boolean): Matrix;
  20209. /**
  20210. * Gets the world matrix
  20211. * @returns A world matrix
  20212. */
  20213. getWorldMatrix?(): Matrix;
  20214. /**
  20215. * Gets the child meshes
  20216. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20217. * @returns An array of abstract meshes
  20218. */
  20219. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20220. /**
  20221. * Gets the vertex data
  20222. * @param kind The type of vertex data
  20223. * @returns A nullable array of numbers, or a float32 array
  20224. */
  20225. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20226. /**
  20227. * Gets the indices from the mesh
  20228. * @returns A nullable array of index arrays
  20229. */
  20230. getIndices?(): Nullable<IndicesArray>;
  20231. /**
  20232. * Gets the scene from the mesh
  20233. * @returns the indices array or null
  20234. */
  20235. getScene?(): Scene;
  20236. /**
  20237. * Gets the absolute position from the mesh
  20238. * @returns the absolute position
  20239. */
  20240. getAbsolutePosition(): Vector3;
  20241. /**
  20242. * Gets the absolute pivot point from the mesh
  20243. * @returns the absolute pivot point
  20244. */
  20245. getAbsolutePivotPoint(): Vector3;
  20246. /**
  20247. * Rotates the mesh
  20248. * @param axis The axis of rotation
  20249. * @param amount The amount of rotation
  20250. * @param space The space of the rotation
  20251. * @returns The rotation transform node
  20252. */
  20253. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20254. /**
  20255. * Translates the mesh
  20256. * @param axis The axis of translation
  20257. * @param distance The distance of translation
  20258. * @param space The space of the translation
  20259. * @returns The transform node
  20260. */
  20261. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20262. /**
  20263. * Sets the absolute position of the mesh
  20264. * @param absolutePosition The absolute position of the mesh
  20265. * @returns The transform node
  20266. */
  20267. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20268. /**
  20269. * Gets the class name of the mesh
  20270. * @returns The class name
  20271. */
  20272. getClassName(): string;
  20273. }
  20274. /**
  20275. * Represents a physics imposter
  20276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20277. */
  20278. export class PhysicsImpostor {
  20279. /**
  20280. * The physics-enabled object used as the physics imposter
  20281. */
  20282. object: IPhysicsEnabledObject;
  20283. /**
  20284. * The type of the physics imposter
  20285. */
  20286. type: number;
  20287. private _options;
  20288. private _scene?;
  20289. /**
  20290. * The default object size of the imposter
  20291. */
  20292. static DEFAULT_OBJECT_SIZE: Vector3;
  20293. /**
  20294. * The identity quaternion of the imposter
  20295. */
  20296. static IDENTITY_QUATERNION: Quaternion;
  20297. /** @hidden */
  20298. _pluginData: any;
  20299. private _physicsEngine;
  20300. private _physicsBody;
  20301. private _bodyUpdateRequired;
  20302. private _onBeforePhysicsStepCallbacks;
  20303. private _onAfterPhysicsStepCallbacks;
  20304. /** @hidden */
  20305. _onPhysicsCollideCallbacks: Array<{
  20306. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20307. otherImpostors: Array<PhysicsImpostor>;
  20308. }>;
  20309. private _deltaPosition;
  20310. private _deltaRotation;
  20311. private _deltaRotationConjugated;
  20312. /** hidden */
  20313. _isFromLine: boolean;
  20314. private _parent;
  20315. private _isDisposed;
  20316. private static _tmpVecs;
  20317. private static _tmpQuat;
  20318. /**
  20319. * Specifies if the physics imposter is disposed
  20320. */
  20321. readonly isDisposed: boolean;
  20322. /**
  20323. * Gets the mass of the physics imposter
  20324. */
  20325. mass: number;
  20326. /**
  20327. * Gets the coefficient of friction
  20328. */
  20329. /**
  20330. * Sets the coefficient of friction
  20331. */
  20332. friction: number;
  20333. /**
  20334. * Gets the coefficient of restitution
  20335. */
  20336. /**
  20337. * Sets the coefficient of restitution
  20338. */
  20339. restitution: number;
  20340. /**
  20341. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20342. */
  20343. /**
  20344. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20345. */
  20346. pressure: number;
  20347. /**
  20348. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20349. */
  20350. /**
  20351. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20352. */
  20353. stiffness: number;
  20354. /**
  20355. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20356. */
  20357. /**
  20358. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20359. */
  20360. velocityIterations: number;
  20361. /**
  20362. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20363. */
  20364. /**
  20365. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20366. */
  20367. positionIterations: number;
  20368. /**
  20369. * The unique id of the physics imposter
  20370. * set by the physics engine when adding this impostor to the array
  20371. */
  20372. uniqueId: number;
  20373. /**
  20374. * @hidden
  20375. */
  20376. soft: boolean;
  20377. /**
  20378. * @hidden
  20379. */
  20380. segments: number;
  20381. private _joints;
  20382. /**
  20383. * Initializes the physics imposter
  20384. * @param object The physics-enabled object used as the physics imposter
  20385. * @param type The type of the physics imposter
  20386. * @param _options The options for the physics imposter
  20387. * @param _scene The Babylon scene
  20388. */
  20389. constructor(
  20390. /**
  20391. * The physics-enabled object used as the physics imposter
  20392. */
  20393. object: IPhysicsEnabledObject,
  20394. /**
  20395. * The type of the physics imposter
  20396. */
  20397. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20398. /**
  20399. * This function will completly initialize this impostor.
  20400. * It will create a new body - but only if this mesh has no parent.
  20401. * If it has, this impostor will not be used other than to define the impostor
  20402. * of the child mesh.
  20403. * @hidden
  20404. */
  20405. _init(): void;
  20406. private _getPhysicsParent;
  20407. /**
  20408. * Should a new body be generated.
  20409. * @returns boolean specifying if body initialization is required
  20410. */
  20411. isBodyInitRequired(): boolean;
  20412. /**
  20413. * Sets the updated scaling
  20414. * @param updated Specifies if the scaling is updated
  20415. */
  20416. setScalingUpdated(): void;
  20417. /**
  20418. * Force a regeneration of this or the parent's impostor's body.
  20419. * Use under cautious - This will remove all joints already implemented.
  20420. */
  20421. forceUpdate(): void;
  20422. /**
  20423. * Gets the body that holds this impostor. Either its own, or its parent.
  20424. */
  20425. /**
  20426. * Set the physics body. Used mainly by the physics engine/plugin
  20427. */
  20428. physicsBody: any;
  20429. /**
  20430. * Get the parent of the physics imposter
  20431. * @returns Physics imposter or null
  20432. */
  20433. /**
  20434. * Sets the parent of the physics imposter
  20435. */
  20436. parent: Nullable<PhysicsImpostor>;
  20437. /**
  20438. * Resets the update flags
  20439. */
  20440. resetUpdateFlags(): void;
  20441. /**
  20442. * Gets the object extend size
  20443. * @returns the object extend size
  20444. */
  20445. getObjectExtendSize(): Vector3;
  20446. /**
  20447. * Gets the object center
  20448. * @returns The object center
  20449. */
  20450. getObjectCenter(): Vector3;
  20451. /**
  20452. * Get a specific parametes from the options parameter
  20453. * @param paramName The object parameter name
  20454. * @returns The object parameter
  20455. */
  20456. getParam(paramName: string): any;
  20457. /**
  20458. * Sets a specific parameter in the options given to the physics plugin
  20459. * @param paramName The parameter name
  20460. * @param value The value of the parameter
  20461. */
  20462. setParam(paramName: string, value: number): void;
  20463. /**
  20464. * Specifically change the body's mass option. Won't recreate the physics body object
  20465. * @param mass The mass of the physics imposter
  20466. */
  20467. setMass(mass: number): void;
  20468. /**
  20469. * Gets the linear velocity
  20470. * @returns linear velocity or null
  20471. */
  20472. getLinearVelocity(): Nullable<Vector3>;
  20473. /**
  20474. * Sets the linear velocity
  20475. * @param velocity linear velocity or null
  20476. */
  20477. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20478. /**
  20479. * Gets the angular velocity
  20480. * @returns angular velocity or null
  20481. */
  20482. getAngularVelocity(): Nullable<Vector3>;
  20483. /**
  20484. * Sets the angular velocity
  20485. * @param velocity The velocity or null
  20486. */
  20487. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20488. /**
  20489. * Execute a function with the physics plugin native code
  20490. * Provide a function the will have two variables - the world object and the physics body object
  20491. * @param func The function to execute with the physics plugin native code
  20492. */
  20493. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20494. /**
  20495. * Register a function that will be executed before the physics world is stepping forward
  20496. * @param func The function to execute before the physics world is stepped forward
  20497. */
  20498. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20499. /**
  20500. * Unregister a function that will be executed before the physics world is stepping forward
  20501. * @param func The function to execute before the physics world is stepped forward
  20502. */
  20503. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20504. /**
  20505. * Register a function that will be executed after the physics step
  20506. * @param func The function to execute after physics step
  20507. */
  20508. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20509. /**
  20510. * Unregisters a function that will be executed after the physics step
  20511. * @param func The function to execute after physics step
  20512. */
  20513. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20514. /**
  20515. * register a function that will be executed when this impostor collides against a different body
  20516. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20517. * @param func Callback that is executed on collision
  20518. */
  20519. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20520. /**
  20521. * Unregisters the physics imposter on contact
  20522. * @param collideAgainst The physics object to collide against
  20523. * @param func Callback to execute on collision
  20524. */
  20525. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20526. private _tmpQuat;
  20527. private _tmpQuat2;
  20528. /**
  20529. * Get the parent rotation
  20530. * @returns The parent rotation
  20531. */
  20532. getParentsRotation(): Quaternion;
  20533. /**
  20534. * this function is executed by the physics engine.
  20535. */
  20536. beforeStep: () => void;
  20537. /**
  20538. * this function is executed by the physics engine
  20539. */
  20540. afterStep: () => void;
  20541. /**
  20542. * Legacy collision detection event support
  20543. */
  20544. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20545. /**
  20546. * event and body object due to cannon's event-based architecture.
  20547. */
  20548. onCollide: (e: {
  20549. body: any;
  20550. }) => void;
  20551. /**
  20552. * Apply a force
  20553. * @param force The force to apply
  20554. * @param contactPoint The contact point for the force
  20555. * @returns The physics imposter
  20556. */
  20557. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20558. /**
  20559. * Apply an impulse
  20560. * @param force The impulse force
  20561. * @param contactPoint The contact point for the impulse force
  20562. * @returns The physics imposter
  20563. */
  20564. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20565. /**
  20566. * A help function to create a joint
  20567. * @param otherImpostor A physics imposter used to create a joint
  20568. * @param jointType The type of joint
  20569. * @param jointData The data for the joint
  20570. * @returns The physics imposter
  20571. */
  20572. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20573. /**
  20574. * Add a joint to this impostor with a different impostor
  20575. * @param otherImpostor A physics imposter used to add a joint
  20576. * @param joint The joint to add
  20577. * @returns The physics imposter
  20578. */
  20579. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20580. /**
  20581. * Add an anchor to a cloth impostor
  20582. * @param otherImpostor rigid impostor to anchor to
  20583. * @param width ratio across width from 0 to 1
  20584. * @param height ratio up height from 0 to 1
  20585. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20586. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20587. * @returns impostor the soft imposter
  20588. */
  20589. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20590. /**
  20591. * Add a hook to a rope impostor
  20592. * @param otherImpostor rigid impostor to anchor to
  20593. * @param length ratio across rope from 0 to 1
  20594. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20595. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20596. * @returns impostor the rope imposter
  20597. */
  20598. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20599. /**
  20600. * Will keep this body still, in a sleep mode.
  20601. * @returns the physics imposter
  20602. */
  20603. sleep(): PhysicsImpostor;
  20604. /**
  20605. * Wake the body up.
  20606. * @returns The physics imposter
  20607. */
  20608. wakeUp(): PhysicsImpostor;
  20609. /**
  20610. * Clones the physics imposter
  20611. * @param newObject The physics imposter clones to this physics-enabled object
  20612. * @returns A nullable physics imposter
  20613. */
  20614. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20615. /**
  20616. * Disposes the physics imposter
  20617. */
  20618. dispose(): void;
  20619. /**
  20620. * Sets the delta position
  20621. * @param position The delta position amount
  20622. */
  20623. setDeltaPosition(position: Vector3): void;
  20624. /**
  20625. * Sets the delta rotation
  20626. * @param rotation The delta rotation amount
  20627. */
  20628. setDeltaRotation(rotation: Quaternion): void;
  20629. /**
  20630. * Gets the box size of the physics imposter and stores the result in the input parameter
  20631. * @param result Stores the box size
  20632. * @returns The physics imposter
  20633. */
  20634. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20635. /**
  20636. * Gets the radius of the physics imposter
  20637. * @returns Radius of the physics imposter
  20638. */
  20639. getRadius(): number;
  20640. /**
  20641. * Sync a bone with this impostor
  20642. * @param bone The bone to sync to the impostor.
  20643. * @param boneMesh The mesh that the bone is influencing.
  20644. * @param jointPivot The pivot of the joint / bone in local space.
  20645. * @param distToJoint Optional distance from the impostor to the joint.
  20646. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20647. */
  20648. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20649. /**
  20650. * Sync impostor to a bone
  20651. * @param bone The bone that the impostor will be synced to.
  20652. * @param boneMesh The mesh that the bone is influencing.
  20653. * @param jointPivot The pivot of the joint / bone in local space.
  20654. * @param distToJoint Optional distance from the impostor to the joint.
  20655. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20656. * @param boneAxis Optional vector3 axis the bone is aligned with
  20657. */
  20658. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20659. /**
  20660. * No-Imposter type
  20661. */
  20662. static NoImpostor: number;
  20663. /**
  20664. * Sphere-Imposter type
  20665. */
  20666. static SphereImpostor: number;
  20667. /**
  20668. * Box-Imposter type
  20669. */
  20670. static BoxImpostor: number;
  20671. /**
  20672. * Plane-Imposter type
  20673. */
  20674. static PlaneImpostor: number;
  20675. /**
  20676. * Mesh-imposter type
  20677. */
  20678. static MeshImpostor: number;
  20679. /**
  20680. * Cylinder-Imposter type
  20681. */
  20682. static CylinderImpostor: number;
  20683. /**
  20684. * Particle-Imposter type
  20685. */
  20686. static ParticleImpostor: number;
  20687. /**
  20688. * Heightmap-Imposter type
  20689. */
  20690. static HeightmapImpostor: number;
  20691. /**
  20692. * ConvexHull-Impostor type (Ammo.js plugin only)
  20693. */
  20694. static ConvexHullImpostor: number;
  20695. /**
  20696. * Rope-Imposter type
  20697. */
  20698. static RopeImpostor: number;
  20699. /**
  20700. * Cloth-Imposter type
  20701. */
  20702. static ClothImpostor: number;
  20703. /**
  20704. * Softbody-Imposter type
  20705. */
  20706. static SoftbodyImpostor: number;
  20707. }
  20708. }
  20709. declare module BABYLON {
  20710. /**
  20711. * @hidden
  20712. **/
  20713. export class _CreationDataStorage {
  20714. closePath?: boolean;
  20715. closeArray?: boolean;
  20716. idx: number[];
  20717. dashSize: number;
  20718. gapSize: number;
  20719. path3D: Path3D;
  20720. pathArray: Vector3[][];
  20721. arc: number;
  20722. radius: number;
  20723. cap: number;
  20724. tessellation: number;
  20725. }
  20726. /**
  20727. * @hidden
  20728. **/
  20729. class _InstanceDataStorage {
  20730. visibleInstances: any;
  20731. batchCache: _InstancesBatch;
  20732. instancesBufferSize: number;
  20733. instancesBuffer: Nullable<Buffer>;
  20734. instancesData: Float32Array;
  20735. overridenInstanceCount: number;
  20736. isFrozen: boolean;
  20737. previousBatch: _InstancesBatch;
  20738. hardwareInstancedRendering: boolean;
  20739. sideOrientation: number;
  20740. }
  20741. /**
  20742. * @hidden
  20743. **/
  20744. export class _InstancesBatch {
  20745. mustReturn: boolean;
  20746. visibleInstances: Nullable<InstancedMesh[]>[];
  20747. renderSelf: boolean[];
  20748. hardwareInstancedRendering: boolean[];
  20749. }
  20750. /**
  20751. * Class used to represent renderable models
  20752. */
  20753. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20754. /**
  20755. * Mesh side orientation : usually the external or front surface
  20756. */
  20757. static readonly FRONTSIDE: number;
  20758. /**
  20759. * Mesh side orientation : usually the internal or back surface
  20760. */
  20761. static readonly BACKSIDE: number;
  20762. /**
  20763. * Mesh side orientation : both internal and external or front and back surfaces
  20764. */
  20765. static readonly DOUBLESIDE: number;
  20766. /**
  20767. * Mesh side orientation : by default, `FRONTSIDE`
  20768. */
  20769. static readonly DEFAULTSIDE: number;
  20770. /**
  20771. * Mesh cap setting : no cap
  20772. */
  20773. static readonly NO_CAP: number;
  20774. /**
  20775. * Mesh cap setting : one cap at the beginning of the mesh
  20776. */
  20777. static readonly CAP_START: number;
  20778. /**
  20779. * Mesh cap setting : one cap at the end of the mesh
  20780. */
  20781. static readonly CAP_END: number;
  20782. /**
  20783. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20784. */
  20785. static readonly CAP_ALL: number;
  20786. /**
  20787. * Gets the default side orientation.
  20788. * @param orientation the orientation to value to attempt to get
  20789. * @returns the default orientation
  20790. * @hidden
  20791. */
  20792. static _GetDefaultSideOrientation(orientation?: number): number;
  20793. private _onBeforeRenderObservable;
  20794. private _onBeforeBindObservable;
  20795. private _onAfterRenderObservable;
  20796. private _onBeforeDrawObservable;
  20797. /**
  20798. * An event triggered before rendering the mesh
  20799. */
  20800. readonly onBeforeRenderObservable: Observable<Mesh>;
  20801. /**
  20802. * An event triggered before binding the mesh
  20803. */
  20804. readonly onBeforeBindObservable: Observable<Mesh>;
  20805. /**
  20806. * An event triggered after rendering the mesh
  20807. */
  20808. readonly onAfterRenderObservable: Observable<Mesh>;
  20809. /**
  20810. * An event triggered before drawing the mesh
  20811. */
  20812. readonly onBeforeDrawObservable: Observable<Mesh>;
  20813. private _onBeforeDrawObserver;
  20814. /**
  20815. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20816. */
  20817. onBeforeDraw: () => void;
  20818. /**
  20819. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20820. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20821. */
  20822. delayLoadState: number;
  20823. /**
  20824. * Gets the list of instances created from this mesh
  20825. * it is not supposed to be modified manually.
  20826. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20827. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20828. */
  20829. instances: InstancedMesh[];
  20830. /**
  20831. * Gets the file containing delay loading data for this mesh
  20832. */
  20833. delayLoadingFile: string;
  20834. /** @hidden */
  20835. _binaryInfo: any;
  20836. private _LODLevels;
  20837. /**
  20838. * User defined function used to change how LOD level selection is done
  20839. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20840. */
  20841. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20842. private _morphTargetManager;
  20843. /**
  20844. * Gets or sets the morph target manager
  20845. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20846. */
  20847. morphTargetManager: Nullable<MorphTargetManager>;
  20848. /** @hidden */
  20849. _creationDataStorage: Nullable<_CreationDataStorage>;
  20850. /** @hidden */
  20851. _geometry: Nullable<Geometry>;
  20852. /** @hidden */
  20853. _delayInfo: Array<string>;
  20854. /** @hidden */
  20855. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20856. /** @hidden */
  20857. _instanceDataStorage: _InstanceDataStorage;
  20858. private _effectiveMaterial;
  20859. /** @hidden */
  20860. _shouldGenerateFlatShading: boolean;
  20861. private _preActivateId;
  20862. /** @hidden */
  20863. _originalBuilderSideOrientation: number;
  20864. /**
  20865. * Use this property to change the original side orientation defined at construction time
  20866. */
  20867. overrideMaterialSideOrientation: Nullable<number>;
  20868. private _areNormalsFrozen;
  20869. private _sourcePositions;
  20870. private _sourceNormals;
  20871. private _source;
  20872. private meshMap;
  20873. /**
  20874. * Gets the source mesh (the one used to clone this one from)
  20875. */
  20876. readonly source: Nullable<Mesh>;
  20877. /**
  20878. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20879. */
  20880. isUnIndexed: boolean;
  20881. /**
  20882. * @constructor
  20883. * @param name The value used by scene.getMeshByName() to do a lookup.
  20884. * @param scene The scene to add this mesh to.
  20885. * @param parent The parent of this mesh, if it has one
  20886. * @param source An optional Mesh from which geometry is shared, cloned.
  20887. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20888. * When false, achieved by calling a clone(), also passing False.
  20889. * This will make creation of children, recursive.
  20890. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20891. */
  20892. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20893. /**
  20894. * Gets the class name
  20895. * @returns the string "Mesh".
  20896. */
  20897. getClassName(): string;
  20898. /** @hidden */
  20899. readonly _isMesh: boolean;
  20900. /**
  20901. * Returns a description of this mesh
  20902. * @param fullDetails define if full details about this mesh must be used
  20903. * @returns a descriptive string representing this mesh
  20904. */
  20905. toString(fullDetails?: boolean): string;
  20906. /** @hidden */
  20907. _unBindEffect(): void;
  20908. /**
  20909. * Gets a boolean indicating if this mesh has LOD
  20910. */
  20911. readonly hasLODLevels: boolean;
  20912. /**
  20913. * Gets the list of MeshLODLevel associated with the current mesh
  20914. * @returns an array of MeshLODLevel
  20915. */
  20916. getLODLevels(): MeshLODLevel[];
  20917. private _sortLODLevels;
  20918. /**
  20919. * Add a mesh as LOD level triggered at the given distance.
  20920. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20921. * @param distance The distance from the center of the object to show this level
  20922. * @param mesh The mesh to be added as LOD level (can be null)
  20923. * @return This mesh (for chaining)
  20924. */
  20925. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20926. /**
  20927. * Returns the LOD level mesh at the passed distance or null if not found.
  20928. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20929. * @param distance The distance from the center of the object to show this level
  20930. * @returns a Mesh or `null`
  20931. */
  20932. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20933. /**
  20934. * Remove a mesh from the LOD array
  20935. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20936. * @param mesh defines the mesh to be removed
  20937. * @return This mesh (for chaining)
  20938. */
  20939. removeLODLevel(mesh: Mesh): Mesh;
  20940. /**
  20941. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20942. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20943. * @param camera defines the camera to use to compute distance
  20944. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20945. * @return This mesh (for chaining)
  20946. */
  20947. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20948. /**
  20949. * Gets the mesh internal Geometry object
  20950. */
  20951. readonly geometry: Nullable<Geometry>;
  20952. /**
  20953. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20954. * @returns the total number of vertices
  20955. */
  20956. getTotalVertices(): number;
  20957. /**
  20958. * Returns the content of an associated vertex buffer
  20959. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20960. * - VertexBuffer.PositionKind
  20961. * - VertexBuffer.UVKind
  20962. * - VertexBuffer.UV2Kind
  20963. * - VertexBuffer.UV3Kind
  20964. * - VertexBuffer.UV4Kind
  20965. * - VertexBuffer.UV5Kind
  20966. * - VertexBuffer.UV6Kind
  20967. * - VertexBuffer.ColorKind
  20968. * - VertexBuffer.MatricesIndicesKind
  20969. * - VertexBuffer.MatricesIndicesExtraKind
  20970. * - VertexBuffer.MatricesWeightsKind
  20971. * - VertexBuffer.MatricesWeightsExtraKind
  20972. * @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
  20973. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20974. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20975. */
  20976. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20977. /**
  20978. * Returns the mesh VertexBuffer object from the requested `kind`
  20979. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20980. * - VertexBuffer.PositionKind
  20981. * - VertexBuffer.UVKind
  20982. * - VertexBuffer.UV2Kind
  20983. * - VertexBuffer.UV3Kind
  20984. * - VertexBuffer.UV4Kind
  20985. * - VertexBuffer.UV5Kind
  20986. * - VertexBuffer.UV6Kind
  20987. * - VertexBuffer.ColorKind
  20988. * - VertexBuffer.MatricesIndicesKind
  20989. * - VertexBuffer.MatricesIndicesExtraKind
  20990. * - VertexBuffer.MatricesWeightsKind
  20991. * - VertexBuffer.MatricesWeightsExtraKind
  20992. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20993. */
  20994. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20995. /**
  20996. * Tests if a specific vertex buffer is associated with this mesh
  20997. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20998. * - VertexBuffer.PositionKind
  20999. * - VertexBuffer.UVKind
  21000. * - VertexBuffer.UV2Kind
  21001. * - VertexBuffer.UV3Kind
  21002. * - VertexBuffer.UV4Kind
  21003. * - VertexBuffer.UV5Kind
  21004. * - VertexBuffer.UV6Kind
  21005. * - VertexBuffer.ColorKind
  21006. * - VertexBuffer.MatricesIndicesKind
  21007. * - VertexBuffer.MatricesIndicesExtraKind
  21008. * - VertexBuffer.MatricesWeightsKind
  21009. * - VertexBuffer.MatricesWeightsExtraKind
  21010. * @returns a boolean
  21011. */
  21012. isVerticesDataPresent(kind: string): boolean;
  21013. /**
  21014. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21015. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21016. * - VertexBuffer.PositionKind
  21017. * - VertexBuffer.UVKind
  21018. * - VertexBuffer.UV2Kind
  21019. * - VertexBuffer.UV3Kind
  21020. * - VertexBuffer.UV4Kind
  21021. * - VertexBuffer.UV5Kind
  21022. * - VertexBuffer.UV6Kind
  21023. * - VertexBuffer.ColorKind
  21024. * - VertexBuffer.MatricesIndicesKind
  21025. * - VertexBuffer.MatricesIndicesExtraKind
  21026. * - VertexBuffer.MatricesWeightsKind
  21027. * - VertexBuffer.MatricesWeightsExtraKind
  21028. * @returns a boolean
  21029. */
  21030. isVertexBufferUpdatable(kind: string): boolean;
  21031. /**
  21032. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21033. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21034. * - VertexBuffer.PositionKind
  21035. * - VertexBuffer.UVKind
  21036. * - VertexBuffer.UV2Kind
  21037. * - VertexBuffer.UV3Kind
  21038. * - VertexBuffer.UV4Kind
  21039. * - VertexBuffer.UV5Kind
  21040. * - VertexBuffer.UV6Kind
  21041. * - VertexBuffer.ColorKind
  21042. * - VertexBuffer.MatricesIndicesKind
  21043. * - VertexBuffer.MatricesIndicesExtraKind
  21044. * - VertexBuffer.MatricesWeightsKind
  21045. * - VertexBuffer.MatricesWeightsExtraKind
  21046. * @returns an array of strings
  21047. */
  21048. getVerticesDataKinds(): string[];
  21049. /**
  21050. * Returns a positive integer : the total number of indices in this mesh geometry.
  21051. * @returns the numner of indices or zero if the mesh has no geometry.
  21052. */
  21053. getTotalIndices(): number;
  21054. /**
  21055. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21056. * @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.
  21057. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21058. * @returns the indices array or an empty array if the mesh has no geometry
  21059. */
  21060. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21061. readonly isBlocked: boolean;
  21062. /**
  21063. * Determine if the current mesh is ready to be rendered
  21064. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21065. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21066. * @returns true if all associated assets are ready (material, textures, shaders)
  21067. */
  21068. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21069. /**
  21070. * 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.
  21071. */
  21072. readonly areNormalsFrozen: boolean;
  21073. /**
  21074. * 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.
  21075. * @returns the current mesh
  21076. */
  21077. freezeNormals(): Mesh;
  21078. /**
  21079. * 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
  21080. * @returns the current mesh
  21081. */
  21082. unfreezeNormals(): Mesh;
  21083. /**
  21084. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21085. */
  21086. overridenInstanceCount: number;
  21087. /** @hidden */
  21088. _preActivate(): Mesh;
  21089. /** @hidden */
  21090. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21091. /** @hidden */
  21092. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21093. /**
  21094. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21095. * This means the mesh underlying bounding box and sphere are recomputed.
  21096. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21097. * @returns the current mesh
  21098. */
  21099. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21100. /** @hidden */
  21101. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21102. /**
  21103. * This function will subdivide the mesh into multiple submeshes
  21104. * @param count defines the expected number of submeshes
  21105. */
  21106. subdivide(count: number): void;
  21107. /**
  21108. * Copy a FloatArray into a specific associated vertex buffer
  21109. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21110. * - VertexBuffer.PositionKind
  21111. * - VertexBuffer.UVKind
  21112. * - VertexBuffer.UV2Kind
  21113. * - VertexBuffer.UV3Kind
  21114. * - VertexBuffer.UV4Kind
  21115. * - VertexBuffer.UV5Kind
  21116. * - VertexBuffer.UV6Kind
  21117. * - VertexBuffer.ColorKind
  21118. * - VertexBuffer.MatricesIndicesKind
  21119. * - VertexBuffer.MatricesIndicesExtraKind
  21120. * - VertexBuffer.MatricesWeightsKind
  21121. * - VertexBuffer.MatricesWeightsExtraKind
  21122. * @param data defines the data source
  21123. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21124. * @param stride defines the data stride size (can be null)
  21125. * @returns the current mesh
  21126. */
  21127. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21128. /**
  21129. * Flags an associated vertex buffer as updatable
  21130. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21131. * - VertexBuffer.PositionKind
  21132. * - VertexBuffer.UVKind
  21133. * - VertexBuffer.UV2Kind
  21134. * - VertexBuffer.UV3Kind
  21135. * - VertexBuffer.UV4Kind
  21136. * - VertexBuffer.UV5Kind
  21137. * - VertexBuffer.UV6Kind
  21138. * - VertexBuffer.ColorKind
  21139. * - VertexBuffer.MatricesIndicesKind
  21140. * - VertexBuffer.MatricesIndicesExtraKind
  21141. * - VertexBuffer.MatricesWeightsKind
  21142. * - VertexBuffer.MatricesWeightsExtraKind
  21143. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21144. */
  21145. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21146. /**
  21147. * Sets the mesh global Vertex Buffer
  21148. * @param buffer defines the buffer to use
  21149. * @returns the current mesh
  21150. */
  21151. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21152. /**
  21153. * Update a specific associated vertex buffer
  21154. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21155. * - VertexBuffer.PositionKind
  21156. * - VertexBuffer.UVKind
  21157. * - VertexBuffer.UV2Kind
  21158. * - VertexBuffer.UV3Kind
  21159. * - VertexBuffer.UV4Kind
  21160. * - VertexBuffer.UV5Kind
  21161. * - VertexBuffer.UV6Kind
  21162. * - VertexBuffer.ColorKind
  21163. * - VertexBuffer.MatricesIndicesKind
  21164. * - VertexBuffer.MatricesIndicesExtraKind
  21165. * - VertexBuffer.MatricesWeightsKind
  21166. * - VertexBuffer.MatricesWeightsExtraKind
  21167. * @param data defines the data source
  21168. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21169. * @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)
  21170. * @returns the current mesh
  21171. */
  21172. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21173. /**
  21174. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21175. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21176. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21177. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21178. * @returns the current mesh
  21179. */
  21180. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21181. /**
  21182. * Creates a un-shared specific occurence of the geometry for the mesh.
  21183. * @returns the current mesh
  21184. */
  21185. makeGeometryUnique(): Mesh;
  21186. /**
  21187. * Set the index buffer of this mesh
  21188. * @param indices defines the source data
  21189. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21190. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21191. * @returns the current mesh
  21192. */
  21193. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21194. /**
  21195. * Update the current index buffer
  21196. * @param indices defines the source data
  21197. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21198. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  21199. * @returns the current mesh
  21200. */
  21201. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21202. /**
  21203. * Invert the geometry to move from a right handed system to a left handed one.
  21204. * @returns the current mesh
  21205. */
  21206. toLeftHanded(): Mesh;
  21207. /** @hidden */
  21208. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21209. /** @hidden */
  21210. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21211. /**
  21212. * Registers for this mesh a javascript function called just before the rendering process
  21213. * @param func defines the function to call before rendering this mesh
  21214. * @returns the current mesh
  21215. */
  21216. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21217. /**
  21218. * Disposes a previously registered javascript function called before the rendering
  21219. * @param func defines the function to remove
  21220. * @returns the current mesh
  21221. */
  21222. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21223. /**
  21224. * Registers for this mesh a javascript function called just after the rendering is complete
  21225. * @param func defines the function to call after rendering this mesh
  21226. * @returns the current mesh
  21227. */
  21228. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21229. /**
  21230. * Disposes a previously registered javascript function called after the rendering.
  21231. * @param func defines the function to remove
  21232. * @returns the current mesh
  21233. */
  21234. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21235. /** @hidden */
  21236. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21237. /** @hidden */
  21238. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21239. /** @hidden */
  21240. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21241. /** @hidden */
  21242. _freeze(): void;
  21243. /** @hidden */
  21244. _unFreeze(): void;
  21245. /**
  21246. * 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
  21247. * @param subMesh defines the subMesh to render
  21248. * @param enableAlphaMode defines if alpha mode can be changed
  21249. * @returns the current mesh
  21250. */
  21251. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21252. private _onBeforeDraw;
  21253. /**
  21254. * Renormalize the mesh and patch it up if there are no weights
  21255. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21256. * However in the case of zero weights then we set just a single influence to 1.
  21257. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21258. */
  21259. cleanMatrixWeights(): void;
  21260. private normalizeSkinFourWeights;
  21261. private normalizeSkinWeightsAndExtra;
  21262. /**
  21263. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21264. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21265. * the user know there was an issue with importing the mesh
  21266. * @returns a validation object with skinned, valid and report string
  21267. */
  21268. validateSkinning(): {
  21269. skinned: boolean;
  21270. valid: boolean;
  21271. report: string;
  21272. };
  21273. /** @hidden */
  21274. _checkDelayState(): Mesh;
  21275. private _queueLoad;
  21276. /**
  21277. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21278. * A mesh is in the frustum if its bounding box intersects the frustum
  21279. * @param frustumPlanes defines the frustum to test
  21280. * @returns true if the mesh is in the frustum planes
  21281. */
  21282. isInFrustum(frustumPlanes: Plane[]): boolean;
  21283. /**
  21284. * Sets the mesh material by the material or multiMaterial `id` property
  21285. * @param id is a string identifying the material or the multiMaterial
  21286. * @returns the current mesh
  21287. */
  21288. setMaterialByID(id: string): Mesh;
  21289. /**
  21290. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21291. * @returns an array of IAnimatable
  21292. */
  21293. getAnimatables(): IAnimatable[];
  21294. /**
  21295. * Modifies the mesh geometry according to the passed transformation matrix.
  21296. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21297. * The mesh normals are modified using the same transformation.
  21298. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21299. * @param transform defines the transform matrix to use
  21300. * @see http://doc.babylonjs.com/resources/baking_transformations
  21301. * @returns the current mesh
  21302. */
  21303. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21304. /**
  21305. * Modifies the mesh geometry according to its own current World Matrix.
  21306. * The mesh World Matrix is then reset.
  21307. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21308. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21309. * @see http://doc.babylonjs.com/resources/baking_transformations
  21310. * @returns the current mesh
  21311. */
  21312. bakeCurrentTransformIntoVertices(): Mesh;
  21313. /** @hidden */
  21314. readonly _positions: Nullable<Vector3[]>;
  21315. /** @hidden */
  21316. _resetPointsArrayCache(): Mesh;
  21317. /** @hidden */
  21318. _generatePointsArray(): boolean;
  21319. /**
  21320. * Returns a new Mesh object generated from the current mesh properties.
  21321. * This method must not get confused with createInstance()
  21322. * @param name is a string, the name given to the new mesh
  21323. * @param newParent can be any Node object (default `null`)
  21324. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21325. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21326. * @returns a new mesh
  21327. */
  21328. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21329. /**
  21330. * Releases resources associated with this mesh.
  21331. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21332. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21333. */
  21334. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21335. /**
  21336. * Modifies the mesh geometry according to a displacement map.
  21337. * 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.
  21338. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21339. * @param url is a string, the URL from the image file is to be downloaded.
  21340. * @param minHeight is the lower limit of the displacement.
  21341. * @param maxHeight is the upper limit of the displacement.
  21342. * @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.
  21343. * @param uvOffset is an optional vector2 used to offset UV.
  21344. * @param uvScale is an optional vector2 used to scale UV.
  21345. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  21346. * @returns the Mesh.
  21347. */
  21348. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21349. /**
  21350. * Modifies the mesh geometry according to a displacementMap buffer.
  21351. * 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.
  21352. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21353. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21354. * @param heightMapWidth is the width of the buffer image.
  21355. * @param heightMapHeight is the height of the buffer image.
  21356. * @param minHeight is the lower limit of the displacement.
  21357. * @param maxHeight is the upper limit of the displacement.
  21358. * @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.
  21359. * @param uvOffset is an optional vector2 used to offset UV.
  21360. * @param uvScale is an optional vector2 used to scale UV.
  21361. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  21362. * @returns the Mesh.
  21363. */
  21364. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21365. /**
  21366. * Modify the mesh to get a flat shading rendering.
  21367. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21368. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21369. * @returns current mesh
  21370. */
  21371. convertToFlatShadedMesh(): Mesh;
  21372. /**
  21373. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21374. * In other words, more vertices, no more indices and a single bigger VBO.
  21375. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21376. * @returns current mesh
  21377. */
  21378. convertToUnIndexedMesh(): Mesh;
  21379. /**
  21380. * Inverses facet orientations.
  21381. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21382. * @param flipNormals will also inverts the normals
  21383. * @returns current mesh
  21384. */
  21385. flipFaces(flipNormals?: boolean): Mesh;
  21386. /**
  21387. * Increase the number of facets and hence vertices in a mesh
  21388. * Vertex normals are interpolated from existing vertex normals
  21389. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21390. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21391. */
  21392. increaseVertices(numberPerEdge: number): void;
  21393. /**
  21394. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21395. * This will undo any application of covertToFlatShadedMesh
  21396. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21397. */
  21398. forceSharedVertices(): void;
  21399. /** @hidden */
  21400. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21401. /** @hidden */
  21402. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21403. /**
  21404. * Creates a new InstancedMesh object from the mesh model.
  21405. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21406. * @param name defines the name of the new instance
  21407. * @returns a new InstancedMesh
  21408. */
  21409. createInstance(name: string): InstancedMesh;
  21410. /**
  21411. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21412. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21413. * @returns the current mesh
  21414. */
  21415. synchronizeInstances(): Mesh;
  21416. /**
  21417. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21418. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21419. * This should be used together with the simplification to avoid disappearing triangles.
  21420. * @param successCallback an optional success callback to be called after the optimization finished.
  21421. * @returns the current mesh
  21422. */
  21423. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21424. /**
  21425. * Serialize current mesh
  21426. * @param serializationObject defines the object which will receive the serialization data
  21427. */
  21428. serialize(serializationObject: any): void;
  21429. /** @hidden */
  21430. _syncGeometryWithMorphTargetManager(): void;
  21431. /** @hidden */
  21432. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21433. /**
  21434. * Returns a new Mesh object parsed from the source provided.
  21435. * @param parsedMesh is the source
  21436. * @param scene defines the hosting scene
  21437. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21438. * @returns a new Mesh
  21439. */
  21440. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21441. /**
  21442. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21443. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21444. * @param name defines the name of the mesh to create
  21445. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21446. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21447. * @param closePath creates a seam between the first and the last points of each path of the path array
  21448. * @param offset is taken in account only if the `pathArray` is containing a single path
  21449. * @param scene defines the hosting scene
  21450. * @param updatable defines if the mesh must be flagged as updatable
  21451. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21452. * @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)
  21453. * @returns a new Mesh
  21454. */
  21455. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21456. /**
  21457. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21458. * @param name defines the name of the mesh to create
  21459. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21460. * @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
  21461. * @param scene defines the hosting scene
  21462. * @param updatable defines if the mesh must be flagged as updatable
  21463. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21464. * @returns a new Mesh
  21465. */
  21466. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21467. /**
  21468. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21469. * @param name defines the name of the mesh to create
  21470. * @param size sets the size (float) of each box side (default 1)
  21471. * @param scene defines the hosting scene
  21472. * @param updatable defines if the mesh must be flagged as updatable
  21473. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21474. * @returns a new Mesh
  21475. */
  21476. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21477. /**
  21478. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21479. * @param name defines the name of the mesh to create
  21480. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21481. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21482. * @param scene defines the hosting scene
  21483. * @param updatable defines if the mesh must be flagged as updatable
  21484. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21485. * @returns a new Mesh
  21486. */
  21487. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21488. /**
  21489. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21490. * @param name defines the name of the mesh to create
  21491. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21492. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21493. * @param scene defines the hosting scene
  21494. * @returns a new Mesh
  21495. */
  21496. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21497. /**
  21498. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21499. * @param name defines the name of the mesh to create
  21500. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21501. * @param diameterTop set the top cap diameter (floats, default 1)
  21502. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21503. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21504. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21505. * @param scene defines the hosting scene
  21506. * @param updatable defines if the mesh must be flagged as updatable
  21507. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21508. * @returns a new Mesh
  21509. */
  21510. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21511. /**
  21512. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21513. * @param name defines the name of the mesh to create
  21514. * @param diameter sets the diameter size (float) of the torus (default 1)
  21515. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21516. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21517. * @param scene defines the hosting scene
  21518. * @param updatable defines if the mesh must be flagged as updatable
  21519. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21520. * @returns a new Mesh
  21521. */
  21522. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21523. /**
  21524. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21525. * @param name defines the name of the mesh to create
  21526. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21527. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21528. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21529. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21530. * @param p the number of windings on X axis (positive integers, default 2)
  21531. * @param q the number of windings on Y axis (positive integers, default 3)
  21532. * @param scene defines the hosting scene
  21533. * @param updatable defines if the mesh must be flagged as updatable
  21534. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21535. * @returns a new Mesh
  21536. */
  21537. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21538. /**
  21539. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21540. * @param name defines the name of the mesh to create
  21541. * @param points is an array successive Vector3
  21542. * @param scene defines the hosting scene
  21543. * @param updatable defines if the mesh must be flagged as updatable
  21544. * @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).
  21545. * @returns a new Mesh
  21546. */
  21547. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21548. /**
  21549. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21550. * @param name defines the name of the mesh to create
  21551. * @param points is an array successive Vector3
  21552. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21553. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21554. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21555. * @param scene defines the hosting scene
  21556. * @param updatable defines if the mesh must be flagged as updatable
  21557. * @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)
  21558. * @returns a new Mesh
  21559. */
  21560. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21561. /**
  21562. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21563. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21564. * 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.
  21565. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21566. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21567. * Remember you can only change the shape positions, not their number when updating a polygon.
  21568. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21569. * @param name defines the name of the mesh to create
  21570. * @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
  21571. * @param scene defines the hosting scene
  21572. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21573. * @param updatable defines if the mesh must be flagged as updatable
  21574. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21575. * @param earcutInjection can be used to inject your own earcut reference
  21576. * @returns a new Mesh
  21577. */
  21578. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21579. /**
  21580. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21581. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21582. * @param name defines the name of the mesh to create
  21583. * @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
  21584. * @param depth defines the height of extrusion
  21585. * @param scene defines the hosting scene
  21586. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21587. * @param updatable defines if the mesh must be flagged as updatable
  21588. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21589. * @param earcutInjection can be used to inject your own earcut reference
  21590. * @returns a new Mesh
  21591. */
  21592. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21593. /**
  21594. * Creates an extruded shape mesh.
  21595. * 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
  21596. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21597. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21598. * @param name defines the name of the mesh to create
  21599. * @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
  21600. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21601. * @param scale is the value to scale the shape
  21602. * @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
  21603. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  21604. * @param scene defines the hosting scene
  21605. * @param updatable defines if the mesh must be flagged as updatable
  21606. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21607. * @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)
  21608. * @returns a new Mesh
  21609. */
  21610. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21611. /**
  21612. * Creates an custom extruded shape mesh.
  21613. * The custom extrusion is a parametric shape.
  21614. * It has no predefined shape. Its final shape will depend on the input parameters.
  21615. * Please consider using the same method from the MeshBuilder class instead
  21616. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21617. * @param name defines the name of the mesh to create
  21618. * @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
  21619. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21620. * @param scaleFunction is a custom Javascript function called on each path point
  21621. * @param rotationFunction is a custom Javascript function called on each path point
  21622. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21623. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21624. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  21625. * @param scene defines the hosting scene
  21626. * @param updatable defines if the mesh must be flagged as updatable
  21627. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21628. * @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)
  21629. * @returns a new Mesh
  21630. */
  21631. 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;
  21632. /**
  21633. * Creates lathe mesh.
  21634. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21635. * Please consider using the same method from the MeshBuilder class instead
  21636. * @param name defines the name of the mesh to create
  21637. * @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
  21638. * @param radius is the radius value of the lathe
  21639. * @param tessellation is the side number of the lathe.
  21640. * @param scene defines the hosting scene
  21641. * @param updatable defines if the mesh must be flagged as updatable
  21642. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21643. * @returns a new Mesh
  21644. */
  21645. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21646. /**
  21647. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21648. * @param name defines the name of the mesh to create
  21649. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21650. * @param scene defines the hosting scene
  21651. * @param updatable defines if the mesh must be flagged as updatable
  21652. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21653. * @returns a new Mesh
  21654. */
  21655. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21656. /**
  21657. * Creates a ground mesh.
  21658. * Please consider using the same method from the MeshBuilder class instead
  21659. * @param name defines the name of the mesh to create
  21660. * @param width set the width of the ground
  21661. * @param height set the height of the ground
  21662. * @param subdivisions sets the number of subdivisions per side
  21663. * @param scene defines the hosting scene
  21664. * @param updatable defines if the mesh must be flagged as updatable
  21665. * @returns a new Mesh
  21666. */
  21667. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21668. /**
  21669. * Creates a tiled ground mesh.
  21670. * Please consider using the same method from the MeshBuilder class instead
  21671. * @param name defines the name of the mesh to create
  21672. * @param xmin set the ground minimum X coordinate
  21673. * @param zmin set the ground minimum Y coordinate
  21674. * @param xmax set the ground maximum X coordinate
  21675. * @param zmax set the ground maximum Z coordinate
  21676. * @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
  21677. * @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
  21678. * @param scene defines the hosting scene
  21679. * @param updatable defines if the mesh must be flagged as updatable
  21680. * @returns a new Mesh
  21681. */
  21682. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21683. w: number;
  21684. h: number;
  21685. }, precision: {
  21686. w: number;
  21687. h: number;
  21688. }, scene: Scene, updatable?: boolean): Mesh;
  21689. /**
  21690. * Creates a ground mesh from a height map.
  21691. * Please consider using the same method from the MeshBuilder class instead
  21692. * @see http://doc.babylonjs.com/babylon101/height_map
  21693. * @param name defines the name of the mesh to create
  21694. * @param url sets the URL of the height map image resource
  21695. * @param width set the ground width size
  21696. * @param height set the ground height size
  21697. * @param subdivisions sets the number of subdivision per side
  21698. * @param minHeight is the minimum altitude on the ground
  21699. * @param maxHeight is the maximum altitude on the ground
  21700. * @param scene defines the hosting scene
  21701. * @param updatable defines if the mesh must be flagged as updatable
  21702. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21703. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21704. * @returns a new Mesh
  21705. */
  21706. 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;
  21707. /**
  21708. * Creates a tube mesh.
  21709. * The tube is a parametric shape.
  21710. * It has no predefined shape. Its final shape will depend on the input parameters.
  21711. * Please consider using the same method from the MeshBuilder class instead
  21712. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21713. * @param name defines the name of the mesh to create
  21714. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21715. * @param radius sets the tube radius size
  21716. * @param tessellation is the number of sides on the tubular surface
  21717. * @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
  21718. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  21719. * @param scene defines the hosting scene
  21720. * @param updatable defines if the mesh must be flagged as updatable
  21721. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21722. * @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)
  21723. * @returns a new Mesh
  21724. */
  21725. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21726. (i: number, distance: number): number;
  21727. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21728. /**
  21729. * Creates a polyhedron mesh.
  21730. * Please consider using the same method from the MeshBuilder class instead.
  21731. * * 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
  21732. * * The parameter `size` (positive float, default 1) sets the polygon size
  21733. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21734. * * 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`
  21735. * * 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
  21736. * * 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)`)
  21737. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  21738. * * 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
  21739. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21740. * * 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
  21741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21742. * @param name defines the name of the mesh to create
  21743. * @param options defines the options used to create the mesh
  21744. * @param scene defines the hosting scene
  21745. * @returns a new Mesh
  21746. */
  21747. static CreatePolyhedron(name: string, options: {
  21748. type?: number;
  21749. size?: number;
  21750. sizeX?: number;
  21751. sizeY?: number;
  21752. sizeZ?: number;
  21753. custom?: any;
  21754. faceUV?: Vector4[];
  21755. faceColors?: Color4[];
  21756. updatable?: boolean;
  21757. sideOrientation?: number;
  21758. }, scene: Scene): Mesh;
  21759. /**
  21760. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21761. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21762. * * 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`)
  21763. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21764. * * 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
  21765. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21766. * * 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
  21767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21768. * @param name defines the name of the mesh
  21769. * @param options defines the options used to create the mesh
  21770. * @param scene defines the hosting scene
  21771. * @returns a new Mesh
  21772. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21773. */
  21774. static CreateIcoSphere(name: string, options: {
  21775. radius?: number;
  21776. flat?: boolean;
  21777. subdivisions?: number;
  21778. sideOrientation?: number;
  21779. updatable?: boolean;
  21780. }, scene: Scene): Mesh;
  21781. /**
  21782. * Creates a decal mesh.
  21783. * Please consider using the same method from the MeshBuilder class instead.
  21784. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21785. * @param name defines the name of the mesh
  21786. * @param sourceMesh defines the mesh receiving the decal
  21787. * @param position sets the position of the decal in world coordinates
  21788. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21789. * @param size sets the decal scaling
  21790. * @param angle sets the angle to rotate the decal
  21791. * @returns a new Mesh
  21792. */
  21793. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21794. /**
  21795. * Prepare internal position array for software CPU skinning
  21796. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21797. */
  21798. setPositionsForCPUSkinning(): Float32Array;
  21799. /**
  21800. * Prepare internal normal array for software CPU skinning
  21801. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21802. */
  21803. setNormalsForCPUSkinning(): Float32Array;
  21804. /**
  21805. * Updates the vertex buffer by applying transformation from the bones
  21806. * @param skeleton defines the skeleton to apply to current mesh
  21807. * @returns the current mesh
  21808. */
  21809. applySkeleton(skeleton: Skeleton): Mesh;
  21810. /**
  21811. * 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
  21812. * @param meshes defines the list of meshes to scan
  21813. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21814. */
  21815. static MinMax(meshes: AbstractMesh[]): {
  21816. min: Vector3;
  21817. max: Vector3;
  21818. };
  21819. /**
  21820. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21821. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21822. * @returns a vector3
  21823. */
  21824. static Center(meshesOrMinMaxVector: {
  21825. min: Vector3;
  21826. max: Vector3;
  21827. } | AbstractMesh[]): Vector3;
  21828. /**
  21829. * Merge the array of meshes into a single mesh for performance reasons.
  21830. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21831. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21832. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21833. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21834. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21835. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21836. * @returns a new mesh
  21837. */
  21838. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21839. /** @hidden */
  21840. addInstance(instance: InstancedMesh): void;
  21841. /** @hidden */
  21842. removeInstance(instance: InstancedMesh): void;
  21843. }
  21844. }
  21845. declare module BABYLON {
  21846. /**
  21847. * Base class for the main features of a material in Babylon.js
  21848. */
  21849. export class Material implements IAnimatable {
  21850. /**
  21851. * Returns the triangle fill mode
  21852. */
  21853. static readonly TriangleFillMode: number;
  21854. /**
  21855. * Returns the wireframe mode
  21856. */
  21857. static readonly WireFrameFillMode: number;
  21858. /**
  21859. * Returns the point fill mode
  21860. */
  21861. static readonly PointFillMode: number;
  21862. /**
  21863. * Returns the point list draw mode
  21864. */
  21865. static readonly PointListDrawMode: number;
  21866. /**
  21867. * Returns the line list draw mode
  21868. */
  21869. static readonly LineListDrawMode: number;
  21870. /**
  21871. * Returns the line loop draw mode
  21872. */
  21873. static readonly LineLoopDrawMode: number;
  21874. /**
  21875. * Returns the line strip draw mode
  21876. */
  21877. static readonly LineStripDrawMode: number;
  21878. /**
  21879. * Returns the triangle strip draw mode
  21880. */
  21881. static readonly TriangleStripDrawMode: number;
  21882. /**
  21883. * Returns the triangle fan draw mode
  21884. */
  21885. static readonly TriangleFanDrawMode: number;
  21886. /**
  21887. * Stores the clock-wise side orientation
  21888. */
  21889. static readonly ClockWiseSideOrientation: number;
  21890. /**
  21891. * Stores the counter clock-wise side orientation
  21892. */
  21893. static readonly CounterClockWiseSideOrientation: number;
  21894. /**
  21895. * The dirty texture flag value
  21896. */
  21897. static readonly TextureDirtyFlag: number;
  21898. /**
  21899. * The dirty light flag value
  21900. */
  21901. static readonly LightDirtyFlag: number;
  21902. /**
  21903. * The dirty fresnel flag value
  21904. */
  21905. static readonly FresnelDirtyFlag: number;
  21906. /**
  21907. * The dirty attribute flag value
  21908. */
  21909. static readonly AttributesDirtyFlag: number;
  21910. /**
  21911. * The dirty misc flag value
  21912. */
  21913. static readonly MiscDirtyFlag: number;
  21914. /**
  21915. * The all dirty flag value
  21916. */
  21917. static readonly AllDirtyFlag: number;
  21918. /**
  21919. * The ID of the material
  21920. */
  21921. id: string;
  21922. /**
  21923. * Gets or sets the unique id of the material
  21924. */
  21925. uniqueId: number;
  21926. /**
  21927. * The name of the material
  21928. */
  21929. name: string;
  21930. /**
  21931. * Gets or sets user defined metadata
  21932. */
  21933. metadata: any;
  21934. /**
  21935. * For internal use only. Please do not use.
  21936. */
  21937. reservedDataStore: any;
  21938. /**
  21939. * Specifies if the ready state should be checked on each call
  21940. */
  21941. checkReadyOnEveryCall: boolean;
  21942. /**
  21943. * Specifies if the ready state should be checked once
  21944. */
  21945. checkReadyOnlyOnce: boolean;
  21946. /**
  21947. * The state of the material
  21948. */
  21949. state: string;
  21950. /**
  21951. * The alpha value of the material
  21952. */
  21953. protected _alpha: number;
  21954. /**
  21955. * List of inspectable custom properties (used by the Inspector)
  21956. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21957. */
  21958. inspectableCustomProperties: IInspectable[];
  21959. /**
  21960. * Sets the alpha value of the material
  21961. */
  21962. /**
  21963. * Gets the alpha value of the material
  21964. */
  21965. alpha: number;
  21966. /**
  21967. * Specifies if back face culling is enabled
  21968. */
  21969. protected _backFaceCulling: boolean;
  21970. /**
  21971. * Sets the back-face culling state
  21972. */
  21973. /**
  21974. * Gets the back-face culling state
  21975. */
  21976. backFaceCulling: boolean;
  21977. /**
  21978. * Stores the value for side orientation
  21979. */
  21980. sideOrientation: number;
  21981. /**
  21982. * Callback triggered when the material is compiled
  21983. */
  21984. onCompiled: Nullable<(effect: Effect) => void>;
  21985. /**
  21986. * Callback triggered when an error occurs
  21987. */
  21988. onError: Nullable<(effect: Effect, errors: string) => void>;
  21989. /**
  21990. * Callback triggered to get the render target textures
  21991. */
  21992. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21993. /**
  21994. * Gets a boolean indicating that current material needs to register RTT
  21995. */
  21996. readonly hasRenderTargetTextures: boolean;
  21997. /**
  21998. * Specifies if the material should be serialized
  21999. */
  22000. doNotSerialize: boolean;
  22001. /**
  22002. * @hidden
  22003. */
  22004. _storeEffectOnSubMeshes: boolean;
  22005. /**
  22006. * Stores the animations for the material
  22007. */
  22008. animations: Nullable<Array<Animation>>;
  22009. /**
  22010. * An event triggered when the material is disposed
  22011. */
  22012. onDisposeObservable: Observable<Material>;
  22013. /**
  22014. * An observer which watches for dispose events
  22015. */
  22016. private _onDisposeObserver;
  22017. private _onUnBindObservable;
  22018. /**
  22019. * Called during a dispose event
  22020. */
  22021. onDispose: () => void;
  22022. private _onBindObservable;
  22023. /**
  22024. * An event triggered when the material is bound
  22025. */
  22026. readonly onBindObservable: Observable<AbstractMesh>;
  22027. /**
  22028. * An observer which watches for bind events
  22029. */
  22030. private _onBindObserver;
  22031. /**
  22032. * Called during a bind event
  22033. */
  22034. onBind: (Mesh: AbstractMesh) => void;
  22035. /**
  22036. * An event triggered when the material is unbound
  22037. */
  22038. readonly onUnBindObservable: Observable<Material>;
  22039. /**
  22040. * Stores the value of the alpha mode
  22041. */
  22042. private _alphaMode;
  22043. /**
  22044. * Sets the value of the alpha mode.
  22045. *
  22046. * | Value | Type | Description |
  22047. * | --- | --- | --- |
  22048. * | 0 | ALPHA_DISABLE | |
  22049. * | 1 | ALPHA_ADD | |
  22050. * | 2 | ALPHA_COMBINE | |
  22051. * | 3 | ALPHA_SUBTRACT | |
  22052. * | 4 | ALPHA_MULTIPLY | |
  22053. * | 5 | ALPHA_MAXIMIZED | |
  22054. * | 6 | ALPHA_ONEONE | |
  22055. * | 7 | ALPHA_PREMULTIPLIED | |
  22056. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22057. * | 9 | ALPHA_INTERPOLATE | |
  22058. * | 10 | ALPHA_SCREENMODE | |
  22059. *
  22060. */
  22061. /**
  22062. * Gets the value of the alpha mode
  22063. */
  22064. alphaMode: number;
  22065. /**
  22066. * Stores the state of the need depth pre-pass value
  22067. */
  22068. private _needDepthPrePass;
  22069. /**
  22070. * Sets the need depth pre-pass value
  22071. */
  22072. /**
  22073. * Gets the depth pre-pass value
  22074. */
  22075. needDepthPrePass: boolean;
  22076. /**
  22077. * Specifies if depth writing should be disabled
  22078. */
  22079. disableDepthWrite: boolean;
  22080. /**
  22081. * Specifies if depth writing should be forced
  22082. */
  22083. forceDepthWrite: boolean;
  22084. /**
  22085. * Specifies if there should be a separate pass for culling
  22086. */
  22087. separateCullingPass: boolean;
  22088. /**
  22089. * Stores the state specifing if fog should be enabled
  22090. */
  22091. private _fogEnabled;
  22092. /**
  22093. * Sets the state for enabling fog
  22094. */
  22095. /**
  22096. * Gets the value of the fog enabled state
  22097. */
  22098. fogEnabled: boolean;
  22099. /**
  22100. * Stores the size of points
  22101. */
  22102. pointSize: number;
  22103. /**
  22104. * Stores the z offset value
  22105. */
  22106. zOffset: number;
  22107. /**
  22108. * Gets a value specifying if wireframe mode is enabled
  22109. */
  22110. /**
  22111. * Sets the state of wireframe mode
  22112. */
  22113. wireframe: boolean;
  22114. /**
  22115. * Gets the value specifying if point clouds are enabled
  22116. */
  22117. /**
  22118. * Sets the state of point cloud mode
  22119. */
  22120. pointsCloud: boolean;
  22121. /**
  22122. * Gets the material fill mode
  22123. */
  22124. /**
  22125. * Sets the material fill mode
  22126. */
  22127. fillMode: number;
  22128. /**
  22129. * @hidden
  22130. * Stores the effects for the material
  22131. */
  22132. _effect: Nullable<Effect>;
  22133. /**
  22134. * @hidden
  22135. * Specifies if the material was previously ready
  22136. */
  22137. _wasPreviouslyReady: boolean;
  22138. /**
  22139. * Specifies if uniform buffers should be used
  22140. */
  22141. private _useUBO;
  22142. /**
  22143. * Stores a reference to the scene
  22144. */
  22145. private _scene;
  22146. /**
  22147. * Stores the fill mode state
  22148. */
  22149. private _fillMode;
  22150. /**
  22151. * Specifies if the depth write state should be cached
  22152. */
  22153. private _cachedDepthWriteState;
  22154. /**
  22155. * Stores the uniform buffer
  22156. */
  22157. protected _uniformBuffer: UniformBuffer;
  22158. /** @hidden */
  22159. _indexInSceneMaterialArray: number;
  22160. /** @hidden */
  22161. meshMap: Nullable<{
  22162. [id: string]: AbstractMesh | undefined;
  22163. }>;
  22164. /**
  22165. * Creates a material instance
  22166. * @param name defines the name of the material
  22167. * @param scene defines the scene to reference
  22168. * @param doNotAdd specifies if the material should be added to the scene
  22169. */
  22170. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22171. /**
  22172. * Returns a string representation of the current material
  22173. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22174. * @returns a string with material information
  22175. */
  22176. toString(fullDetails?: boolean): string;
  22177. /**
  22178. * Gets the class name of the material
  22179. * @returns a string with the class name of the material
  22180. */
  22181. getClassName(): string;
  22182. /**
  22183. * Specifies if updates for the material been locked
  22184. */
  22185. readonly isFrozen: boolean;
  22186. /**
  22187. * Locks updates for the material
  22188. */
  22189. freeze(): void;
  22190. /**
  22191. * Unlocks updates for the material
  22192. */
  22193. unfreeze(): void;
  22194. /**
  22195. * Specifies if the material is ready to be used
  22196. * @param mesh defines the mesh to check
  22197. * @param useInstances specifies if instances should be used
  22198. * @returns a boolean indicating if the material is ready to be used
  22199. */
  22200. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22201. /**
  22202. * Specifies that the submesh is ready to be used
  22203. * @param mesh defines the mesh to check
  22204. * @param subMesh defines which submesh to check
  22205. * @param useInstances specifies that instances should be used
  22206. * @returns a boolean indicating that the submesh is ready or not
  22207. */
  22208. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22209. /**
  22210. * Returns the material effect
  22211. * @returns the effect associated with the material
  22212. */
  22213. getEffect(): Nullable<Effect>;
  22214. /**
  22215. * Returns the current scene
  22216. * @returns a Scene
  22217. */
  22218. getScene(): Scene;
  22219. /**
  22220. * Specifies if the material will require alpha blending
  22221. * @returns a boolean specifying if alpha blending is needed
  22222. */
  22223. needAlphaBlending(): boolean;
  22224. /**
  22225. * Specifies if the mesh will require alpha blending
  22226. * @param mesh defines the mesh to check
  22227. * @returns a boolean specifying if alpha blending is needed for the mesh
  22228. */
  22229. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22230. /**
  22231. * Specifies if this material should be rendered in alpha test mode
  22232. * @returns a boolean specifying if an alpha test is needed.
  22233. */
  22234. needAlphaTesting(): boolean;
  22235. /**
  22236. * Gets the texture used for the alpha test
  22237. * @returns the texture to use for alpha testing
  22238. */
  22239. getAlphaTestTexture(): Nullable<BaseTexture>;
  22240. /**
  22241. * Marks the material to indicate that it needs to be re-calculated
  22242. */
  22243. markDirty(): void;
  22244. /** @hidden */
  22245. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22246. /**
  22247. * Binds the material to the mesh
  22248. * @param world defines the world transformation matrix
  22249. * @param mesh defines the mesh to bind the material to
  22250. */
  22251. bind(world: Matrix, mesh?: Mesh): void;
  22252. /**
  22253. * Binds the submesh to the material
  22254. * @param world defines the world transformation matrix
  22255. * @param mesh defines the mesh containing the submesh
  22256. * @param subMesh defines the submesh to bind the material to
  22257. */
  22258. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22259. /**
  22260. * Binds the world matrix to the material
  22261. * @param world defines the world transformation matrix
  22262. */
  22263. bindOnlyWorldMatrix(world: Matrix): void;
  22264. /**
  22265. * Binds the scene's uniform buffer to the effect.
  22266. * @param effect defines the effect to bind to the scene uniform buffer
  22267. * @param sceneUbo defines the uniform buffer storing scene data
  22268. */
  22269. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22270. /**
  22271. * Binds the view matrix to the effect
  22272. * @param effect defines the effect to bind the view matrix to
  22273. */
  22274. bindView(effect: Effect): void;
  22275. /**
  22276. * Binds the view projection matrix to the effect
  22277. * @param effect defines the effect to bind the view projection matrix to
  22278. */
  22279. bindViewProjection(effect: Effect): void;
  22280. /**
  22281. * Specifies if material alpha testing should be turned on for the mesh
  22282. * @param mesh defines the mesh to check
  22283. */
  22284. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22285. /**
  22286. * Processes to execute after binding the material to a mesh
  22287. * @param mesh defines the rendered mesh
  22288. */
  22289. protected _afterBind(mesh?: Mesh): void;
  22290. /**
  22291. * Unbinds the material from the mesh
  22292. */
  22293. unbind(): void;
  22294. /**
  22295. * Gets the active textures from the material
  22296. * @returns an array of textures
  22297. */
  22298. getActiveTextures(): BaseTexture[];
  22299. /**
  22300. * Specifies if the material uses a texture
  22301. * @param texture defines the texture to check against the material
  22302. * @returns a boolean specifying if the material uses the texture
  22303. */
  22304. hasTexture(texture: BaseTexture): boolean;
  22305. /**
  22306. * Makes a duplicate of the material, and gives it a new name
  22307. * @param name defines the new name for the duplicated material
  22308. * @returns the cloned material
  22309. */
  22310. clone(name: string): Nullable<Material>;
  22311. /**
  22312. * Gets the meshes bound to the material
  22313. * @returns an array of meshes bound to the material
  22314. */
  22315. getBindedMeshes(): AbstractMesh[];
  22316. /**
  22317. * Force shader compilation
  22318. * @param mesh defines the mesh associated with this material
  22319. * @param onCompiled defines a function to execute once the material is compiled
  22320. * @param options defines the options to configure the compilation
  22321. */
  22322. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22323. clipPlane: boolean;
  22324. }>): void;
  22325. /**
  22326. * Force shader compilation
  22327. * @param mesh defines the mesh that will use this material
  22328. * @param options defines additional options for compiling the shaders
  22329. * @returns a promise that resolves when the compilation completes
  22330. */
  22331. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22332. clipPlane: boolean;
  22333. }>): Promise<void>;
  22334. private static readonly _ImageProcessingDirtyCallBack;
  22335. private static readonly _TextureDirtyCallBack;
  22336. private static readonly _FresnelDirtyCallBack;
  22337. private static readonly _MiscDirtyCallBack;
  22338. private static readonly _LightsDirtyCallBack;
  22339. private static readonly _AttributeDirtyCallBack;
  22340. private static _FresnelAndMiscDirtyCallBack;
  22341. private static _TextureAndMiscDirtyCallBack;
  22342. private static readonly _DirtyCallbackArray;
  22343. private static readonly _RunDirtyCallBacks;
  22344. /**
  22345. * Marks a define in the material to indicate that it needs to be re-computed
  22346. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22347. */
  22348. markAsDirty(flag: number): void;
  22349. /**
  22350. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22351. * @param func defines a function which checks material defines against the submeshes
  22352. */
  22353. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22354. /**
  22355. * Indicates that image processing needs to be re-calculated for all submeshes
  22356. */
  22357. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22358. /**
  22359. * Indicates that textures need to be re-calculated for all submeshes
  22360. */
  22361. protected _markAllSubMeshesAsTexturesDirty(): void;
  22362. /**
  22363. * Indicates that fresnel needs to be re-calculated for all submeshes
  22364. */
  22365. protected _markAllSubMeshesAsFresnelDirty(): void;
  22366. /**
  22367. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22368. */
  22369. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22370. /**
  22371. * Indicates that lights need to be re-calculated for all submeshes
  22372. */
  22373. protected _markAllSubMeshesAsLightsDirty(): void;
  22374. /**
  22375. * Indicates that attributes need to be re-calculated for all submeshes
  22376. */
  22377. protected _markAllSubMeshesAsAttributesDirty(): void;
  22378. /**
  22379. * Indicates that misc needs to be re-calculated for all submeshes
  22380. */
  22381. protected _markAllSubMeshesAsMiscDirty(): void;
  22382. /**
  22383. * Indicates that textures and misc need to be re-calculated for all submeshes
  22384. */
  22385. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22386. /**
  22387. * Disposes the material
  22388. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22389. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22390. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22391. */
  22392. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22393. /** @hidden */
  22394. private releaseVertexArrayObject;
  22395. /**
  22396. * Serializes this material
  22397. * @returns the serialized material object
  22398. */
  22399. serialize(): any;
  22400. /**
  22401. * Creates a material from parsed material data
  22402. * @param parsedMaterial defines parsed material data
  22403. * @param scene defines the hosting scene
  22404. * @param rootUrl defines the root URL to use to load textures
  22405. * @returns a new material
  22406. */
  22407. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22408. }
  22409. }
  22410. declare module BABYLON {
  22411. /**
  22412. * Base class for submeshes
  22413. */
  22414. export class BaseSubMesh {
  22415. /** @hidden */
  22416. _materialDefines: Nullable<MaterialDefines>;
  22417. /** @hidden */
  22418. _materialEffect: Nullable<Effect>;
  22419. /**
  22420. * Gets associated effect
  22421. */
  22422. readonly effect: Nullable<Effect>;
  22423. /**
  22424. * Sets associated effect (effect used to render this submesh)
  22425. * @param effect defines the effect to associate with
  22426. * @param defines defines the set of defines used to compile this effect
  22427. */
  22428. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22429. }
  22430. /**
  22431. * Defines a subdivision inside a mesh
  22432. */
  22433. export class SubMesh extends BaseSubMesh implements ICullable {
  22434. /** the material index to use */
  22435. materialIndex: number;
  22436. /** vertex index start */
  22437. verticesStart: number;
  22438. /** vertices count */
  22439. verticesCount: number;
  22440. /** index start */
  22441. indexStart: number;
  22442. /** indices count */
  22443. indexCount: number;
  22444. /** @hidden */
  22445. _linesIndexCount: number;
  22446. private _mesh;
  22447. private _renderingMesh;
  22448. private _boundingInfo;
  22449. private _linesIndexBuffer;
  22450. /** @hidden */
  22451. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22452. /** @hidden */
  22453. _trianglePlanes: Plane[];
  22454. /** @hidden */
  22455. _lastColliderTransformMatrix: Nullable<Matrix>;
  22456. /** @hidden */
  22457. _renderId: number;
  22458. /** @hidden */
  22459. _alphaIndex: number;
  22460. /** @hidden */
  22461. _distanceToCamera: number;
  22462. /** @hidden */
  22463. _id: number;
  22464. private _currentMaterial;
  22465. /**
  22466. * Add a new submesh to a mesh
  22467. * @param materialIndex defines the material index to use
  22468. * @param verticesStart defines vertex index start
  22469. * @param verticesCount defines vertices count
  22470. * @param indexStart defines index start
  22471. * @param indexCount defines indices count
  22472. * @param mesh defines the parent mesh
  22473. * @param renderingMesh defines an optional rendering mesh
  22474. * @param createBoundingBox defines if bounding box should be created for this submesh
  22475. * @returns the new submesh
  22476. */
  22477. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22478. /**
  22479. * Creates a new submesh
  22480. * @param materialIndex defines the material index to use
  22481. * @param verticesStart defines vertex index start
  22482. * @param verticesCount defines vertices count
  22483. * @param indexStart defines index start
  22484. * @param indexCount defines indices count
  22485. * @param mesh defines the parent mesh
  22486. * @param renderingMesh defines an optional rendering mesh
  22487. * @param createBoundingBox defines if bounding box should be created for this submesh
  22488. */
  22489. constructor(
  22490. /** the material index to use */
  22491. materialIndex: number,
  22492. /** vertex index start */
  22493. verticesStart: number,
  22494. /** vertices count */
  22495. verticesCount: number,
  22496. /** index start */
  22497. indexStart: number,
  22498. /** indices count */
  22499. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22500. /**
  22501. * Returns true if this submesh covers the entire parent mesh
  22502. * @ignorenaming
  22503. */
  22504. readonly IsGlobal: boolean;
  22505. /**
  22506. * Returns the submesh BoudingInfo object
  22507. * @returns current bounding info (or mesh's one if the submesh is global)
  22508. */
  22509. getBoundingInfo(): BoundingInfo;
  22510. /**
  22511. * Sets the submesh BoundingInfo
  22512. * @param boundingInfo defines the new bounding info to use
  22513. * @returns the SubMesh
  22514. */
  22515. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22516. /**
  22517. * Returns the mesh of the current submesh
  22518. * @return the parent mesh
  22519. */
  22520. getMesh(): AbstractMesh;
  22521. /**
  22522. * Returns the rendering mesh of the submesh
  22523. * @returns the rendering mesh (could be different from parent mesh)
  22524. */
  22525. getRenderingMesh(): Mesh;
  22526. /**
  22527. * Returns the submesh material
  22528. * @returns null or the current material
  22529. */
  22530. getMaterial(): Nullable<Material>;
  22531. /**
  22532. * Sets a new updated BoundingInfo object to the submesh
  22533. * @param data defines an optional position array to use to determine the bounding info
  22534. * @returns the SubMesh
  22535. */
  22536. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22537. /** @hidden */
  22538. _checkCollision(collider: Collider): boolean;
  22539. /**
  22540. * Updates the submesh BoundingInfo
  22541. * @param world defines the world matrix to use to update the bounding info
  22542. * @returns the submesh
  22543. */
  22544. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22545. /**
  22546. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22547. * @param frustumPlanes defines the frustum planes
  22548. * @returns true if the submesh is intersecting with the frustum
  22549. */
  22550. isInFrustum(frustumPlanes: Plane[]): boolean;
  22551. /**
  22552. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22553. * @param frustumPlanes defines the frustum planes
  22554. * @returns true if the submesh is inside the frustum
  22555. */
  22556. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22557. /**
  22558. * Renders the submesh
  22559. * @param enableAlphaMode defines if alpha needs to be used
  22560. * @returns the submesh
  22561. */
  22562. render(enableAlphaMode: boolean): SubMesh;
  22563. /**
  22564. * @hidden
  22565. */
  22566. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22567. /**
  22568. * Checks if the submesh intersects with a ray
  22569. * @param ray defines the ray to test
  22570. * @returns true is the passed ray intersects the submesh bounding box
  22571. */
  22572. canIntersects(ray: Ray): boolean;
  22573. /**
  22574. * Intersects current submesh with a ray
  22575. * @param ray defines the ray to test
  22576. * @param positions defines mesh's positions array
  22577. * @param indices defines mesh's indices array
  22578. * @param fastCheck defines if only bounding info should be used
  22579. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22580. * @returns intersection info or null if no intersection
  22581. */
  22582. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22583. /** @hidden */
  22584. private _intersectLines;
  22585. /** @hidden */
  22586. private _intersectTriangles;
  22587. /** @hidden */
  22588. _rebuild(): void;
  22589. /**
  22590. * Creates a new submesh from the passed mesh
  22591. * @param newMesh defines the new hosting mesh
  22592. * @param newRenderingMesh defines an optional rendering mesh
  22593. * @returns the new submesh
  22594. */
  22595. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22596. /**
  22597. * Release associated resources
  22598. */
  22599. dispose(): void;
  22600. /**
  22601. * Gets the class name
  22602. * @returns the string "SubMesh".
  22603. */
  22604. getClassName(): string;
  22605. /**
  22606. * Creates a new submesh from indices data
  22607. * @param materialIndex the index of the main mesh material
  22608. * @param startIndex the index where to start the copy in the mesh indices array
  22609. * @param indexCount the number of indices to copy then from the startIndex
  22610. * @param mesh the main mesh to create the submesh from
  22611. * @param renderingMesh the optional rendering mesh
  22612. * @returns a new submesh
  22613. */
  22614. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22615. }
  22616. }
  22617. declare module BABYLON {
  22618. /**
  22619. * Class used to store geometry data (vertex buffers + index buffer)
  22620. */
  22621. export class Geometry implements IGetSetVerticesData {
  22622. /**
  22623. * Gets or sets the ID of the geometry
  22624. */
  22625. id: string;
  22626. /**
  22627. * Gets or sets the unique ID of the geometry
  22628. */
  22629. uniqueId: number;
  22630. /**
  22631. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22632. */
  22633. delayLoadState: number;
  22634. /**
  22635. * Gets the file containing the data to load when running in delay load state
  22636. */
  22637. delayLoadingFile: Nullable<string>;
  22638. /**
  22639. * Callback called when the geometry is updated
  22640. */
  22641. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22642. private _scene;
  22643. private _engine;
  22644. private _meshes;
  22645. private _totalVertices;
  22646. /** @hidden */
  22647. _indices: IndicesArray;
  22648. /** @hidden */
  22649. _vertexBuffers: {
  22650. [key: string]: VertexBuffer;
  22651. };
  22652. private _isDisposed;
  22653. private _extend;
  22654. private _boundingBias;
  22655. /** @hidden */
  22656. _delayInfo: Array<string>;
  22657. private _indexBuffer;
  22658. private _indexBufferIsUpdatable;
  22659. /** @hidden */
  22660. _boundingInfo: Nullable<BoundingInfo>;
  22661. /** @hidden */
  22662. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22663. /** @hidden */
  22664. _softwareSkinningFrameId: number;
  22665. private _vertexArrayObjects;
  22666. private _updatable;
  22667. /** @hidden */
  22668. _positions: Nullable<Vector3[]>;
  22669. /**
  22670. * 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
  22671. */
  22672. /**
  22673. * 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
  22674. */
  22675. boundingBias: Vector2;
  22676. /**
  22677. * Static function used to attach a new empty geometry to a mesh
  22678. * @param mesh defines the mesh to attach the geometry to
  22679. * @returns the new Geometry
  22680. */
  22681. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22682. /**
  22683. * Creates a new geometry
  22684. * @param id defines the unique ID
  22685. * @param scene defines the hosting scene
  22686. * @param vertexData defines the VertexData used to get geometry data
  22687. * @param updatable defines if geometry must be updatable (false by default)
  22688. * @param mesh defines the mesh that will be associated with the geometry
  22689. */
  22690. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22691. /**
  22692. * Gets the current extend of the geometry
  22693. */
  22694. readonly extend: {
  22695. minimum: Vector3;
  22696. maximum: Vector3;
  22697. };
  22698. /**
  22699. * Gets the hosting scene
  22700. * @returns the hosting Scene
  22701. */
  22702. getScene(): Scene;
  22703. /**
  22704. * Gets the hosting engine
  22705. * @returns the hosting Engine
  22706. */
  22707. getEngine(): Engine;
  22708. /**
  22709. * Defines if the geometry is ready to use
  22710. * @returns true if the geometry is ready to be used
  22711. */
  22712. isReady(): boolean;
  22713. /**
  22714. * Gets a value indicating that the geometry should not be serialized
  22715. */
  22716. readonly doNotSerialize: boolean;
  22717. /** @hidden */
  22718. _rebuild(): void;
  22719. /**
  22720. * Affects all geometry data in one call
  22721. * @param vertexData defines the geometry data
  22722. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22723. */
  22724. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22725. /**
  22726. * Set specific vertex data
  22727. * @param kind defines the data kind (Position, normal, etc...)
  22728. * @param data defines the vertex data to use
  22729. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22730. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22731. */
  22732. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22733. /**
  22734. * Removes a specific vertex data
  22735. * @param kind defines the data kind (Position, normal, etc...)
  22736. */
  22737. removeVerticesData(kind: string): void;
  22738. /**
  22739. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22740. * @param buffer defines the vertex buffer to use
  22741. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22742. */
  22743. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22744. /**
  22745. * Update a specific vertex buffer
  22746. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22747. * It will do nothing if the buffer is not updatable
  22748. * @param kind defines the data kind (Position, normal, etc...)
  22749. * @param data defines the data to use
  22750. * @param offset defines the offset in the target buffer where to store the data
  22751. * @param useBytes set to true if the offset is in bytes
  22752. */
  22753. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22754. /**
  22755. * Update a specific vertex buffer
  22756. * This function will create a new buffer if the current one is not updatable
  22757. * @param kind defines the data kind (Position, normal, etc...)
  22758. * @param data defines the data to use
  22759. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22760. */
  22761. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22762. private _updateBoundingInfo;
  22763. /** @hidden */
  22764. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22765. /**
  22766. * Gets total number of vertices
  22767. * @returns the total number of vertices
  22768. */
  22769. getTotalVertices(): number;
  22770. /**
  22771. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22772. * @param kind defines the data kind (Position, normal, etc...)
  22773. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22774. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22775. * @returns a float array containing vertex data
  22776. */
  22777. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22778. /**
  22779. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22780. * @param kind defines the data kind (Position, normal, etc...)
  22781. * @returns true if the vertex buffer with the specified kind is updatable
  22782. */
  22783. isVertexBufferUpdatable(kind: string): boolean;
  22784. /**
  22785. * Gets a specific vertex buffer
  22786. * @param kind defines the data kind (Position, normal, etc...)
  22787. * @returns a VertexBuffer
  22788. */
  22789. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22790. /**
  22791. * Returns all vertex buffers
  22792. * @return an object holding all vertex buffers indexed by kind
  22793. */
  22794. getVertexBuffers(): Nullable<{
  22795. [key: string]: VertexBuffer;
  22796. }>;
  22797. /**
  22798. * Gets a boolean indicating if specific vertex buffer is present
  22799. * @param kind defines the data kind (Position, normal, etc...)
  22800. * @returns true if data is present
  22801. */
  22802. isVerticesDataPresent(kind: string): boolean;
  22803. /**
  22804. * Gets a list of all attached data kinds (Position, normal, etc...)
  22805. * @returns a list of string containing all kinds
  22806. */
  22807. getVerticesDataKinds(): string[];
  22808. /**
  22809. * Update index buffer
  22810. * @param indices defines the indices to store in the index buffer
  22811. * @param offset defines the offset in the target buffer where to store the data
  22812. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  22813. */
  22814. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22815. /**
  22816. * Creates a new index buffer
  22817. * @param indices defines the indices to store in the index buffer
  22818. * @param totalVertices defines the total number of vertices (could be null)
  22819. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22820. */
  22821. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22822. /**
  22823. * Return the total number of indices
  22824. * @returns the total number of indices
  22825. */
  22826. getTotalIndices(): number;
  22827. /**
  22828. * Gets the index buffer array
  22829. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22830. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22831. * @returns the index buffer array
  22832. */
  22833. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22834. /**
  22835. * Gets the index buffer
  22836. * @return the index buffer
  22837. */
  22838. getIndexBuffer(): Nullable<DataBuffer>;
  22839. /** @hidden */
  22840. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22841. /**
  22842. * Release the associated resources for a specific mesh
  22843. * @param mesh defines the source mesh
  22844. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22845. */
  22846. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22847. /**
  22848. * Apply current geometry to a given mesh
  22849. * @param mesh defines the mesh to apply geometry to
  22850. */
  22851. applyToMesh(mesh: Mesh): void;
  22852. private _updateExtend;
  22853. private _applyToMesh;
  22854. private notifyUpdate;
  22855. /**
  22856. * Load the geometry if it was flagged as delay loaded
  22857. * @param scene defines the hosting scene
  22858. * @param onLoaded defines a callback called when the geometry is loaded
  22859. */
  22860. load(scene: Scene, onLoaded?: () => void): void;
  22861. private _queueLoad;
  22862. /**
  22863. * Invert the geometry to move from a right handed system to a left handed one.
  22864. */
  22865. toLeftHanded(): void;
  22866. /** @hidden */
  22867. _resetPointsArrayCache(): void;
  22868. /** @hidden */
  22869. _generatePointsArray(): boolean;
  22870. /**
  22871. * Gets a value indicating if the geometry is disposed
  22872. * @returns true if the geometry was disposed
  22873. */
  22874. isDisposed(): boolean;
  22875. private _disposeVertexArrayObjects;
  22876. /**
  22877. * Free all associated resources
  22878. */
  22879. dispose(): void;
  22880. /**
  22881. * Clone the current geometry into a new geometry
  22882. * @param id defines the unique ID of the new geometry
  22883. * @returns a new geometry object
  22884. */
  22885. copy(id: string): Geometry;
  22886. /**
  22887. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22888. * @return a JSON representation of the current geometry data (without the vertices data)
  22889. */
  22890. serialize(): any;
  22891. private toNumberArray;
  22892. /**
  22893. * Serialize all vertices data into a JSON oject
  22894. * @returns a JSON representation of the current geometry data
  22895. */
  22896. serializeVerticeData(): any;
  22897. /**
  22898. * Extracts a clone of a mesh geometry
  22899. * @param mesh defines the source mesh
  22900. * @param id defines the unique ID of the new geometry object
  22901. * @returns the new geometry object
  22902. */
  22903. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22904. /**
  22905. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22906. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22907. * Be aware Math.random() could cause collisions, but:
  22908. * "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"
  22909. * @returns a string containing a new GUID
  22910. */
  22911. static RandomId(): string;
  22912. /** @hidden */
  22913. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22914. private static _CleanMatricesWeights;
  22915. /**
  22916. * Create a new geometry from persisted data (Using .babylon file format)
  22917. * @param parsedVertexData defines the persisted data
  22918. * @param scene defines the hosting scene
  22919. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22920. * @returns the new geometry object
  22921. */
  22922. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22923. }
  22924. }
  22925. declare module BABYLON {
  22926. /**
  22927. * Define an interface for all classes that will get and set the data on vertices
  22928. */
  22929. export interface IGetSetVerticesData {
  22930. /**
  22931. * Gets a boolean indicating if specific vertex data is present
  22932. * @param kind defines the vertex data kind to use
  22933. * @returns true is data kind is present
  22934. */
  22935. isVerticesDataPresent(kind: string): boolean;
  22936. /**
  22937. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22938. * @param kind defines the data kind (Position, normal, etc...)
  22939. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22940. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22941. * @returns a float array containing vertex data
  22942. */
  22943. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22944. /**
  22945. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22946. * @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.
  22947. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22948. * @returns the indices array or an empty array if the mesh has no geometry
  22949. */
  22950. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22951. /**
  22952. * Set specific vertex data
  22953. * @param kind defines the data kind (Position, normal, etc...)
  22954. * @param data defines the vertex data to use
  22955. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22956. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22957. */
  22958. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22959. /**
  22960. * Update a specific associated vertex buffer
  22961. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22962. * - VertexBuffer.PositionKind
  22963. * - VertexBuffer.UVKind
  22964. * - VertexBuffer.UV2Kind
  22965. * - VertexBuffer.UV3Kind
  22966. * - VertexBuffer.UV4Kind
  22967. * - VertexBuffer.UV5Kind
  22968. * - VertexBuffer.UV6Kind
  22969. * - VertexBuffer.ColorKind
  22970. * - VertexBuffer.MatricesIndicesKind
  22971. * - VertexBuffer.MatricesIndicesExtraKind
  22972. * - VertexBuffer.MatricesWeightsKind
  22973. * - VertexBuffer.MatricesWeightsExtraKind
  22974. * @param data defines the data source
  22975. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22976. * @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)
  22977. */
  22978. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22979. /**
  22980. * Creates a new index buffer
  22981. * @param indices defines the indices to store in the index buffer
  22982. * @param totalVertices defines the total number of vertices (could be null)
  22983. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22984. */
  22985. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22986. }
  22987. /**
  22988. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22989. */
  22990. export class VertexData {
  22991. /**
  22992. * Mesh side orientation : usually the external or front surface
  22993. */
  22994. static readonly FRONTSIDE: number;
  22995. /**
  22996. * Mesh side orientation : usually the internal or back surface
  22997. */
  22998. static readonly BACKSIDE: number;
  22999. /**
  23000. * Mesh side orientation : both internal and external or front and back surfaces
  23001. */
  23002. static readonly DOUBLESIDE: number;
  23003. /**
  23004. * Mesh side orientation : by default, `FRONTSIDE`
  23005. */
  23006. static readonly DEFAULTSIDE: number;
  23007. /**
  23008. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23009. */
  23010. positions: Nullable<FloatArray>;
  23011. /**
  23012. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23013. */
  23014. normals: Nullable<FloatArray>;
  23015. /**
  23016. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23017. */
  23018. tangents: Nullable<FloatArray>;
  23019. /**
  23020. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23021. */
  23022. uvs: Nullable<FloatArray>;
  23023. /**
  23024. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23025. */
  23026. uvs2: Nullable<FloatArray>;
  23027. /**
  23028. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23029. */
  23030. uvs3: Nullable<FloatArray>;
  23031. /**
  23032. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23033. */
  23034. uvs4: Nullable<FloatArray>;
  23035. /**
  23036. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23037. */
  23038. uvs5: Nullable<FloatArray>;
  23039. /**
  23040. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23041. */
  23042. uvs6: Nullable<FloatArray>;
  23043. /**
  23044. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23045. */
  23046. colors: Nullable<FloatArray>;
  23047. /**
  23048. * 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).
  23049. */
  23050. matricesIndices: Nullable<FloatArray>;
  23051. /**
  23052. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23053. */
  23054. matricesWeights: Nullable<FloatArray>;
  23055. /**
  23056. * An array extending the number of possible indices
  23057. */
  23058. matricesIndicesExtra: Nullable<FloatArray>;
  23059. /**
  23060. * An array extending the number of possible weights when the number of indices is extended
  23061. */
  23062. matricesWeightsExtra: Nullable<FloatArray>;
  23063. /**
  23064. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23065. */
  23066. indices: Nullable<IndicesArray>;
  23067. /**
  23068. * Uses the passed data array to set the set the values for the specified kind of data
  23069. * @param data a linear array of floating numbers
  23070. * @param kind the type of data that is being set, eg positions, colors etc
  23071. */
  23072. set(data: FloatArray, kind: string): void;
  23073. /**
  23074. * Associates the vertexData to the passed Mesh.
  23075. * Sets it as updatable or not (default `false`)
  23076. * @param mesh the mesh the vertexData is applied to
  23077. * @param updatable when used and having the value true allows new data to update the vertexData
  23078. * @returns the VertexData
  23079. */
  23080. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23081. /**
  23082. * Associates the vertexData to the passed Geometry.
  23083. * Sets it as updatable or not (default `false`)
  23084. * @param geometry the geometry the vertexData is applied to
  23085. * @param updatable when used and having the value true allows new data to update the vertexData
  23086. * @returns VertexData
  23087. */
  23088. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23089. /**
  23090. * Updates the associated mesh
  23091. * @param mesh the mesh to be updated
  23092. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23093. * @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
  23094. * @returns VertexData
  23095. */
  23096. updateMesh(mesh: Mesh): VertexData;
  23097. /**
  23098. * Updates the associated geometry
  23099. * @param geometry the geometry to be updated
  23100. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23101. * @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
  23102. * @returns VertexData.
  23103. */
  23104. updateGeometry(geometry: Geometry): VertexData;
  23105. private _applyTo;
  23106. private _update;
  23107. /**
  23108. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23109. * @param matrix the transforming matrix
  23110. * @returns the VertexData
  23111. */
  23112. transform(matrix: Matrix): VertexData;
  23113. /**
  23114. * Merges the passed VertexData into the current one
  23115. * @param other the VertexData to be merged into the current one
  23116. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23117. * @returns the modified VertexData
  23118. */
  23119. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23120. private _mergeElement;
  23121. private _validate;
  23122. /**
  23123. * Serializes the VertexData
  23124. * @returns a serialized object
  23125. */
  23126. serialize(): any;
  23127. /**
  23128. * Extracts the vertexData from a mesh
  23129. * @param mesh the mesh from which to extract the VertexData
  23130. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23131. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23132. * @returns the object VertexData associated to the passed mesh
  23133. */
  23134. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23135. /**
  23136. * Extracts the vertexData from the geometry
  23137. * @param geometry the geometry from which to extract the VertexData
  23138. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23139. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23140. * @returns the object VertexData associated to the passed mesh
  23141. */
  23142. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23143. private static _ExtractFrom;
  23144. /**
  23145. * Creates the VertexData for a Ribbon
  23146. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23147. * * pathArray array of paths, each of which an array of successive Vector3
  23148. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23149. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23150. * * 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
  23151. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23152. * * 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)
  23153. * * 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)
  23154. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23155. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23156. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23157. * @returns the VertexData of the ribbon
  23158. */
  23159. static CreateRibbon(options: {
  23160. pathArray: Vector3[][];
  23161. closeArray?: boolean;
  23162. closePath?: boolean;
  23163. offset?: number;
  23164. sideOrientation?: number;
  23165. frontUVs?: Vector4;
  23166. backUVs?: Vector4;
  23167. invertUV?: boolean;
  23168. uvs?: Vector2[];
  23169. colors?: Color4[];
  23170. }): VertexData;
  23171. /**
  23172. * Creates the VertexData for a box
  23173. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23174. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23175. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23176. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23177. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23178. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23179. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23180. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23181. * * 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)
  23182. * * 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)
  23183. * @returns the VertexData of the box
  23184. */
  23185. static CreateBox(options: {
  23186. size?: number;
  23187. width?: number;
  23188. height?: number;
  23189. depth?: number;
  23190. faceUV?: Vector4[];
  23191. faceColors?: Color4[];
  23192. sideOrientation?: number;
  23193. frontUVs?: Vector4;
  23194. backUVs?: Vector4;
  23195. }): VertexData;
  23196. /**
  23197. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23198. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23199. * * segments sets the number of horizontal strips optional, default 32
  23200. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23201. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23202. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23203. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23204. * * 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
  23205. * * 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
  23206. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23207. * * 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)
  23208. * * 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)
  23209. * @returns the VertexData of the ellipsoid
  23210. */
  23211. static CreateSphere(options: {
  23212. segments?: number;
  23213. diameter?: number;
  23214. diameterX?: number;
  23215. diameterY?: number;
  23216. diameterZ?: number;
  23217. arc?: number;
  23218. slice?: number;
  23219. sideOrientation?: number;
  23220. frontUVs?: Vector4;
  23221. backUVs?: Vector4;
  23222. }): VertexData;
  23223. /**
  23224. * Creates the VertexData for a cylinder, cone or prism
  23225. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23226. * * height sets the height (y direction) of the cylinder, optional, default 2
  23227. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23228. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23229. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23230. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23231. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23232. * * 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
  23233. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23234. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23235. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23236. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23237. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23238. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23239. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23240. * @returns the VertexData of the cylinder, cone or prism
  23241. */
  23242. static CreateCylinder(options: {
  23243. height?: number;
  23244. diameterTop?: number;
  23245. diameterBottom?: number;
  23246. diameter?: number;
  23247. tessellation?: number;
  23248. subdivisions?: number;
  23249. arc?: number;
  23250. faceColors?: Color4[];
  23251. faceUV?: Vector4[];
  23252. hasRings?: boolean;
  23253. enclose?: boolean;
  23254. sideOrientation?: number;
  23255. frontUVs?: Vector4;
  23256. backUVs?: Vector4;
  23257. }): VertexData;
  23258. /**
  23259. * Creates the VertexData for a torus
  23260. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23261. * * diameter the diameter of the torus, optional default 1
  23262. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23263. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23264. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23265. * * 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)
  23266. * * 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)
  23267. * @returns the VertexData of the torus
  23268. */
  23269. static CreateTorus(options: {
  23270. diameter?: number;
  23271. thickness?: number;
  23272. tessellation?: number;
  23273. sideOrientation?: number;
  23274. frontUVs?: Vector4;
  23275. backUVs?: Vector4;
  23276. }): VertexData;
  23277. /**
  23278. * Creates the VertexData of the LineSystem
  23279. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23280. * - lines an array of lines, each line being an array of successive Vector3
  23281. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23282. * @returns the VertexData of the LineSystem
  23283. */
  23284. static CreateLineSystem(options: {
  23285. lines: Vector3[][];
  23286. colors?: Nullable<Color4[][]>;
  23287. }): VertexData;
  23288. /**
  23289. * Create the VertexData for a DashedLines
  23290. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23291. * - points an array successive Vector3
  23292. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23293. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23294. * - dashNb the intended total number of dashes, optional, default 200
  23295. * @returns the VertexData for the DashedLines
  23296. */
  23297. static CreateDashedLines(options: {
  23298. points: Vector3[];
  23299. dashSize?: number;
  23300. gapSize?: number;
  23301. dashNb?: number;
  23302. }): VertexData;
  23303. /**
  23304. * Creates the VertexData for a Ground
  23305. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23306. * - width the width (x direction) of the ground, optional, default 1
  23307. * - height the height (z direction) of the ground, optional, default 1
  23308. * - subdivisions the number of subdivisions per side, optional, default 1
  23309. * @returns the VertexData of the Ground
  23310. */
  23311. static CreateGround(options: {
  23312. width?: number;
  23313. height?: number;
  23314. subdivisions?: number;
  23315. subdivisionsX?: number;
  23316. subdivisionsY?: number;
  23317. }): VertexData;
  23318. /**
  23319. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23320. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23321. * * xmin the ground minimum X coordinate, optional, default -1
  23322. * * zmin the ground minimum Z coordinate, optional, default -1
  23323. * * xmax the ground maximum X coordinate, optional, default 1
  23324. * * zmax the ground maximum Z coordinate, optional, default 1
  23325. * * 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}
  23326. * * 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}
  23327. * @returns the VertexData of the TiledGround
  23328. */
  23329. static CreateTiledGround(options: {
  23330. xmin: number;
  23331. zmin: number;
  23332. xmax: number;
  23333. zmax: number;
  23334. subdivisions?: {
  23335. w: number;
  23336. h: number;
  23337. };
  23338. precision?: {
  23339. w: number;
  23340. h: number;
  23341. };
  23342. }): VertexData;
  23343. /**
  23344. * Creates the VertexData of the Ground designed from a heightmap
  23345. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23346. * * width the width (x direction) of the ground
  23347. * * height the height (z direction) of the ground
  23348. * * subdivisions the number of subdivisions per side
  23349. * * minHeight the minimum altitude on the ground, optional, default 0
  23350. * * maxHeight the maximum altitude on the ground, optional default 1
  23351. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23352. * * buffer the array holding the image color data
  23353. * * bufferWidth the width of image
  23354. * * bufferHeight the height of image
  23355. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23356. * @returns the VertexData of the Ground designed from a heightmap
  23357. */
  23358. static CreateGroundFromHeightMap(options: {
  23359. width: number;
  23360. height: number;
  23361. subdivisions: number;
  23362. minHeight: number;
  23363. maxHeight: number;
  23364. colorFilter: Color3;
  23365. buffer: Uint8Array;
  23366. bufferWidth: number;
  23367. bufferHeight: number;
  23368. alphaFilter: number;
  23369. }): VertexData;
  23370. /**
  23371. * Creates the VertexData for a Plane
  23372. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23373. * * size sets the width and height of the plane to the value of size, optional default 1
  23374. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23375. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23376. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23377. * * 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)
  23378. * * 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)
  23379. * @returns the VertexData of the box
  23380. */
  23381. static CreatePlane(options: {
  23382. size?: number;
  23383. width?: number;
  23384. height?: number;
  23385. sideOrientation?: number;
  23386. frontUVs?: Vector4;
  23387. backUVs?: Vector4;
  23388. }): VertexData;
  23389. /**
  23390. * Creates the VertexData of the Disc or regular Polygon
  23391. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23392. * * radius the radius of the disc, optional default 0.5
  23393. * * tessellation the number of polygon sides, optional, default 64
  23394. * * 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
  23395. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23396. * * 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)
  23397. * * 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)
  23398. * @returns the VertexData of the box
  23399. */
  23400. static CreateDisc(options: {
  23401. radius?: number;
  23402. tessellation?: number;
  23403. arc?: number;
  23404. sideOrientation?: number;
  23405. frontUVs?: Vector4;
  23406. backUVs?: Vector4;
  23407. }): VertexData;
  23408. /**
  23409. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23410. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23411. * @param polygon a mesh built from polygonTriangulation.build()
  23412. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23413. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23414. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23415. * @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)
  23416. * @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)
  23417. * @returns the VertexData of the Polygon
  23418. */
  23419. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23420. /**
  23421. * Creates the VertexData of the IcoSphere
  23422. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23423. * * radius the radius of the IcoSphere, optional default 1
  23424. * * radiusX allows stretching in the x direction, optional, default radius
  23425. * * radiusY allows stretching in the y direction, optional, default radius
  23426. * * radiusZ allows stretching in the z direction, optional, default radius
  23427. * * flat when true creates a flat shaded mesh, optional, default true
  23428. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23430. * * 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)
  23431. * * 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)
  23432. * @returns the VertexData of the IcoSphere
  23433. */
  23434. static CreateIcoSphere(options: {
  23435. radius?: number;
  23436. radiusX?: number;
  23437. radiusY?: number;
  23438. radiusZ?: number;
  23439. flat?: boolean;
  23440. subdivisions?: number;
  23441. sideOrientation?: number;
  23442. frontUVs?: Vector4;
  23443. backUVs?: Vector4;
  23444. }): VertexData;
  23445. /**
  23446. * Creates the VertexData for a Polyhedron
  23447. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23448. * * type provided types are:
  23449. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23450. * * 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)
  23451. * * size the size of the IcoSphere, optional default 1
  23452. * * sizeX allows stretching in the x direction, optional, default size
  23453. * * sizeY allows stretching in the y direction, optional, default size
  23454. * * sizeZ allows stretching in the z direction, optional, default size
  23455. * * 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
  23456. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23457. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23458. * * flat when true creates a flat shaded mesh, optional, default true
  23459. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23460. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23461. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23462. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23463. * @returns the VertexData of the Polyhedron
  23464. */
  23465. static CreatePolyhedron(options: {
  23466. type?: number;
  23467. size?: number;
  23468. sizeX?: number;
  23469. sizeY?: number;
  23470. sizeZ?: number;
  23471. custom?: any;
  23472. faceUV?: Vector4[];
  23473. faceColors?: Color4[];
  23474. flat?: boolean;
  23475. sideOrientation?: number;
  23476. frontUVs?: Vector4;
  23477. backUVs?: Vector4;
  23478. }): VertexData;
  23479. /**
  23480. * Creates the VertexData for a TorusKnot
  23481. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23482. * * radius the radius of the torus knot, optional, default 2
  23483. * * tube the thickness of the tube, optional, default 0.5
  23484. * * radialSegments the number of sides on each tube segments, optional, default 32
  23485. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23486. * * p the number of windings around the z axis, optional, default 2
  23487. * * q the number of windings around the x axis, optional, default 3
  23488. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23489. * * 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)
  23490. * * 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)
  23491. * @returns the VertexData of the Torus Knot
  23492. */
  23493. static CreateTorusKnot(options: {
  23494. radius?: number;
  23495. tube?: number;
  23496. radialSegments?: number;
  23497. tubularSegments?: number;
  23498. p?: number;
  23499. q?: number;
  23500. sideOrientation?: number;
  23501. frontUVs?: Vector4;
  23502. backUVs?: Vector4;
  23503. }): VertexData;
  23504. /**
  23505. * Compute normals for given positions and indices
  23506. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23507. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23508. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23509. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23510. * * facetNormals : optional array of facet normals (vector3)
  23511. * * facetPositions : optional array of facet positions (vector3)
  23512. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23513. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23514. * * bInfo : optional bounding info, required for facetPartitioning computation
  23515. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23516. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23517. * * useRightHandedSystem: optional boolean to for right handed system computation
  23518. * * depthSort : optional boolean to enable the facet depth sort computation
  23519. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23520. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23521. */
  23522. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23523. facetNormals?: any;
  23524. facetPositions?: any;
  23525. facetPartitioning?: any;
  23526. ratio?: number;
  23527. bInfo?: any;
  23528. bbSize?: Vector3;
  23529. subDiv?: any;
  23530. useRightHandedSystem?: boolean;
  23531. depthSort?: boolean;
  23532. distanceTo?: Vector3;
  23533. depthSortedFacets?: any;
  23534. }): void;
  23535. /** @hidden */
  23536. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23537. /**
  23538. * Applies VertexData created from the imported parameters to the geometry
  23539. * @param parsedVertexData the parsed data from an imported file
  23540. * @param geometry the geometry to apply the VertexData to
  23541. */
  23542. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23543. }
  23544. }
  23545. declare module BABYLON {
  23546. /**
  23547. * Class containing static functions to help procedurally build meshes
  23548. */
  23549. export class DiscBuilder {
  23550. /**
  23551. * Creates a plane polygonal mesh. By default, this is a disc
  23552. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23553. * * 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
  23554. * * 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
  23555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23556. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23558. * @param name defines the name of the mesh
  23559. * @param options defines the options used to create the mesh
  23560. * @param scene defines the hosting scene
  23561. * @returns the plane polygonal mesh
  23562. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23563. */
  23564. static CreateDisc(name: string, options: {
  23565. radius?: number;
  23566. tessellation?: number;
  23567. arc?: number;
  23568. updatable?: boolean;
  23569. sideOrientation?: number;
  23570. frontUVs?: Vector4;
  23571. backUVs?: Vector4;
  23572. }, scene?: Nullable<Scene>): Mesh;
  23573. }
  23574. }
  23575. declare module BABYLON {
  23576. /**
  23577. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23578. *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.
  23579. * The SPS is also a particle system. It provides some methods to manage the particles.
  23580. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23581. *
  23582. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23583. */
  23584. export class SolidParticleSystem implements IDisposable {
  23585. /**
  23586. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23587. * Example : var p = SPS.particles[i];
  23588. */
  23589. particles: SolidParticle[];
  23590. /**
  23591. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23592. */
  23593. nbParticles: number;
  23594. /**
  23595. * If the particles must ever face the camera (default false). Useful for planar particles.
  23596. */
  23597. billboard: boolean;
  23598. /**
  23599. * Recompute normals when adding a shape
  23600. */
  23601. recomputeNormals: boolean;
  23602. /**
  23603. * This a counter ofr your own usage. It's not set by any SPS functions.
  23604. */
  23605. counter: number;
  23606. /**
  23607. * The SPS name. This name is also given to the underlying mesh.
  23608. */
  23609. name: string;
  23610. /**
  23611. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23612. */
  23613. mesh: Mesh;
  23614. /**
  23615. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23616. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23617. */
  23618. vars: any;
  23619. /**
  23620. * This array is populated when the SPS is set as 'pickable'.
  23621. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23622. * Each element of this array is an object `{idx: int, faceId: int}`.
  23623. * `idx` is the picked particle index in the `SPS.particles` array
  23624. * `faceId` is the picked face index counted within this particle.
  23625. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23626. */
  23627. pickedParticles: {
  23628. idx: number;
  23629. faceId: number;
  23630. }[];
  23631. /**
  23632. * This array is populated when `enableDepthSort` is set to true.
  23633. * Each element of this array is an instance of the class DepthSortedParticle.
  23634. */
  23635. depthSortedParticles: DepthSortedParticle[];
  23636. /**
  23637. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23638. * @hidden
  23639. */
  23640. _bSphereOnly: boolean;
  23641. /**
  23642. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23643. * @hidden
  23644. */
  23645. _bSphereRadiusFactor: number;
  23646. private _scene;
  23647. private _positions;
  23648. private _indices;
  23649. private _normals;
  23650. private _colors;
  23651. private _uvs;
  23652. private _indices32;
  23653. private _positions32;
  23654. private _normals32;
  23655. private _fixedNormal32;
  23656. private _colors32;
  23657. private _uvs32;
  23658. private _index;
  23659. private _updatable;
  23660. private _pickable;
  23661. private _isVisibilityBoxLocked;
  23662. private _alwaysVisible;
  23663. private _depthSort;
  23664. private _shapeCounter;
  23665. private _copy;
  23666. private _color;
  23667. private _computeParticleColor;
  23668. private _computeParticleTexture;
  23669. private _computeParticleRotation;
  23670. private _computeParticleVertex;
  23671. private _computeBoundingBox;
  23672. private _depthSortParticles;
  23673. private _camera;
  23674. private _mustUnrotateFixedNormals;
  23675. private _particlesIntersect;
  23676. private _needs32Bits;
  23677. /**
  23678. * Creates a SPS (Solid Particle System) object.
  23679. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23680. * @param scene (Scene) is the scene in which the SPS is added.
  23681. * @param options defines the options of the sps e.g.
  23682. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23683. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23684. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23685. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23686. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23687. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23688. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23689. */
  23690. constructor(name: string, scene: Scene, options?: {
  23691. updatable?: boolean;
  23692. isPickable?: boolean;
  23693. enableDepthSort?: boolean;
  23694. particleIntersection?: boolean;
  23695. boundingSphereOnly?: boolean;
  23696. bSphereRadiusFactor?: number;
  23697. });
  23698. /**
  23699. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23700. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23701. * @returns the created mesh
  23702. */
  23703. buildMesh(): Mesh;
  23704. /**
  23705. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23706. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23707. * Thus the particles generated from `digest()` have their property `position` set yet.
  23708. * @param mesh ( Mesh ) is the mesh to be digested
  23709. * @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
  23710. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23711. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23712. * @returns the current SPS
  23713. */
  23714. digest(mesh: Mesh, options?: {
  23715. facetNb?: number;
  23716. number?: number;
  23717. delta?: number;
  23718. }): SolidParticleSystem;
  23719. private _unrotateFixedNormals;
  23720. private _resetCopy;
  23721. private _meshBuilder;
  23722. private _posToShape;
  23723. private _uvsToShapeUV;
  23724. private _addParticle;
  23725. /**
  23726. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23727. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23728. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23729. * @param nb (positive integer) the number of particles to be created from this model
  23730. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23731. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23732. * @returns the number of shapes in the system
  23733. */
  23734. addShape(mesh: Mesh, nb: number, options?: {
  23735. positionFunction?: any;
  23736. vertexFunction?: any;
  23737. }): number;
  23738. private _rebuildParticle;
  23739. /**
  23740. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23741. * @returns the SPS.
  23742. */
  23743. rebuildMesh(): SolidParticleSystem;
  23744. /**
  23745. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23746. * This method calls `updateParticle()` for each particle of the SPS.
  23747. * For an animated SPS, it is usually called within the render loop.
  23748. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23749. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23750. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23751. * @returns the SPS.
  23752. */
  23753. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23754. /**
  23755. * Disposes the SPS.
  23756. */
  23757. dispose(): void;
  23758. /**
  23759. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23760. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23761. * @returns the SPS.
  23762. */
  23763. refreshVisibleSize(): SolidParticleSystem;
  23764. /**
  23765. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23766. * @param size the size (float) of the visibility box
  23767. * note : this doesn't lock the SPS mesh bounding box.
  23768. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23769. */
  23770. setVisibilityBox(size: number): void;
  23771. /**
  23772. * Gets whether the SPS as always visible or not
  23773. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23774. */
  23775. /**
  23776. * Sets the SPS as always visible or not
  23777. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23778. */
  23779. isAlwaysVisible: boolean;
  23780. /**
  23781. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23782. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23783. */
  23784. /**
  23785. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23786. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23787. */
  23788. isVisibilityBoxLocked: boolean;
  23789. /**
  23790. * Tells to `setParticles()` to compute the particle rotations or not.
  23791. * Default value : true. The SPS is faster when it's set to false.
  23792. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23793. */
  23794. /**
  23795. * Gets if `setParticles()` computes the particle rotations or not.
  23796. * Default value : true. The SPS is faster when it's set to false.
  23797. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23798. */
  23799. computeParticleRotation: boolean;
  23800. /**
  23801. * Tells to `setParticles()` to compute the particle colors or not.
  23802. * Default value : true. The SPS is faster when it's set to false.
  23803. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23804. */
  23805. /**
  23806. * Gets if `setParticles()` computes the particle colors or not.
  23807. * Default value : true. The SPS is faster when it's set to false.
  23808. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23809. */
  23810. computeParticleColor: boolean;
  23811. /**
  23812. * Gets if `setParticles()` computes the particle textures or not.
  23813. * Default value : true. The SPS is faster when it's set to false.
  23814. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23815. */
  23816. computeParticleTexture: boolean;
  23817. /**
  23818. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23819. * Default value : false. The SPS is faster when it's set to false.
  23820. * Note : the particle custom vertex positions aren't stored values.
  23821. */
  23822. /**
  23823. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23824. * Default value : false. The SPS is faster when it's set to false.
  23825. * Note : the particle custom vertex positions aren't stored values.
  23826. */
  23827. computeParticleVertex: boolean;
  23828. /**
  23829. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23830. */
  23831. /**
  23832. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23833. */
  23834. computeBoundingBox: boolean;
  23835. /**
  23836. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23837. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23838. * Default : `true`
  23839. */
  23840. /**
  23841. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23842. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23843. * Default : `true`
  23844. */
  23845. depthSortParticles: boolean;
  23846. /**
  23847. * This function does nothing. It may be overwritten to set all the particle first values.
  23848. * The SPS doesn't call this function, you may have to call it by your own.
  23849. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23850. */
  23851. initParticles(): void;
  23852. /**
  23853. * This function does nothing. It may be overwritten to recycle a particle.
  23854. * The SPS doesn't call this function, you may have to call it by your own.
  23855. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23856. * @param particle The particle to recycle
  23857. * @returns the recycled particle
  23858. */
  23859. recycleParticle(particle: SolidParticle): SolidParticle;
  23860. /**
  23861. * Updates a particle : this function should be overwritten by the user.
  23862. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23863. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23864. * @example : just set a particle position or velocity and recycle conditions
  23865. * @param particle The particle to update
  23866. * @returns the updated particle
  23867. */
  23868. updateParticle(particle: SolidParticle): SolidParticle;
  23869. /**
  23870. * Updates a vertex of a particle : it can be overwritten by the user.
  23871. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23872. * @param particle the current particle
  23873. * @param vertex the current index of the current particle
  23874. * @param pt the index of the current vertex in the particle shape
  23875. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23876. * @example : just set a vertex particle position
  23877. * @returns the updated vertex
  23878. */
  23879. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23880. /**
  23881. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23882. * This does nothing and may be overwritten by the user.
  23883. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23884. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23885. * @param update the boolean update value actually passed to setParticles()
  23886. */
  23887. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23888. /**
  23889. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23890. * This will be passed three parameters.
  23891. * This does nothing and may be overwritten by the user.
  23892. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23893. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23894. * @param update the boolean update value actually passed to setParticles()
  23895. */
  23896. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23897. }
  23898. }
  23899. declare module BABYLON {
  23900. /**
  23901. * Represents one particle of a solid particle system.
  23902. */
  23903. export class SolidParticle {
  23904. /**
  23905. * particle global index
  23906. */
  23907. idx: number;
  23908. /**
  23909. * The color of the particle
  23910. */
  23911. color: Nullable<Color4>;
  23912. /**
  23913. * The world space position of the particle.
  23914. */
  23915. position: Vector3;
  23916. /**
  23917. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23918. */
  23919. rotation: Vector3;
  23920. /**
  23921. * The world space rotation quaternion of the particle.
  23922. */
  23923. rotationQuaternion: Nullable<Quaternion>;
  23924. /**
  23925. * The scaling of the particle.
  23926. */
  23927. scaling: Vector3;
  23928. /**
  23929. * The uvs of the particle.
  23930. */
  23931. uvs: Vector4;
  23932. /**
  23933. * The current speed of the particle.
  23934. */
  23935. velocity: Vector3;
  23936. /**
  23937. * The pivot point in the particle local space.
  23938. */
  23939. pivot: Vector3;
  23940. /**
  23941. * Must the particle be translated from its pivot point in its local space ?
  23942. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23943. * Default : false
  23944. */
  23945. translateFromPivot: boolean;
  23946. /**
  23947. * Is the particle active or not ?
  23948. */
  23949. alive: boolean;
  23950. /**
  23951. * Is the particle visible or not ?
  23952. */
  23953. isVisible: boolean;
  23954. /**
  23955. * Index of this particle in the global "positions" array (Internal use)
  23956. * @hidden
  23957. */
  23958. _pos: number;
  23959. /**
  23960. * @hidden Index of this particle in the global "indices" array (Internal use)
  23961. */
  23962. _ind: number;
  23963. /**
  23964. * @hidden ModelShape of this particle (Internal use)
  23965. */
  23966. _model: ModelShape;
  23967. /**
  23968. * ModelShape id of this particle
  23969. */
  23970. shapeId: number;
  23971. /**
  23972. * Index of the particle in its shape id (Internal use)
  23973. */
  23974. idxInShape: number;
  23975. /**
  23976. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23977. */
  23978. _modelBoundingInfo: BoundingInfo;
  23979. /**
  23980. * @hidden Particle BoundingInfo object (Internal use)
  23981. */
  23982. _boundingInfo: BoundingInfo;
  23983. /**
  23984. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23985. */
  23986. _sps: SolidParticleSystem;
  23987. /**
  23988. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23989. */
  23990. _stillInvisible: boolean;
  23991. /**
  23992. * @hidden Last computed particle rotation matrix
  23993. */
  23994. _rotationMatrix: number[];
  23995. /**
  23996. * Parent particle Id, if any.
  23997. * Default null.
  23998. */
  23999. parentId: Nullable<number>;
  24000. /**
  24001. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24002. * The possible values are :
  24003. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24004. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24005. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24006. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24007. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24008. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24009. * */
  24010. cullingStrategy: number;
  24011. /**
  24012. * @hidden Internal global position in the SPS.
  24013. */
  24014. _globalPosition: Vector3;
  24015. /**
  24016. * Creates a Solid Particle object.
  24017. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24018. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24019. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24020. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24021. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24022. * @param shapeId (integer) is the model shape identifier in the SPS.
  24023. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24024. * @param sps defines the sps it is associated to
  24025. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24026. */
  24027. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24028. /**
  24029. * Legacy support, changed scale to scaling
  24030. */
  24031. /**
  24032. * Legacy support, changed scale to scaling
  24033. */
  24034. scale: Vector3;
  24035. /**
  24036. * Legacy support, changed quaternion to rotationQuaternion
  24037. */
  24038. /**
  24039. * Legacy support, changed quaternion to rotationQuaternion
  24040. */
  24041. quaternion: Nullable<Quaternion>;
  24042. /**
  24043. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24044. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24045. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24046. * @returns true if it intersects
  24047. */
  24048. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24049. /**
  24050. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24051. * A particle is in the frustum if its bounding box intersects the frustum
  24052. * @param frustumPlanes defines the frustum to test
  24053. * @returns true if the particle is in the frustum planes
  24054. */
  24055. isInFrustum(frustumPlanes: Plane[]): boolean;
  24056. /**
  24057. * get the rotation matrix of the particle
  24058. * @hidden
  24059. */
  24060. getRotationMatrix(m: Matrix): void;
  24061. }
  24062. /**
  24063. * Represents the shape of the model used by one particle of a solid particle system.
  24064. * SPS internal tool, don't use it manually.
  24065. */
  24066. export class ModelShape {
  24067. /**
  24068. * The shape id
  24069. * @hidden
  24070. */
  24071. shapeID: number;
  24072. /**
  24073. * flat array of model positions (internal use)
  24074. * @hidden
  24075. */
  24076. _shape: Vector3[];
  24077. /**
  24078. * flat array of model UVs (internal use)
  24079. * @hidden
  24080. */
  24081. _shapeUV: number[];
  24082. /**
  24083. * length of the shape in the model indices array (internal use)
  24084. * @hidden
  24085. */
  24086. _indicesLength: number;
  24087. /**
  24088. * Custom position function (internal use)
  24089. * @hidden
  24090. */
  24091. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24092. /**
  24093. * Custom vertex function (internal use)
  24094. * @hidden
  24095. */
  24096. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24097. /**
  24098. * 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.
  24099. * SPS internal tool, don't use it manually.
  24100. * @hidden
  24101. */
  24102. 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>);
  24103. }
  24104. /**
  24105. * Represents a Depth Sorted Particle in the solid particle system.
  24106. */
  24107. export class DepthSortedParticle {
  24108. /**
  24109. * Index of the particle in the "indices" array
  24110. */
  24111. ind: number;
  24112. /**
  24113. * Length of the particle shape in the "indices" array
  24114. */
  24115. indicesLength: number;
  24116. /**
  24117. * Squared distance from the particle to the camera
  24118. */
  24119. sqDistance: number;
  24120. }
  24121. }
  24122. declare module BABYLON {
  24123. /**
  24124. * Class used to store all common mesh properties
  24125. */
  24126. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24127. /** No occlusion */
  24128. static OCCLUSION_TYPE_NONE: number;
  24129. /** Occlusion set to optimisitic */
  24130. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24131. /** Occlusion set to strict */
  24132. static OCCLUSION_TYPE_STRICT: number;
  24133. /** Use an accurante occlusion algorithm */
  24134. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24135. /** Use a conservative occlusion algorithm */
  24136. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24137. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24138. * Test order :
  24139. * Is the bounding sphere outside the frustum ?
  24140. * If not, are the bounding box vertices outside the frustum ?
  24141. * It not, then the cullable object is in the frustum.
  24142. */
  24143. static readonly CULLINGSTRATEGY_STANDARD: number;
  24144. /** Culling strategy : Bounding Sphere Only.
  24145. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24146. * It's also less accurate than the standard because some not visible objects can still be selected.
  24147. * Test : is the bounding sphere outside the frustum ?
  24148. * If not, then the cullable object is in the frustum.
  24149. */
  24150. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24151. /** Culling strategy : Optimistic Inclusion.
  24152. * This in an inclusion test first, then the standard exclusion test.
  24153. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24154. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  24155. * Anyway, it's as accurate as the standard strategy.
  24156. * Test :
  24157. * Is the cullable object bounding sphere center in the frustum ?
  24158. * If not, apply the default culling strategy.
  24159. */
  24160. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24161. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24162. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24163. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24164. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  24165. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24166. * Test :
  24167. * Is the cullable object bounding sphere center in the frustum ?
  24168. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24169. */
  24170. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24171. /**
  24172. * No billboard
  24173. */
  24174. static readonly BILLBOARDMODE_NONE: number;
  24175. /** Billboard on X axis */
  24176. static readonly BILLBOARDMODE_X: number;
  24177. /** Billboard on Y axis */
  24178. static readonly BILLBOARDMODE_Y: number;
  24179. /** Billboard on Z axis */
  24180. static readonly BILLBOARDMODE_Z: number;
  24181. /** Billboard on all axes */
  24182. static readonly BILLBOARDMODE_ALL: number;
  24183. private _facetData;
  24184. /**
  24185. * The culling strategy to use to check whether the mesh must be rendered or not.
  24186. * This value can be changed at any time and will be used on the next render mesh selection.
  24187. * The possible values are :
  24188. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24189. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24190. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24191. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24192. * Please read each static variable documentation to get details about the culling process.
  24193. * */
  24194. cullingStrategy: number;
  24195. /**
  24196. * Gets the number of facets in the mesh
  24197. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24198. */
  24199. readonly facetNb: number;
  24200. /**
  24201. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24202. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24203. */
  24204. partitioningSubdivisions: number;
  24205. /**
  24206. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24207. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24208. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24209. */
  24210. partitioningBBoxRatio: number;
  24211. /**
  24212. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24213. * Works only for updatable meshes.
  24214. * Doesn't work with multi-materials
  24215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24216. */
  24217. mustDepthSortFacets: boolean;
  24218. /**
  24219. * The location (Vector3) where the facet depth sort must be computed from.
  24220. * By default, the active camera position.
  24221. * Used only when facet depth sort is enabled
  24222. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24223. */
  24224. facetDepthSortFrom: Vector3;
  24225. /**
  24226. * gets a boolean indicating if facetData is enabled
  24227. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24228. */
  24229. readonly isFacetDataEnabled: boolean;
  24230. /** @hidden */
  24231. _updateNonUniformScalingState(value: boolean): boolean;
  24232. /**
  24233. * An event triggered when this mesh collides with another one
  24234. */
  24235. onCollideObservable: Observable<AbstractMesh>;
  24236. private _onCollideObserver;
  24237. /** Set a function to call when this mesh collides with another one */
  24238. onCollide: () => void;
  24239. /**
  24240. * An event triggered when the collision's position changes
  24241. */
  24242. onCollisionPositionChangeObservable: Observable<Vector3>;
  24243. private _onCollisionPositionChangeObserver;
  24244. /** Set a function to call when the collision's position changes */
  24245. onCollisionPositionChange: () => void;
  24246. /**
  24247. * An event triggered when material is changed
  24248. */
  24249. onMaterialChangedObservable: Observable<AbstractMesh>;
  24250. /**
  24251. * Gets or sets the orientation for POV movement & rotation
  24252. */
  24253. definedFacingForward: boolean;
  24254. /** @hidden */
  24255. _occlusionQuery: Nullable<WebGLQuery>;
  24256. private _visibility;
  24257. /** @hidden */
  24258. _isActive: boolean;
  24259. /** @hidden */
  24260. _onlyForInstances: boolean;
  24261. /** @hidden */
  24262. _renderingGroup: Nullable<RenderingGroup>;
  24263. /**
  24264. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24265. */
  24266. /**
  24267. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24268. */
  24269. visibility: number;
  24270. /** Gets or sets the alpha index used to sort transparent meshes
  24271. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24272. */
  24273. alphaIndex: number;
  24274. /**
  24275. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24276. */
  24277. isVisible: boolean;
  24278. /**
  24279. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24280. */
  24281. isPickable: boolean;
  24282. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24283. showSubMeshesBoundingBox: boolean;
  24284. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24285. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24286. */
  24287. isBlocker: boolean;
  24288. /**
  24289. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24290. */
  24291. enablePointerMoveEvents: boolean;
  24292. /**
  24293. * Specifies the rendering group id for this mesh (0 by default)
  24294. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24295. */
  24296. renderingGroupId: number;
  24297. private _material;
  24298. /** Gets or sets current material */
  24299. material: Nullable<Material>;
  24300. private _receiveShadows;
  24301. /**
  24302. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24303. * @see http://doc.babylonjs.com/babylon101/shadows
  24304. */
  24305. receiveShadows: boolean;
  24306. /** Defines color to use when rendering outline */
  24307. outlineColor: Color3;
  24308. /** Define width to use when rendering outline */
  24309. outlineWidth: number;
  24310. /** Defines color to use when rendering overlay */
  24311. overlayColor: Color3;
  24312. /** Defines alpha to use when rendering overlay */
  24313. overlayAlpha: number;
  24314. private _hasVertexAlpha;
  24315. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24316. hasVertexAlpha: boolean;
  24317. private _useVertexColors;
  24318. /** 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) */
  24319. useVertexColors: boolean;
  24320. private _computeBonesUsingShaders;
  24321. /**
  24322. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24323. */
  24324. computeBonesUsingShaders: boolean;
  24325. private _numBoneInfluencers;
  24326. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24327. numBoneInfluencers: number;
  24328. private _applyFog;
  24329. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24330. applyFog: boolean;
  24331. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24332. useOctreeForRenderingSelection: boolean;
  24333. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24334. useOctreeForPicking: boolean;
  24335. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24336. useOctreeForCollisions: boolean;
  24337. private _layerMask;
  24338. /**
  24339. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24340. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24341. */
  24342. layerMask: number;
  24343. /**
  24344. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24345. */
  24346. alwaysSelectAsActiveMesh: boolean;
  24347. /**
  24348. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24349. */
  24350. doNotSyncBoundingInfo: boolean;
  24351. /**
  24352. * Gets or sets the current action manager
  24353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24354. */
  24355. actionManager: Nullable<AbstractActionManager>;
  24356. private _checkCollisions;
  24357. private _collisionMask;
  24358. private _collisionGroup;
  24359. /**
  24360. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24361. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24362. */
  24363. ellipsoid: Vector3;
  24364. /**
  24365. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24366. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24367. */
  24368. ellipsoidOffset: Vector3;
  24369. private _collider;
  24370. private _oldPositionForCollisions;
  24371. private _diffPositionForCollisions;
  24372. /**
  24373. * Gets or sets a collision mask used to mask collisions (default is -1).
  24374. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24375. */
  24376. collisionMask: number;
  24377. /**
  24378. * Gets or sets the current collision group mask (-1 by default).
  24379. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24380. */
  24381. collisionGroup: number;
  24382. /**
  24383. * Defines edge width used when edgesRenderer is enabled
  24384. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24385. */
  24386. edgesWidth: number;
  24387. /**
  24388. * Defines edge color used when edgesRenderer is enabled
  24389. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24390. */
  24391. edgesColor: Color4;
  24392. /** @hidden */
  24393. _edgesRenderer: Nullable<IEdgesRenderer>;
  24394. /** @hidden */
  24395. _masterMesh: Nullable<AbstractMesh>;
  24396. /** @hidden */
  24397. _boundingInfo: Nullable<BoundingInfo>;
  24398. /** @hidden */
  24399. _renderId: number;
  24400. /**
  24401. * Gets or sets the list of subMeshes
  24402. * @see http://doc.babylonjs.com/how_to/multi_materials
  24403. */
  24404. subMeshes: SubMesh[];
  24405. /** @hidden */
  24406. _intersectionsInProgress: AbstractMesh[];
  24407. /** @hidden */
  24408. _unIndexed: boolean;
  24409. /** @hidden */
  24410. _lightSources: Light[];
  24411. /** @hidden */
  24412. readonly _positions: Nullable<Vector3[]>;
  24413. /** @hidden */
  24414. _waitingActions: Nullable<any>;
  24415. /** @hidden */
  24416. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24417. private _skeleton;
  24418. /** @hidden */
  24419. _bonesTransformMatrices: Nullable<Float32Array>;
  24420. /**
  24421. * Gets or sets a skeleton to apply skining transformations
  24422. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24423. */
  24424. skeleton: Nullable<Skeleton>;
  24425. /**
  24426. * An event triggered when the mesh is rebuilt.
  24427. */
  24428. onRebuildObservable: Observable<AbstractMesh>;
  24429. /**
  24430. * Creates a new AbstractMesh
  24431. * @param name defines the name of the mesh
  24432. * @param scene defines the hosting scene
  24433. */
  24434. constructor(name: string, scene?: Nullable<Scene>);
  24435. /**
  24436. * Returns the string "AbstractMesh"
  24437. * @returns "AbstractMesh"
  24438. */
  24439. getClassName(): string;
  24440. /**
  24441. * Gets a string representation of the current mesh
  24442. * @param fullDetails defines a boolean indicating if full details must be included
  24443. * @returns a string representation of the current mesh
  24444. */
  24445. toString(fullDetails?: boolean): string;
  24446. /**
  24447. * @hidden
  24448. */
  24449. protected _getEffectiveParent(): Nullable<Node>;
  24450. /** @hidden */
  24451. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24452. /** @hidden */
  24453. _rebuild(): void;
  24454. /** @hidden */
  24455. _resyncLightSources(): void;
  24456. /** @hidden */
  24457. _resyncLighSource(light: Light): void;
  24458. /** @hidden */
  24459. _unBindEffect(): void;
  24460. /** @hidden */
  24461. _removeLightSource(light: Light): void;
  24462. private _markSubMeshesAsDirty;
  24463. /** @hidden */
  24464. _markSubMeshesAsLightDirty(): void;
  24465. /** @hidden */
  24466. _markSubMeshesAsAttributesDirty(): void;
  24467. /** @hidden */
  24468. _markSubMeshesAsMiscDirty(): void;
  24469. /**
  24470. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24471. */
  24472. scaling: Vector3;
  24473. /**
  24474. * Returns true if the mesh is blocked. Implemented by child classes
  24475. */
  24476. readonly isBlocked: boolean;
  24477. /**
  24478. * Returns the mesh itself by default. Implemented by child classes
  24479. * @param camera defines the camera to use to pick the right LOD level
  24480. * @returns the currentAbstractMesh
  24481. */
  24482. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24483. /**
  24484. * Returns 0 by default. Implemented by child classes
  24485. * @returns an integer
  24486. */
  24487. getTotalVertices(): number;
  24488. /**
  24489. * Returns a positive integer : the total number of indices in this mesh geometry.
  24490. * @returns the numner of indices or zero if the mesh has no geometry.
  24491. */
  24492. getTotalIndices(): number;
  24493. /**
  24494. * Returns null by default. Implemented by child classes
  24495. * @returns null
  24496. */
  24497. getIndices(): Nullable<IndicesArray>;
  24498. /**
  24499. * Returns the array of the requested vertex data kind. Implemented by child classes
  24500. * @param kind defines the vertex data kind to use
  24501. * @returns null
  24502. */
  24503. getVerticesData(kind: string): Nullable<FloatArray>;
  24504. /**
  24505. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24506. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24507. * Note that a new underlying VertexBuffer object is created each call.
  24508. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24509. * @param kind defines vertex data kind:
  24510. * * VertexBuffer.PositionKind
  24511. * * VertexBuffer.UVKind
  24512. * * VertexBuffer.UV2Kind
  24513. * * VertexBuffer.UV3Kind
  24514. * * VertexBuffer.UV4Kind
  24515. * * VertexBuffer.UV5Kind
  24516. * * VertexBuffer.UV6Kind
  24517. * * VertexBuffer.ColorKind
  24518. * * VertexBuffer.MatricesIndicesKind
  24519. * * VertexBuffer.MatricesIndicesExtraKind
  24520. * * VertexBuffer.MatricesWeightsKind
  24521. * * VertexBuffer.MatricesWeightsExtraKind
  24522. * @param data defines the data source
  24523. * @param updatable defines if the data must be flagged as updatable (or static)
  24524. * @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
  24525. * @returns the current mesh
  24526. */
  24527. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24528. /**
  24529. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24530. * If the mesh has no geometry, it is simply returned as it is.
  24531. * @param kind defines vertex data kind:
  24532. * * VertexBuffer.PositionKind
  24533. * * VertexBuffer.UVKind
  24534. * * VertexBuffer.UV2Kind
  24535. * * VertexBuffer.UV3Kind
  24536. * * VertexBuffer.UV4Kind
  24537. * * VertexBuffer.UV5Kind
  24538. * * VertexBuffer.UV6Kind
  24539. * * VertexBuffer.ColorKind
  24540. * * VertexBuffer.MatricesIndicesKind
  24541. * * VertexBuffer.MatricesIndicesExtraKind
  24542. * * VertexBuffer.MatricesWeightsKind
  24543. * * VertexBuffer.MatricesWeightsExtraKind
  24544. * @param data defines the data source
  24545. * @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
  24546. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24547. * @returns the current mesh
  24548. */
  24549. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24550. /**
  24551. * Sets the mesh indices,
  24552. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24553. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24554. * @param totalVertices Defines the total number of vertices
  24555. * @returns the current mesh
  24556. */
  24557. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24558. /**
  24559. * Gets a boolean indicating if specific vertex data is present
  24560. * @param kind defines the vertex data kind to use
  24561. * @returns true is data kind is present
  24562. */
  24563. isVerticesDataPresent(kind: string): boolean;
  24564. /**
  24565. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24566. * @returns a BoundingInfo
  24567. */
  24568. getBoundingInfo(): BoundingInfo;
  24569. /**
  24570. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24571. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24572. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24573. * @returns the current mesh
  24574. */
  24575. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24576. /**
  24577. * Overwrite the current bounding info
  24578. * @param boundingInfo defines the new bounding info
  24579. * @returns the current mesh
  24580. */
  24581. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24582. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24583. readonly useBones: boolean;
  24584. /** @hidden */
  24585. _preActivate(): void;
  24586. /** @hidden */
  24587. _preActivateForIntermediateRendering(renderId: number): void;
  24588. /** @hidden */
  24589. _activate(renderId: number): boolean;
  24590. /** @hidden */
  24591. _freeze(): void;
  24592. /** @hidden */
  24593. _unFreeze(): void;
  24594. /**
  24595. * Gets the current world matrix
  24596. * @returns a Matrix
  24597. */
  24598. getWorldMatrix(): Matrix;
  24599. /** @hidden */
  24600. _getWorldMatrixDeterminant(): number;
  24601. /**
  24602. * Perform relative position change from the point of view of behind the front of the mesh.
  24603. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24604. * Supports definition of mesh facing forward or backward
  24605. * @param amountRight defines the distance on the right axis
  24606. * @param amountUp defines the distance on the up axis
  24607. * @param amountForward defines the distance on the forward axis
  24608. * @returns the current mesh
  24609. */
  24610. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24611. /**
  24612. * Calculate relative position change from the point of view of behind the front of the mesh.
  24613. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24614. * Supports definition of mesh facing forward or backward
  24615. * @param amountRight defines the distance on the right axis
  24616. * @param amountUp defines the distance on the up axis
  24617. * @param amountForward defines the distance on the forward axis
  24618. * @returns the new displacement vector
  24619. */
  24620. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24621. /**
  24622. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24623. * Supports definition of mesh facing forward or backward
  24624. * @param flipBack defines the flip
  24625. * @param twirlClockwise defines the twirl
  24626. * @param tiltRight defines the tilt
  24627. * @returns the current mesh
  24628. */
  24629. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24630. /**
  24631. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24632. * Supports definition of mesh facing forward or backward.
  24633. * @param flipBack defines the flip
  24634. * @param twirlClockwise defines the twirl
  24635. * @param tiltRight defines the tilt
  24636. * @returns the new rotation vector
  24637. */
  24638. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24639. /**
  24640. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24641. * This means the mesh underlying bounding box and sphere are recomputed.
  24642. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24643. * @returns the current mesh
  24644. */
  24645. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24646. /** @hidden */
  24647. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24648. /** @hidden */
  24649. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24650. /** @hidden */
  24651. _updateBoundingInfo(): AbstractMesh;
  24652. /** @hidden */
  24653. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24654. /** @hidden */
  24655. protected _afterComputeWorldMatrix(): void;
  24656. /** @hidden */
  24657. readonly _effectiveMesh: AbstractMesh;
  24658. /**
  24659. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24660. * A mesh is in the frustum if its bounding box intersects the frustum
  24661. * @param frustumPlanes defines the frustum to test
  24662. * @returns true if the mesh is in the frustum planes
  24663. */
  24664. isInFrustum(frustumPlanes: Plane[]): boolean;
  24665. /**
  24666. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24667. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24668. * @param frustumPlanes defines the frustum to test
  24669. * @returns true if the mesh is completely in the frustum planes
  24670. */
  24671. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24672. /**
  24673. * True if the mesh intersects another mesh or a SolidParticle object
  24674. * @param mesh defines a target mesh or SolidParticle to test
  24675. * @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)
  24676. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24677. * @returns true if there is an intersection
  24678. */
  24679. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24680. /**
  24681. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24682. * @param point defines the point to test
  24683. * @returns true if there is an intersection
  24684. */
  24685. intersectsPoint(point: Vector3): boolean;
  24686. /**
  24687. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24688. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24689. */
  24690. checkCollisions: boolean;
  24691. /**
  24692. * Gets Collider object used to compute collisions (not physics)
  24693. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24694. */
  24695. readonly collider: Nullable<Collider>;
  24696. /**
  24697. * Move the mesh using collision engine
  24698. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24699. * @param displacement defines the requested displacement vector
  24700. * @returns the current mesh
  24701. */
  24702. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24703. private _onCollisionPositionChange;
  24704. /** @hidden */
  24705. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24706. /** @hidden */
  24707. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24708. /** @hidden */
  24709. _checkCollision(collider: Collider): AbstractMesh;
  24710. /** @hidden */
  24711. _generatePointsArray(): boolean;
  24712. /**
  24713. * Checks if the passed Ray intersects with the mesh
  24714. * @param ray defines the ray to use
  24715. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24716. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24717. * @returns the picking info
  24718. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24719. */
  24720. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24721. /**
  24722. * Clones the current mesh
  24723. * @param name defines the mesh name
  24724. * @param newParent defines the new mesh parent
  24725. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24726. * @returns the new mesh
  24727. */
  24728. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24729. /**
  24730. * Disposes all the submeshes of the current meshnp
  24731. * @returns the current mesh
  24732. */
  24733. releaseSubMeshes(): AbstractMesh;
  24734. /**
  24735. * Releases resources associated with this abstract mesh.
  24736. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24737. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24738. */
  24739. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24740. /**
  24741. * Adds the passed mesh as a child to the current mesh
  24742. * @param mesh defines the child mesh
  24743. * @returns the current mesh
  24744. */
  24745. addChild(mesh: AbstractMesh): AbstractMesh;
  24746. /**
  24747. * Removes the passed mesh from the current mesh children list
  24748. * @param mesh defines the child mesh
  24749. * @returns the current mesh
  24750. */
  24751. removeChild(mesh: AbstractMesh): AbstractMesh;
  24752. /** @hidden */
  24753. private _initFacetData;
  24754. /**
  24755. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24756. * This method can be called within the render loop.
  24757. * 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
  24758. * @returns the current mesh
  24759. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24760. */
  24761. updateFacetData(): AbstractMesh;
  24762. /**
  24763. * Returns the facetLocalNormals array.
  24764. * The normals are expressed in the mesh local spac
  24765. * @returns an array of Vector3
  24766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24767. */
  24768. getFacetLocalNormals(): Vector3[];
  24769. /**
  24770. * Returns the facetLocalPositions array.
  24771. * The facet positions are expressed in the mesh local space
  24772. * @returns an array of Vector3
  24773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24774. */
  24775. getFacetLocalPositions(): Vector3[];
  24776. /**
  24777. * Returns the facetLocalPartioning array
  24778. * @returns an array of array of numbers
  24779. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24780. */
  24781. getFacetLocalPartitioning(): number[][];
  24782. /**
  24783. * Returns the i-th facet position in the world system.
  24784. * This method allocates a new Vector3 per call
  24785. * @param i defines the facet index
  24786. * @returns a new Vector3
  24787. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24788. */
  24789. getFacetPosition(i: number): Vector3;
  24790. /**
  24791. * Sets the reference Vector3 with the i-th facet position in the world system
  24792. * @param i defines the facet index
  24793. * @param ref defines the target vector
  24794. * @returns the current mesh
  24795. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24796. */
  24797. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24798. /**
  24799. * Returns the i-th facet normal in the world system.
  24800. * This method allocates a new Vector3 per call
  24801. * @param i defines the facet index
  24802. * @returns a new Vector3
  24803. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24804. */
  24805. getFacetNormal(i: number): Vector3;
  24806. /**
  24807. * Sets the reference Vector3 with the i-th facet normal in the world system
  24808. * @param i defines the facet index
  24809. * @param ref defines the target vector
  24810. * @returns the current mesh
  24811. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24812. */
  24813. getFacetNormalToRef(i: number, ref: Vector3): this;
  24814. /**
  24815. * 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)
  24816. * @param x defines x coordinate
  24817. * @param y defines y coordinate
  24818. * @param z defines z coordinate
  24819. * @returns the array of facet indexes
  24820. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24821. */
  24822. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24823. /**
  24824. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24825. * @param projected sets as the (x,y,z) world projection on the facet
  24826. * @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
  24827. * @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
  24828. * @param x defines x coordinate
  24829. * @param y defines y coordinate
  24830. * @param z defines z coordinate
  24831. * @returns the face index if found (or null instead)
  24832. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24833. */
  24834. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24835. /**
  24836. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24837. * @param projected sets as the (x,y,z) local projection on the facet
  24838. * @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
  24839. * @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
  24840. * @param x defines x coordinate
  24841. * @param y defines y coordinate
  24842. * @param z defines z coordinate
  24843. * @returns the face index if found (or null instead)
  24844. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24845. */
  24846. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24847. /**
  24848. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24849. * @returns the parameters
  24850. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24851. */
  24852. getFacetDataParameters(): any;
  24853. /**
  24854. * Disables the feature FacetData and frees the related memory
  24855. * @returns the current mesh
  24856. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24857. */
  24858. disableFacetData(): AbstractMesh;
  24859. /**
  24860. * Updates the AbstractMesh indices array
  24861. * @param indices defines the data source
  24862. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24863. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24864. * @returns the current mesh
  24865. */
  24866. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24867. /**
  24868. * Creates new normals data for the mesh
  24869. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24870. * @returns the current mesh
  24871. */
  24872. createNormals(updatable: boolean): AbstractMesh;
  24873. /**
  24874. * Align the mesh with a normal
  24875. * @param normal defines the normal to use
  24876. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24877. * @returns the current mesh
  24878. */
  24879. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24880. /** @hidden */
  24881. _checkOcclusionQuery(): boolean;
  24882. }
  24883. }
  24884. declare module BABYLON {
  24885. /**
  24886. * Interface used to define ActionEvent
  24887. */
  24888. export interface IActionEvent {
  24889. /** The mesh or sprite that triggered the action */
  24890. source: any;
  24891. /** The X mouse cursor position at the time of the event */
  24892. pointerX: number;
  24893. /** The Y mouse cursor position at the time of the event */
  24894. pointerY: number;
  24895. /** The mesh that is currently pointed at (can be null) */
  24896. meshUnderPointer: Nullable<AbstractMesh>;
  24897. /** the original (browser) event that triggered the ActionEvent */
  24898. sourceEvent?: any;
  24899. /** additional data for the event */
  24900. additionalData?: any;
  24901. }
  24902. /**
  24903. * ActionEvent is the event being sent when an action is triggered.
  24904. */
  24905. export class ActionEvent implements IActionEvent {
  24906. /** The mesh or sprite that triggered the action */
  24907. source: any;
  24908. /** The X mouse cursor position at the time of the event */
  24909. pointerX: number;
  24910. /** The Y mouse cursor position at the time of the event */
  24911. pointerY: number;
  24912. /** The mesh that is currently pointed at (can be null) */
  24913. meshUnderPointer: Nullable<AbstractMesh>;
  24914. /** the original (browser) event that triggered the ActionEvent */
  24915. sourceEvent?: any;
  24916. /** additional data for the event */
  24917. additionalData?: any;
  24918. /**
  24919. * Creates a new ActionEvent
  24920. * @param source The mesh or sprite that triggered the action
  24921. * @param pointerX The X mouse cursor position at the time of the event
  24922. * @param pointerY The Y mouse cursor position at the time of the event
  24923. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24924. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24925. * @param additionalData additional data for the event
  24926. */
  24927. constructor(
  24928. /** The mesh or sprite that triggered the action */
  24929. source: any,
  24930. /** The X mouse cursor position at the time of the event */
  24931. pointerX: number,
  24932. /** The Y mouse cursor position at the time of the event */
  24933. pointerY: number,
  24934. /** The mesh that is currently pointed at (can be null) */
  24935. meshUnderPointer: Nullable<AbstractMesh>,
  24936. /** the original (browser) event that triggered the ActionEvent */
  24937. sourceEvent?: any,
  24938. /** additional data for the event */
  24939. additionalData?: any);
  24940. /**
  24941. * Helper function to auto-create an ActionEvent from a source mesh.
  24942. * @param source The source mesh that triggered the event
  24943. * @param evt The original (browser) event
  24944. * @param additionalData additional data for the event
  24945. * @returns the new ActionEvent
  24946. */
  24947. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24948. /**
  24949. * Helper function to auto-create an ActionEvent from a source sprite
  24950. * @param source The source sprite that triggered the event
  24951. * @param scene Scene associated with the sprite
  24952. * @param evt The original (browser) event
  24953. * @param additionalData additional data for the event
  24954. * @returns the new ActionEvent
  24955. */
  24956. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24957. /**
  24958. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24959. * @param scene the scene where the event occurred
  24960. * @param evt The original (browser) event
  24961. * @returns the new ActionEvent
  24962. */
  24963. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24964. /**
  24965. * Helper function to auto-create an ActionEvent from a primitive
  24966. * @param prim defines the target primitive
  24967. * @param pointerPos defines the pointer position
  24968. * @param evt The original (browser) event
  24969. * @param additionalData additional data for the event
  24970. * @returns the new ActionEvent
  24971. */
  24972. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24973. }
  24974. }
  24975. declare module BABYLON {
  24976. /**
  24977. * Abstract class used to decouple action Manager from scene and meshes.
  24978. * Do not instantiate.
  24979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24980. */
  24981. export abstract class AbstractActionManager implements IDisposable {
  24982. /** Gets the list of active triggers */
  24983. static Triggers: {
  24984. [key: string]: number;
  24985. };
  24986. /** Gets the cursor to use when hovering items */
  24987. hoverCursor: string;
  24988. /** Gets the list of actions */
  24989. actions: IAction[];
  24990. /**
  24991. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24992. */
  24993. isRecursive: boolean;
  24994. /**
  24995. * Releases all associated resources
  24996. */
  24997. abstract dispose(): void;
  24998. /**
  24999. * Does this action manager has pointer triggers
  25000. */
  25001. abstract readonly hasPointerTriggers: boolean;
  25002. /**
  25003. * Does this action manager has pick triggers
  25004. */
  25005. abstract readonly hasPickTriggers: boolean;
  25006. /**
  25007. * Process a specific trigger
  25008. * @param trigger defines the trigger to process
  25009. * @param evt defines the event details to be processed
  25010. */
  25011. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25012. /**
  25013. * Does this action manager handles actions of any of the given triggers
  25014. * @param triggers defines the triggers to be tested
  25015. * @return a boolean indicating whether one (or more) of the triggers is handled
  25016. */
  25017. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25018. /**
  25019. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25020. * speed.
  25021. * @param triggerA defines the trigger to be tested
  25022. * @param triggerB defines the trigger to be tested
  25023. * @return a boolean indicating whether one (or more) of the triggers is handled
  25024. */
  25025. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25026. /**
  25027. * Does this action manager handles actions of a given trigger
  25028. * @param trigger defines the trigger to be tested
  25029. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25030. * @return whether the trigger is handled
  25031. */
  25032. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25033. /**
  25034. * Serialize this manager to a JSON object
  25035. * @param name defines the property name to store this manager
  25036. * @returns a JSON representation of this manager
  25037. */
  25038. abstract serialize(name: string): any;
  25039. /**
  25040. * Registers an action to this action manager
  25041. * @param action defines the action to be registered
  25042. * @return the action amended (prepared) after registration
  25043. */
  25044. abstract registerAction(action: IAction): Nullable<IAction>;
  25045. /**
  25046. * Unregisters an action to this action manager
  25047. * @param action defines the action to be unregistered
  25048. * @return a boolean indicating whether the action has been unregistered
  25049. */
  25050. abstract unregisterAction(action: IAction): Boolean;
  25051. /**
  25052. * Does exist one action manager with at least one trigger
  25053. **/
  25054. static readonly HasTriggers: boolean;
  25055. /**
  25056. * Does exist one action manager with at least one pick trigger
  25057. **/
  25058. static readonly HasPickTriggers: boolean;
  25059. /**
  25060. * Does exist one action manager that handles actions of a given trigger
  25061. * @param trigger defines the trigger to be tested
  25062. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25063. **/
  25064. static HasSpecificTrigger(trigger: number): boolean;
  25065. }
  25066. }
  25067. declare module BABYLON {
  25068. /**
  25069. * Defines how a node can be built from a string name.
  25070. */
  25071. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25072. /**
  25073. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25074. */
  25075. export class Node implements IBehaviorAware<Node> {
  25076. /** @hidden */
  25077. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25078. private static _NodeConstructors;
  25079. /**
  25080. * Add a new node constructor
  25081. * @param type defines the type name of the node to construct
  25082. * @param constructorFunc defines the constructor function
  25083. */
  25084. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25085. /**
  25086. * Returns a node constructor based on type name
  25087. * @param type defines the type name
  25088. * @param name defines the new node name
  25089. * @param scene defines the hosting scene
  25090. * @param options defines optional options to transmit to constructors
  25091. * @returns the new constructor or null
  25092. */
  25093. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25094. /**
  25095. * Gets or sets the name of the node
  25096. */
  25097. name: string;
  25098. /**
  25099. * Gets or sets the id of the node
  25100. */
  25101. id: string;
  25102. /**
  25103. * Gets or sets the unique id of the node
  25104. */
  25105. uniqueId: number;
  25106. /**
  25107. * Gets or sets a string used to store user defined state for the node
  25108. */
  25109. state: string;
  25110. /**
  25111. * Gets or sets an object used to store user defined information for the node
  25112. */
  25113. metadata: any;
  25114. /**
  25115. * For internal use only. Please do not use.
  25116. */
  25117. reservedDataStore: any;
  25118. /**
  25119. * List of inspectable custom properties (used by the Inspector)
  25120. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25121. */
  25122. inspectableCustomProperties: IInspectable[];
  25123. /**
  25124. * Gets or sets a boolean used to define if the node must be serialized
  25125. */
  25126. doNotSerialize: boolean;
  25127. /** @hidden */
  25128. _isDisposed: boolean;
  25129. /**
  25130. * Gets a list of Animations associated with the node
  25131. */
  25132. animations: Animation[];
  25133. protected _ranges: {
  25134. [name: string]: Nullable<AnimationRange>;
  25135. };
  25136. /**
  25137. * Callback raised when the node is ready to be used
  25138. */
  25139. onReady: Nullable<(node: Node) => void>;
  25140. private _isEnabled;
  25141. private _isParentEnabled;
  25142. private _isReady;
  25143. /** @hidden */
  25144. _currentRenderId: number;
  25145. private _parentUpdateId;
  25146. /** @hidden */
  25147. _childUpdateId: number;
  25148. /** @hidden */
  25149. _waitingParentId: Nullable<string>;
  25150. /** @hidden */
  25151. _scene: Scene;
  25152. /** @hidden */
  25153. _cache: any;
  25154. private _parentNode;
  25155. private _children;
  25156. /** @hidden */
  25157. _worldMatrix: Matrix;
  25158. /** @hidden */
  25159. _worldMatrixDeterminant: number;
  25160. /** @hidden */
  25161. _worldMatrixDeterminantIsDirty: boolean;
  25162. /** @hidden */
  25163. private _sceneRootNodesIndex;
  25164. /**
  25165. * Gets a boolean indicating if the node has been disposed
  25166. * @returns true if the node was disposed
  25167. */
  25168. isDisposed(): boolean;
  25169. /**
  25170. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25171. * @see https://doc.babylonjs.com/how_to/parenting
  25172. */
  25173. parent: Nullable<Node>;
  25174. private addToSceneRootNodes;
  25175. private removeFromSceneRootNodes;
  25176. private _animationPropertiesOverride;
  25177. /**
  25178. * Gets or sets the animation properties override
  25179. */
  25180. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25181. /**
  25182. * Gets a string idenfifying the name of the class
  25183. * @returns "Node" string
  25184. */
  25185. getClassName(): string;
  25186. /** @hidden */
  25187. readonly _isNode: boolean;
  25188. /**
  25189. * An event triggered when the mesh is disposed
  25190. */
  25191. onDisposeObservable: Observable<Node>;
  25192. private _onDisposeObserver;
  25193. /**
  25194. * Sets a callback that will be raised when the node will be disposed
  25195. */
  25196. onDispose: () => void;
  25197. /**
  25198. * Creates a new Node
  25199. * @param name the name and id to be given to this node
  25200. * @param scene the scene this node will be added to
  25201. * @param addToRootNodes the node will be added to scene.rootNodes
  25202. */
  25203. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25204. /**
  25205. * Gets the scene of the node
  25206. * @returns a scene
  25207. */
  25208. getScene(): Scene;
  25209. /**
  25210. * Gets the engine of the node
  25211. * @returns a Engine
  25212. */
  25213. getEngine(): Engine;
  25214. private _behaviors;
  25215. /**
  25216. * Attach a behavior to the node
  25217. * @see http://doc.babylonjs.com/features/behaviour
  25218. * @param behavior defines the behavior to attach
  25219. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25220. * @returns the current Node
  25221. */
  25222. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25223. /**
  25224. * Remove an attached behavior
  25225. * @see http://doc.babylonjs.com/features/behaviour
  25226. * @param behavior defines the behavior to attach
  25227. * @returns the current Node
  25228. */
  25229. removeBehavior(behavior: Behavior<Node>): Node;
  25230. /**
  25231. * Gets the list of attached behaviors
  25232. * @see http://doc.babylonjs.com/features/behaviour
  25233. */
  25234. readonly behaviors: Behavior<Node>[];
  25235. /**
  25236. * Gets an attached behavior by name
  25237. * @param name defines the name of the behavior to look for
  25238. * @see http://doc.babylonjs.com/features/behaviour
  25239. * @returns null if behavior was not found else the requested behavior
  25240. */
  25241. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25242. /**
  25243. * Returns the latest update of the World matrix
  25244. * @returns a Matrix
  25245. */
  25246. getWorldMatrix(): Matrix;
  25247. /** @hidden */
  25248. _getWorldMatrixDeterminant(): number;
  25249. /**
  25250. * Returns directly the latest state of the mesh World matrix.
  25251. * A Matrix is returned.
  25252. */
  25253. readonly worldMatrixFromCache: Matrix;
  25254. /** @hidden */
  25255. _initCache(): void;
  25256. /** @hidden */
  25257. updateCache(force?: boolean): void;
  25258. /** @hidden */
  25259. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25260. /** @hidden */
  25261. _updateCache(ignoreParentClass?: boolean): void;
  25262. /** @hidden */
  25263. _isSynchronized(): boolean;
  25264. /** @hidden */
  25265. _markSyncedWithParent(): void;
  25266. /** @hidden */
  25267. isSynchronizedWithParent(): boolean;
  25268. /** @hidden */
  25269. isSynchronized(): boolean;
  25270. /**
  25271. * Is this node ready to be used/rendered
  25272. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25273. * @return true if the node is ready
  25274. */
  25275. isReady(completeCheck?: boolean): boolean;
  25276. /**
  25277. * Is this node enabled?
  25278. * 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
  25279. * @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
  25280. * @return whether this node (and its parent) is enabled
  25281. */
  25282. isEnabled(checkAncestors?: boolean): boolean;
  25283. /** @hidden */
  25284. protected _syncParentEnabledState(): void;
  25285. /**
  25286. * Set the enabled state of this node
  25287. * @param value defines the new enabled state
  25288. */
  25289. setEnabled(value: boolean): void;
  25290. /**
  25291. * Is this node a descendant of the given node?
  25292. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25293. * @param ancestor defines the parent node to inspect
  25294. * @returns a boolean indicating if this node is a descendant of the given node
  25295. */
  25296. isDescendantOf(ancestor: Node): boolean;
  25297. /** @hidden */
  25298. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25299. /**
  25300. * Will return all nodes that have this node as ascendant
  25301. * @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
  25302. * @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
  25303. * @return all children nodes of all types
  25304. */
  25305. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25306. /**
  25307. * Get all child-meshes of this node
  25308. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  25309. * @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
  25310. * @returns an array of AbstractMesh
  25311. */
  25312. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25313. /**
  25314. * Get all direct children of this node
  25315. * @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
  25316. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  25317. * @returns an array of Node
  25318. */
  25319. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25320. /** @hidden */
  25321. _setReady(state: boolean): void;
  25322. /**
  25323. * Get an animation by name
  25324. * @param name defines the name of the animation to look for
  25325. * @returns null if not found else the requested animation
  25326. */
  25327. getAnimationByName(name: string): Nullable<Animation>;
  25328. /**
  25329. * Creates an animation range for this node
  25330. * @param name defines the name of the range
  25331. * @param from defines the starting key
  25332. * @param to defines the end key
  25333. */
  25334. createAnimationRange(name: string, from: number, to: number): void;
  25335. /**
  25336. * Delete a specific animation range
  25337. * @param name defines the name of the range to delete
  25338. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25339. */
  25340. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25341. /**
  25342. * Get an animation range by name
  25343. * @param name defines the name of the animation range to look for
  25344. * @returns null if not found else the requested animation range
  25345. */
  25346. getAnimationRange(name: string): Nullable<AnimationRange>;
  25347. /**
  25348. * Gets the list of all animation ranges defined on this node
  25349. * @returns an array
  25350. */
  25351. getAnimationRanges(): Nullable<AnimationRange>[];
  25352. /**
  25353. * Will start the animation sequence
  25354. * @param name defines the range frames for animation sequence
  25355. * @param loop defines if the animation should loop (false by default)
  25356. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25357. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25358. * @returns the object created for this animation. If range does not exist, it will return null
  25359. */
  25360. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25361. /**
  25362. * Serialize animation ranges into a JSON compatible object
  25363. * @returns serialization object
  25364. */
  25365. serializeAnimationRanges(): any;
  25366. /**
  25367. * Computes the world matrix of the node
  25368. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25369. * @returns the world matrix
  25370. */
  25371. computeWorldMatrix(force?: boolean): Matrix;
  25372. /**
  25373. * Releases resources associated with this node.
  25374. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25375. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25376. */
  25377. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25378. /**
  25379. * Parse animation range data from a serialization object and store them into a given node
  25380. * @param node defines where to store the animation ranges
  25381. * @param parsedNode defines the serialization object to read data from
  25382. * @param scene defines the hosting scene
  25383. */
  25384. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25385. /**
  25386. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25387. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25388. * @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
  25389. * @returns the new bounding vectors
  25390. */
  25391. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25392. min: Vector3;
  25393. max: Vector3;
  25394. };
  25395. }
  25396. }
  25397. declare module BABYLON {
  25398. /**
  25399. * @hidden
  25400. */
  25401. export class _IAnimationState {
  25402. key: number;
  25403. repeatCount: number;
  25404. workValue?: any;
  25405. loopMode?: number;
  25406. offsetValue?: any;
  25407. highLimitValue?: any;
  25408. }
  25409. /**
  25410. * Class used to store any kind of animation
  25411. */
  25412. export class Animation {
  25413. /**Name of the animation */
  25414. name: string;
  25415. /**Property to animate */
  25416. targetProperty: string;
  25417. /**The frames per second of the animation */
  25418. framePerSecond: number;
  25419. /**The data type of the animation */
  25420. dataType: number;
  25421. /**The loop mode of the animation */
  25422. loopMode?: number | undefined;
  25423. /**Specifies if blending should be enabled */
  25424. enableBlending?: boolean | undefined;
  25425. /**
  25426. * Use matrix interpolation instead of using direct key value when animating matrices
  25427. */
  25428. static AllowMatricesInterpolation: boolean;
  25429. /**
  25430. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25431. */
  25432. static AllowMatrixDecomposeForInterpolation: boolean;
  25433. /**
  25434. * Stores the key frames of the animation
  25435. */
  25436. private _keys;
  25437. /**
  25438. * Stores the easing function of the animation
  25439. */
  25440. private _easingFunction;
  25441. /**
  25442. * @hidden Internal use only
  25443. */
  25444. _runtimeAnimations: RuntimeAnimation[];
  25445. /**
  25446. * The set of event that will be linked to this animation
  25447. */
  25448. private _events;
  25449. /**
  25450. * Stores an array of target property paths
  25451. */
  25452. targetPropertyPath: string[];
  25453. /**
  25454. * Stores the blending speed of the animation
  25455. */
  25456. blendingSpeed: number;
  25457. /**
  25458. * Stores the animation ranges for the animation
  25459. */
  25460. private _ranges;
  25461. /**
  25462. * @hidden Internal use
  25463. */
  25464. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25465. /**
  25466. * Sets up an animation
  25467. * @param property The property to animate
  25468. * @param animationType The animation type to apply
  25469. * @param framePerSecond The frames per second of the animation
  25470. * @param easingFunction The easing function used in the animation
  25471. * @returns The created animation
  25472. */
  25473. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25474. /**
  25475. * Create and start an animation on a node
  25476. * @param name defines the name of the global animation that will be run on all nodes
  25477. * @param node defines the root node where the animation will take place
  25478. * @param targetProperty defines property to animate
  25479. * @param framePerSecond defines the number of frame per second yo use
  25480. * @param totalFrame defines the number of frames in total
  25481. * @param from defines the initial value
  25482. * @param to defines the final value
  25483. * @param loopMode defines which loop mode you want to use (off by default)
  25484. * @param easingFunction defines the easing function to use (linear by default)
  25485. * @param onAnimationEnd defines the callback to call when animation end
  25486. * @returns the animatable created for this animation
  25487. */
  25488. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25489. /**
  25490. * Create and start an animation on a node and its descendants
  25491. * @param name defines the name of the global animation that will be run on all nodes
  25492. * @param node defines the root node where the animation will take place
  25493. * @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
  25494. * @param targetProperty defines property to animate
  25495. * @param framePerSecond defines the number of frame per second to use
  25496. * @param totalFrame defines the number of frames in total
  25497. * @param from defines the initial value
  25498. * @param to defines the final value
  25499. * @param loopMode defines which loop mode you want to use (off by default)
  25500. * @param easingFunction defines the easing function to use (linear by default)
  25501. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25502. * @returns the list of animatables created for all nodes
  25503. * @example https://www.babylonjs-playground.com/#MH0VLI
  25504. */
  25505. 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[]>;
  25506. /**
  25507. * Creates a new animation, merges it with the existing animations and starts it
  25508. * @param name Name of the animation
  25509. * @param node Node which contains the scene that begins the animations
  25510. * @param targetProperty Specifies which property to animate
  25511. * @param framePerSecond The frames per second of the animation
  25512. * @param totalFrame The total number of frames
  25513. * @param from The frame at the beginning of the animation
  25514. * @param to The frame at the end of the animation
  25515. * @param loopMode Specifies the loop mode of the animation
  25516. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25517. * @param onAnimationEnd Callback to run once the animation is complete
  25518. * @returns Nullable animation
  25519. */
  25520. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25521. /**
  25522. * Transition property of an host to the target Value
  25523. * @param property The property to transition
  25524. * @param targetValue The target Value of the property
  25525. * @param host The object where the property to animate belongs
  25526. * @param scene Scene used to run the animation
  25527. * @param frameRate Framerate (in frame/s) to use
  25528. * @param transition The transition type we want to use
  25529. * @param duration The duration of the animation, in milliseconds
  25530. * @param onAnimationEnd Callback trigger at the end of the animation
  25531. * @returns Nullable animation
  25532. */
  25533. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25534. /**
  25535. * Return the array of runtime animations currently using this animation
  25536. */
  25537. readonly runtimeAnimations: RuntimeAnimation[];
  25538. /**
  25539. * Specifies if any of the runtime animations are currently running
  25540. */
  25541. readonly hasRunningRuntimeAnimations: boolean;
  25542. /**
  25543. * Initializes the animation
  25544. * @param name Name of the animation
  25545. * @param targetProperty Property to animate
  25546. * @param framePerSecond The frames per second of the animation
  25547. * @param dataType The data type of the animation
  25548. * @param loopMode The loop mode of the animation
  25549. * @param enableBlending Specifies if blending should be enabled
  25550. */
  25551. constructor(
  25552. /**Name of the animation */
  25553. name: string,
  25554. /**Property to animate */
  25555. targetProperty: string,
  25556. /**The frames per second of the animation */
  25557. framePerSecond: number,
  25558. /**The data type of the animation */
  25559. dataType: number,
  25560. /**The loop mode of the animation */
  25561. loopMode?: number | undefined,
  25562. /**Specifies if blending should be enabled */
  25563. enableBlending?: boolean | undefined);
  25564. /**
  25565. * Converts the animation to a string
  25566. * @param fullDetails support for multiple levels of logging within scene loading
  25567. * @returns String form of the animation
  25568. */
  25569. toString(fullDetails?: boolean): string;
  25570. /**
  25571. * Add an event to this animation
  25572. * @param event Event to add
  25573. */
  25574. addEvent(event: AnimationEvent): void;
  25575. /**
  25576. * Remove all events found at the given frame
  25577. * @param frame The frame to remove events from
  25578. */
  25579. removeEvents(frame: number): void;
  25580. /**
  25581. * Retrieves all the events from the animation
  25582. * @returns Events from the animation
  25583. */
  25584. getEvents(): AnimationEvent[];
  25585. /**
  25586. * Creates an animation range
  25587. * @param name Name of the animation range
  25588. * @param from Starting frame of the animation range
  25589. * @param to Ending frame of the animation
  25590. */
  25591. createRange(name: string, from: number, to: number): void;
  25592. /**
  25593. * Deletes an animation range by name
  25594. * @param name Name of the animation range to delete
  25595. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25596. */
  25597. deleteRange(name: string, deleteFrames?: boolean): void;
  25598. /**
  25599. * Gets the animation range by name, or null if not defined
  25600. * @param name Name of the animation range
  25601. * @returns Nullable animation range
  25602. */
  25603. getRange(name: string): Nullable<AnimationRange>;
  25604. /**
  25605. * Gets the key frames from the animation
  25606. * @returns The key frames of the animation
  25607. */
  25608. getKeys(): Array<IAnimationKey>;
  25609. /**
  25610. * Gets the highest frame rate of the animation
  25611. * @returns Highest frame rate of the animation
  25612. */
  25613. getHighestFrame(): number;
  25614. /**
  25615. * Gets the easing function of the animation
  25616. * @returns Easing function of the animation
  25617. */
  25618. getEasingFunction(): IEasingFunction;
  25619. /**
  25620. * Sets the easing function of the animation
  25621. * @param easingFunction A custom mathematical formula for animation
  25622. */
  25623. setEasingFunction(easingFunction: EasingFunction): void;
  25624. /**
  25625. * Interpolates a scalar linearly
  25626. * @param startValue Start value of the animation curve
  25627. * @param endValue End value of the animation curve
  25628. * @param gradient Scalar amount to interpolate
  25629. * @returns Interpolated scalar value
  25630. */
  25631. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25632. /**
  25633. * Interpolates a scalar cubically
  25634. * @param startValue Start value of the animation curve
  25635. * @param outTangent End tangent of the animation
  25636. * @param endValue End value of the animation curve
  25637. * @param inTangent Start tangent of the animation curve
  25638. * @param gradient Scalar amount to interpolate
  25639. * @returns Interpolated scalar value
  25640. */
  25641. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25642. /**
  25643. * Interpolates a quaternion using a spherical linear interpolation
  25644. * @param startValue Start value of the animation curve
  25645. * @param endValue End value of the animation curve
  25646. * @param gradient Scalar amount to interpolate
  25647. * @returns Interpolated quaternion value
  25648. */
  25649. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25650. /**
  25651. * Interpolates a quaternion cubically
  25652. * @param startValue Start value of the animation curve
  25653. * @param outTangent End tangent of the animation curve
  25654. * @param endValue End value of the animation curve
  25655. * @param inTangent Start tangent of the animation curve
  25656. * @param gradient Scalar amount to interpolate
  25657. * @returns Interpolated quaternion value
  25658. */
  25659. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25660. /**
  25661. * Interpolates a Vector3 linearl
  25662. * @param startValue Start value of the animation curve
  25663. * @param endValue End value of the animation curve
  25664. * @param gradient Scalar amount to interpolate
  25665. * @returns Interpolated scalar value
  25666. */
  25667. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25668. /**
  25669. * Interpolates a Vector3 cubically
  25670. * @param startValue Start value of the animation curve
  25671. * @param outTangent End tangent of the animation
  25672. * @param endValue End value of the animation curve
  25673. * @param inTangent Start tangent of the animation curve
  25674. * @param gradient Scalar amount to interpolate
  25675. * @returns InterpolatedVector3 value
  25676. */
  25677. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25678. /**
  25679. * Interpolates a Vector2 linearly
  25680. * @param startValue Start value of the animation curve
  25681. * @param endValue End value of the animation curve
  25682. * @param gradient Scalar amount to interpolate
  25683. * @returns Interpolated Vector2 value
  25684. */
  25685. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25686. /**
  25687. * Interpolates a Vector2 cubically
  25688. * @param startValue Start value of the animation curve
  25689. * @param outTangent End tangent of the animation
  25690. * @param endValue End value of the animation curve
  25691. * @param inTangent Start tangent of the animation curve
  25692. * @param gradient Scalar amount to interpolate
  25693. * @returns Interpolated Vector2 value
  25694. */
  25695. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25696. /**
  25697. * Interpolates a size linearly
  25698. * @param startValue Start value of the animation curve
  25699. * @param endValue End value of the animation curve
  25700. * @param gradient Scalar amount to interpolate
  25701. * @returns Interpolated Size value
  25702. */
  25703. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25704. /**
  25705. * Interpolates a Color3 linearly
  25706. * @param startValue Start value of the animation curve
  25707. * @param endValue End value of the animation curve
  25708. * @param gradient Scalar amount to interpolate
  25709. * @returns Interpolated Color3 value
  25710. */
  25711. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25712. /**
  25713. * @hidden Internal use only
  25714. */
  25715. _getKeyValue(value: any): any;
  25716. /**
  25717. * @hidden Internal use only
  25718. */
  25719. _interpolate(currentFrame: number, state: _IAnimationState): any;
  25720. /**
  25721. * Defines the function to use to interpolate matrices
  25722. * @param startValue defines the start matrix
  25723. * @param endValue defines the end matrix
  25724. * @param gradient defines the gradient between both matrices
  25725. * @param result defines an optional target matrix where to store the interpolation
  25726. * @returns the interpolated matrix
  25727. */
  25728. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25729. /**
  25730. * Makes a copy of the animation
  25731. * @returns Cloned animation
  25732. */
  25733. clone(): Animation;
  25734. /**
  25735. * Sets the key frames of the animation
  25736. * @param values The animation key frames to set
  25737. */
  25738. setKeys(values: Array<IAnimationKey>): void;
  25739. /**
  25740. * Serializes the animation to an object
  25741. * @returns Serialized object
  25742. */
  25743. serialize(): any;
  25744. /**
  25745. * Float animation type
  25746. */
  25747. private static _ANIMATIONTYPE_FLOAT;
  25748. /**
  25749. * Vector3 animation type
  25750. */
  25751. private static _ANIMATIONTYPE_VECTOR3;
  25752. /**
  25753. * Quaternion animation type
  25754. */
  25755. private static _ANIMATIONTYPE_QUATERNION;
  25756. /**
  25757. * Matrix animation type
  25758. */
  25759. private static _ANIMATIONTYPE_MATRIX;
  25760. /**
  25761. * Color3 animation type
  25762. */
  25763. private static _ANIMATIONTYPE_COLOR3;
  25764. /**
  25765. * Vector2 animation type
  25766. */
  25767. private static _ANIMATIONTYPE_VECTOR2;
  25768. /**
  25769. * Size animation type
  25770. */
  25771. private static _ANIMATIONTYPE_SIZE;
  25772. /**
  25773. * Relative Loop Mode
  25774. */
  25775. private static _ANIMATIONLOOPMODE_RELATIVE;
  25776. /**
  25777. * Cycle Loop Mode
  25778. */
  25779. private static _ANIMATIONLOOPMODE_CYCLE;
  25780. /**
  25781. * Constant Loop Mode
  25782. */
  25783. private static _ANIMATIONLOOPMODE_CONSTANT;
  25784. /**
  25785. * Get the float animation type
  25786. */
  25787. static readonly ANIMATIONTYPE_FLOAT: number;
  25788. /**
  25789. * Get the Vector3 animation type
  25790. */
  25791. static readonly ANIMATIONTYPE_VECTOR3: number;
  25792. /**
  25793. * Get the Vector2 animation type
  25794. */
  25795. static readonly ANIMATIONTYPE_VECTOR2: number;
  25796. /**
  25797. * Get the Size animation type
  25798. */
  25799. static readonly ANIMATIONTYPE_SIZE: number;
  25800. /**
  25801. * Get the Quaternion animation type
  25802. */
  25803. static readonly ANIMATIONTYPE_QUATERNION: number;
  25804. /**
  25805. * Get the Matrix animation type
  25806. */
  25807. static readonly ANIMATIONTYPE_MATRIX: number;
  25808. /**
  25809. * Get the Color3 animation type
  25810. */
  25811. static readonly ANIMATIONTYPE_COLOR3: number;
  25812. /**
  25813. * Get the Relative Loop Mode
  25814. */
  25815. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25816. /**
  25817. * Get the Cycle Loop Mode
  25818. */
  25819. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25820. /**
  25821. * Get the Constant Loop Mode
  25822. */
  25823. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25824. /** @hidden */
  25825. static _UniversalLerp(left: any, right: any, amount: number): any;
  25826. /**
  25827. * Parses an animation object and creates an animation
  25828. * @param parsedAnimation Parsed animation object
  25829. * @returns Animation object
  25830. */
  25831. static Parse(parsedAnimation: any): Animation;
  25832. /**
  25833. * Appends the serialized animations from the source animations
  25834. * @param source Source containing the animations
  25835. * @param destination Target to store the animations
  25836. */
  25837. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25838. }
  25839. }
  25840. declare module BABYLON {
  25841. /**
  25842. * Base class of all the textures in babylon.
  25843. * It groups all the common properties the materials, post process, lights... might need
  25844. * in order to make a correct use of the texture.
  25845. */
  25846. export class BaseTexture implements IAnimatable {
  25847. /**
  25848. * Default anisotropic filtering level for the application.
  25849. * It is set to 4 as a good tradeoff between perf and quality.
  25850. */
  25851. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25852. /**
  25853. * Gets or sets the unique id of the texture
  25854. */
  25855. uniqueId: number;
  25856. /**
  25857. * Define the name of the texture.
  25858. */
  25859. name: string;
  25860. /**
  25861. * Gets or sets an object used to store user defined information.
  25862. */
  25863. metadata: any;
  25864. /**
  25865. * For internal use only. Please do not use.
  25866. */
  25867. reservedDataStore: any;
  25868. private _hasAlpha;
  25869. /**
  25870. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25871. */
  25872. hasAlpha: boolean;
  25873. /**
  25874. * Defines if the alpha value should be determined via the rgb values.
  25875. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25876. */
  25877. getAlphaFromRGB: boolean;
  25878. /**
  25879. * Intensity or strength of the texture.
  25880. * It is commonly used by materials to fine tune the intensity of the texture
  25881. */
  25882. level: number;
  25883. /**
  25884. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25885. * This is part of the texture as textures usually maps to one uv set.
  25886. */
  25887. coordinatesIndex: number;
  25888. private _coordinatesMode;
  25889. /**
  25890. * How a texture is mapped.
  25891. *
  25892. * | Value | Type | Description |
  25893. * | ----- | ----------------------------------- | ----------- |
  25894. * | 0 | EXPLICIT_MODE | |
  25895. * | 1 | SPHERICAL_MODE | |
  25896. * | 2 | PLANAR_MODE | |
  25897. * | 3 | CUBIC_MODE | |
  25898. * | 4 | PROJECTION_MODE | |
  25899. * | 5 | SKYBOX_MODE | |
  25900. * | 6 | INVCUBIC_MODE | |
  25901. * | 7 | EQUIRECTANGULAR_MODE | |
  25902. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25903. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25904. */
  25905. coordinatesMode: number;
  25906. /**
  25907. * | Value | Type | Description |
  25908. * | ----- | ------------------ | ----------- |
  25909. * | 0 | CLAMP_ADDRESSMODE | |
  25910. * | 1 | WRAP_ADDRESSMODE | |
  25911. * | 2 | MIRROR_ADDRESSMODE | |
  25912. */
  25913. wrapU: number;
  25914. /**
  25915. * | Value | Type | Description |
  25916. * | ----- | ------------------ | ----------- |
  25917. * | 0 | CLAMP_ADDRESSMODE | |
  25918. * | 1 | WRAP_ADDRESSMODE | |
  25919. * | 2 | MIRROR_ADDRESSMODE | |
  25920. */
  25921. wrapV: number;
  25922. /**
  25923. * | Value | Type | Description |
  25924. * | ----- | ------------------ | ----------- |
  25925. * | 0 | CLAMP_ADDRESSMODE | |
  25926. * | 1 | WRAP_ADDRESSMODE | |
  25927. * | 2 | MIRROR_ADDRESSMODE | |
  25928. */
  25929. wrapR: number;
  25930. /**
  25931. * With compliant hardware and browser (supporting anisotropic filtering)
  25932. * this defines the level of anisotropic filtering in the texture.
  25933. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25934. */
  25935. anisotropicFilteringLevel: number;
  25936. /**
  25937. * Define if the texture is a cube texture or if false a 2d texture.
  25938. */
  25939. isCube: boolean;
  25940. /**
  25941. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25942. */
  25943. is3D: boolean;
  25944. /**
  25945. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25946. * HDR texture are usually stored in linear space.
  25947. * This only impacts the PBR and Background materials
  25948. */
  25949. gammaSpace: boolean;
  25950. /**
  25951. * Gets whether or not the texture contains RGBD data.
  25952. */
  25953. readonly isRGBD: boolean;
  25954. /**
  25955. * Is Z inverted in the texture (useful in a cube texture).
  25956. */
  25957. invertZ: boolean;
  25958. /**
  25959. * Are mip maps generated for this texture or not.
  25960. */
  25961. readonly noMipmap: boolean;
  25962. /**
  25963. * @hidden
  25964. */
  25965. lodLevelInAlpha: boolean;
  25966. /**
  25967. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25968. */
  25969. lodGenerationOffset: number;
  25970. /**
  25971. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25972. */
  25973. lodGenerationScale: number;
  25974. /**
  25975. * Define if the texture is a render target.
  25976. */
  25977. isRenderTarget: boolean;
  25978. /**
  25979. * Define the unique id of the texture in the scene.
  25980. */
  25981. readonly uid: string;
  25982. /**
  25983. * Return a string representation of the texture.
  25984. * @returns the texture as a string
  25985. */
  25986. toString(): string;
  25987. /**
  25988. * Get the class name of the texture.
  25989. * @returns "BaseTexture"
  25990. */
  25991. getClassName(): string;
  25992. /**
  25993. * Define the list of animation attached to the texture.
  25994. */
  25995. animations: Animation[];
  25996. /**
  25997. * An event triggered when the texture is disposed.
  25998. */
  25999. onDisposeObservable: Observable<BaseTexture>;
  26000. private _onDisposeObserver;
  26001. /**
  26002. * Callback triggered when the texture has been disposed.
  26003. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26004. */
  26005. onDispose: () => void;
  26006. /**
  26007. * Define the current state of the loading sequence when in delayed load mode.
  26008. */
  26009. delayLoadState: number;
  26010. private _scene;
  26011. /** @hidden */
  26012. _texture: Nullable<InternalTexture>;
  26013. private _uid;
  26014. /**
  26015. * Define if the texture is preventinga material to render or not.
  26016. * If not and the texture is not ready, the engine will use a default black texture instead.
  26017. */
  26018. readonly isBlocking: boolean;
  26019. /**
  26020. * Instantiates a new BaseTexture.
  26021. * Base class of all the textures in babylon.
  26022. * It groups all the common properties the materials, post process, lights... might need
  26023. * in order to make a correct use of the texture.
  26024. * @param scene Define the scene the texture blongs to
  26025. */
  26026. constructor(scene: Nullable<Scene>);
  26027. /**
  26028. * Get the scene the texture belongs to.
  26029. * @returns the scene or null if undefined
  26030. */
  26031. getScene(): Nullable<Scene>;
  26032. /**
  26033. * Get the texture transform matrix used to offset tile the texture for istance.
  26034. * @returns the transformation matrix
  26035. */
  26036. getTextureMatrix(): Matrix;
  26037. /**
  26038. * Get the texture reflection matrix used to rotate/transform the reflection.
  26039. * @returns the reflection matrix
  26040. */
  26041. getReflectionTextureMatrix(): Matrix;
  26042. /**
  26043. * Get the underlying lower level texture from Babylon.
  26044. * @returns the insternal texture
  26045. */
  26046. getInternalTexture(): Nullable<InternalTexture>;
  26047. /**
  26048. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26049. * @returns true if ready or not blocking
  26050. */
  26051. isReadyOrNotBlocking(): boolean;
  26052. /**
  26053. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26054. * @returns true if fully ready
  26055. */
  26056. isReady(): boolean;
  26057. private _cachedSize;
  26058. /**
  26059. * Get the size of the texture.
  26060. * @returns the texture size.
  26061. */
  26062. getSize(): ISize;
  26063. /**
  26064. * Get the base size of the texture.
  26065. * It can be different from the size if the texture has been resized for POT for instance
  26066. * @returns the base size
  26067. */
  26068. getBaseSize(): ISize;
  26069. /**
  26070. * Update the sampling mode of the texture.
  26071. * Default is Trilinear mode.
  26072. *
  26073. * | Value | Type | Description |
  26074. * | ----- | ------------------ | ----------- |
  26075. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26076. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26077. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26078. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26079. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26080. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26081. * | 7 | NEAREST_LINEAR | |
  26082. * | 8 | NEAREST_NEAREST | |
  26083. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26084. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26085. * | 11 | LINEAR_LINEAR | |
  26086. * | 12 | LINEAR_NEAREST | |
  26087. *
  26088. * > _mag_: magnification filter (close to the viewer)
  26089. * > _min_: minification filter (far from the viewer)
  26090. * > _mip_: filter used between mip map levels
  26091. *@param samplingMode Define the new sampling mode of the texture
  26092. */
  26093. updateSamplingMode(samplingMode: number): void;
  26094. /**
  26095. * Scales the texture if is `canRescale()`
  26096. * @param ratio the resize factor we want to use to rescale
  26097. */
  26098. scale(ratio: number): void;
  26099. /**
  26100. * Get if the texture can rescale.
  26101. */
  26102. readonly canRescale: boolean;
  26103. /** @hidden */
  26104. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26105. /** @hidden */
  26106. _rebuild(): void;
  26107. /**
  26108. * Triggers the load sequence in delayed load mode.
  26109. */
  26110. delayLoad(): void;
  26111. /**
  26112. * Clones the texture.
  26113. * @returns the cloned texture
  26114. */
  26115. clone(): Nullable<BaseTexture>;
  26116. /**
  26117. * Get the texture underlying type (INT, FLOAT...)
  26118. */
  26119. readonly textureType: number;
  26120. /**
  26121. * Get the texture underlying format (RGB, RGBA...)
  26122. */
  26123. readonly textureFormat: number;
  26124. /**
  26125. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26126. * This will returns an RGBA array buffer containing either in values (0-255) or
  26127. * float values (0-1) depending of the underlying buffer type.
  26128. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26129. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26130. * @param buffer defines a user defined buffer to fill with data (can be null)
  26131. * @returns The Array buffer containing the pixels data.
  26132. */
  26133. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26134. /**
  26135. * Release and destroy the underlying lower level texture aka internalTexture.
  26136. */
  26137. releaseInternalTexture(): void;
  26138. /**
  26139. * Get the polynomial representation of the texture data.
  26140. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26141. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26142. */
  26143. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26144. /** @hidden */
  26145. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26146. /** @hidden */
  26147. readonly _lodTextureMid: Nullable<BaseTexture>;
  26148. /** @hidden */
  26149. readonly _lodTextureLow: Nullable<BaseTexture>;
  26150. /**
  26151. * Dispose the texture and release its associated resources.
  26152. */
  26153. dispose(): void;
  26154. /**
  26155. * Serialize the texture into a JSON representation that can be parsed later on.
  26156. * @returns the JSON representation of the texture
  26157. */
  26158. serialize(): any;
  26159. /**
  26160. * Helper function to be called back once a list of texture contains only ready textures.
  26161. * @param textures Define the list of textures to wait for
  26162. * @param callback Define the callback triggered once the entire list will be ready
  26163. */
  26164. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26165. }
  26166. }
  26167. declare module BABYLON {
  26168. /**
  26169. * Uniform buffer objects.
  26170. *
  26171. * Handles blocks of uniform on the GPU.
  26172. *
  26173. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26174. *
  26175. * For more information, please refer to :
  26176. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26177. */
  26178. export class UniformBuffer {
  26179. private _engine;
  26180. private _buffer;
  26181. private _data;
  26182. private _bufferData;
  26183. private _dynamic?;
  26184. private _uniformLocations;
  26185. private _uniformSizes;
  26186. private _uniformLocationPointer;
  26187. private _needSync;
  26188. private _noUBO;
  26189. private _currentEffect;
  26190. private static _MAX_UNIFORM_SIZE;
  26191. private static _tempBuffer;
  26192. /**
  26193. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26194. * This is dynamic to allow compat with webgl 1 and 2.
  26195. * You will need to pass the name of the uniform as well as the value.
  26196. */
  26197. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26198. /**
  26199. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26200. * This is dynamic to allow compat with webgl 1 and 2.
  26201. * You will need to pass the name of the uniform as well as the value.
  26202. */
  26203. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26204. /**
  26205. * Lambda to Update a single float in a uniform buffer.
  26206. * This is dynamic to allow compat with webgl 1 and 2.
  26207. * You will need to pass the name of the uniform as well as the value.
  26208. */
  26209. updateFloat: (name: string, x: number) => void;
  26210. /**
  26211. * Lambda to Update a vec2 of float in a uniform buffer.
  26212. * This is dynamic to allow compat with webgl 1 and 2.
  26213. * You will need to pass the name of the uniform as well as the value.
  26214. */
  26215. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26216. /**
  26217. * Lambda to Update a vec3 of float in a uniform buffer.
  26218. * This is dynamic to allow compat with webgl 1 and 2.
  26219. * You will need to pass the name of the uniform as well as the value.
  26220. */
  26221. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26222. /**
  26223. * Lambda to Update a vec4 of float in a uniform buffer.
  26224. * This is dynamic to allow compat with webgl 1 and 2.
  26225. * You will need to pass the name of the uniform as well as the value.
  26226. */
  26227. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26228. /**
  26229. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26230. * This is dynamic to allow compat with webgl 1 and 2.
  26231. * You will need to pass the name of the uniform as well as the value.
  26232. */
  26233. updateMatrix: (name: string, mat: Matrix) => void;
  26234. /**
  26235. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26236. * This is dynamic to allow compat with webgl 1 and 2.
  26237. * You will need to pass the name of the uniform as well as the value.
  26238. */
  26239. updateVector3: (name: string, vector: Vector3) => void;
  26240. /**
  26241. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26242. * This is dynamic to allow compat with webgl 1 and 2.
  26243. * You will need to pass the name of the uniform as well as the value.
  26244. */
  26245. updateVector4: (name: string, vector: Vector4) => void;
  26246. /**
  26247. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26248. * This is dynamic to allow compat with webgl 1 and 2.
  26249. * You will need to pass the name of the uniform as well as the value.
  26250. */
  26251. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26252. /**
  26253. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26254. * This is dynamic to allow compat with webgl 1 and 2.
  26255. * You will need to pass the name of the uniform as well as the value.
  26256. */
  26257. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26258. /**
  26259. * Instantiates a new Uniform buffer objects.
  26260. *
  26261. * Handles blocks of uniform on the GPU.
  26262. *
  26263. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26264. *
  26265. * For more information, please refer to :
  26266. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26267. * @param engine Define the engine the buffer is associated with
  26268. * @param data Define the data contained in the buffer
  26269. * @param dynamic Define if the buffer is updatable
  26270. */
  26271. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26272. /**
  26273. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26274. * or just falling back on setUniformXXX calls.
  26275. */
  26276. readonly useUbo: boolean;
  26277. /**
  26278. * Indicates if the WebGL underlying uniform buffer is in sync
  26279. * with the javascript cache data.
  26280. */
  26281. readonly isSync: boolean;
  26282. /**
  26283. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26284. * Also, a dynamic UniformBuffer will disable cache verification and always
  26285. * update the underlying WebGL uniform buffer to the GPU.
  26286. * @returns if Dynamic, otherwise false
  26287. */
  26288. isDynamic(): boolean;
  26289. /**
  26290. * The data cache on JS side.
  26291. * @returns the underlying data as a float array
  26292. */
  26293. getData(): Float32Array;
  26294. /**
  26295. * The underlying WebGL Uniform buffer.
  26296. * @returns the webgl buffer
  26297. */
  26298. getBuffer(): Nullable<DataBuffer>;
  26299. /**
  26300. * std140 layout specifies how to align data within an UBO structure.
  26301. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26302. * for specs.
  26303. */
  26304. private _fillAlignment;
  26305. /**
  26306. * Adds an uniform in the buffer.
  26307. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26308. * for the layout to be correct !
  26309. * @param name Name of the uniform, as used in the uniform block in the shader.
  26310. * @param size Data size, or data directly.
  26311. */
  26312. addUniform(name: string, size: number | number[]): void;
  26313. /**
  26314. * Adds a Matrix 4x4 to the uniform buffer.
  26315. * @param name Name of the uniform, as used in the uniform block in the shader.
  26316. * @param mat A 4x4 matrix.
  26317. */
  26318. addMatrix(name: string, mat: Matrix): void;
  26319. /**
  26320. * Adds a vec2 to the uniform buffer.
  26321. * @param name Name of the uniform, as used in the uniform block in the shader.
  26322. * @param x Define the x component value of the vec2
  26323. * @param y Define the y component value of the vec2
  26324. */
  26325. addFloat2(name: string, x: number, y: number): void;
  26326. /**
  26327. * Adds a vec3 to the uniform buffer.
  26328. * @param name Name of the uniform, as used in the uniform block in the shader.
  26329. * @param x Define the x component value of the vec3
  26330. * @param y Define the y component value of the vec3
  26331. * @param z Define the z component value of the vec3
  26332. */
  26333. addFloat3(name: string, x: number, y: number, z: number): void;
  26334. /**
  26335. * Adds a vec3 to the uniform buffer.
  26336. * @param name Name of the uniform, as used in the uniform block in the shader.
  26337. * @param color Define the vec3 from a Color
  26338. */
  26339. addColor3(name: string, color: Color3): void;
  26340. /**
  26341. * Adds a vec4 to the uniform buffer.
  26342. * @param name Name of the uniform, as used in the uniform block in the shader.
  26343. * @param color Define the rgb components from a Color
  26344. * @param alpha Define the a component of the vec4
  26345. */
  26346. addColor4(name: string, color: Color3, alpha: number): void;
  26347. /**
  26348. * Adds a vec3 to the uniform buffer.
  26349. * @param name Name of the uniform, as used in the uniform block in the shader.
  26350. * @param vector Define the vec3 components from a Vector
  26351. */
  26352. addVector3(name: string, vector: Vector3): void;
  26353. /**
  26354. * Adds a Matrix 3x3 to the uniform buffer.
  26355. * @param name Name of the uniform, as used in the uniform block in the shader.
  26356. */
  26357. addMatrix3x3(name: string): void;
  26358. /**
  26359. * Adds a Matrix 2x2 to the uniform buffer.
  26360. * @param name Name of the uniform, as used in the uniform block in the shader.
  26361. */
  26362. addMatrix2x2(name: string): void;
  26363. /**
  26364. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26365. */
  26366. create(): void;
  26367. /** @hidden */
  26368. _rebuild(): void;
  26369. /**
  26370. * Updates the WebGL Uniform Buffer on the GPU.
  26371. * If the `dynamic` flag is set to true, no cache comparison is done.
  26372. * Otherwise, the buffer will be updated only if the cache differs.
  26373. */
  26374. update(): void;
  26375. /**
  26376. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26377. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26378. * @param data Define the flattened data
  26379. * @param size Define the size of the data.
  26380. */
  26381. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26382. private _updateMatrix3x3ForUniform;
  26383. private _updateMatrix3x3ForEffect;
  26384. private _updateMatrix2x2ForEffect;
  26385. private _updateMatrix2x2ForUniform;
  26386. private _updateFloatForEffect;
  26387. private _updateFloatForUniform;
  26388. private _updateFloat2ForEffect;
  26389. private _updateFloat2ForUniform;
  26390. private _updateFloat3ForEffect;
  26391. private _updateFloat3ForUniform;
  26392. private _updateFloat4ForEffect;
  26393. private _updateFloat4ForUniform;
  26394. private _updateMatrixForEffect;
  26395. private _updateMatrixForUniform;
  26396. private _updateVector3ForEffect;
  26397. private _updateVector3ForUniform;
  26398. private _updateVector4ForEffect;
  26399. private _updateVector4ForUniform;
  26400. private _updateColor3ForEffect;
  26401. private _updateColor3ForUniform;
  26402. private _updateColor4ForEffect;
  26403. private _updateColor4ForUniform;
  26404. /**
  26405. * Sets a sampler uniform on the effect.
  26406. * @param name Define the name of the sampler.
  26407. * @param texture Define the texture to set in the sampler
  26408. */
  26409. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26410. /**
  26411. * Directly updates the value of the uniform in the cache AND on the GPU.
  26412. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26413. * @param data Define the flattened data
  26414. */
  26415. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26416. /**
  26417. * Binds this uniform buffer to an effect.
  26418. * @param effect Define the effect to bind the buffer to
  26419. * @param name Name of the uniform block in the shader.
  26420. */
  26421. bindToEffect(effect: Effect, name: string): void;
  26422. /**
  26423. * Disposes the uniform buffer.
  26424. */
  26425. dispose(): void;
  26426. }
  26427. }
  26428. declare module BABYLON {
  26429. /**
  26430. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26431. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26432. */
  26433. export class Analyser {
  26434. /**
  26435. * Gets or sets the smoothing
  26436. * @ignorenaming
  26437. */
  26438. SMOOTHING: number;
  26439. /**
  26440. * Gets or sets the FFT table size
  26441. * @ignorenaming
  26442. */
  26443. FFT_SIZE: number;
  26444. /**
  26445. * Gets or sets the bar graph amplitude
  26446. * @ignorenaming
  26447. */
  26448. BARGRAPHAMPLITUDE: number;
  26449. /**
  26450. * Gets or sets the position of the debug canvas
  26451. * @ignorenaming
  26452. */
  26453. DEBUGCANVASPOS: {
  26454. x: number;
  26455. y: number;
  26456. };
  26457. /**
  26458. * Gets or sets the debug canvas size
  26459. * @ignorenaming
  26460. */
  26461. DEBUGCANVASSIZE: {
  26462. width: number;
  26463. height: number;
  26464. };
  26465. private _byteFreqs;
  26466. private _byteTime;
  26467. private _floatFreqs;
  26468. private _webAudioAnalyser;
  26469. private _debugCanvas;
  26470. private _debugCanvasContext;
  26471. private _scene;
  26472. private _registerFunc;
  26473. private _audioEngine;
  26474. /**
  26475. * Creates a new analyser
  26476. * @param scene defines hosting scene
  26477. */
  26478. constructor(scene: Scene);
  26479. /**
  26480. * Get the number of data values you will have to play with for the visualization
  26481. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26482. * @returns a number
  26483. */
  26484. getFrequencyBinCount(): number;
  26485. /**
  26486. * Gets the current frequency data as a byte array
  26487. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26488. * @returns a Uint8Array
  26489. */
  26490. getByteFrequencyData(): Uint8Array;
  26491. /**
  26492. * Gets the current waveform as a byte array
  26493. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26494. * @returns a Uint8Array
  26495. */
  26496. getByteTimeDomainData(): Uint8Array;
  26497. /**
  26498. * Gets the current frequency data as a float array
  26499. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26500. * @returns a Float32Array
  26501. */
  26502. getFloatFrequencyData(): Float32Array;
  26503. /**
  26504. * Renders the debug canvas
  26505. */
  26506. drawDebugCanvas(): void;
  26507. /**
  26508. * Stops rendering the debug canvas and removes it
  26509. */
  26510. stopDebugCanvas(): void;
  26511. /**
  26512. * Connects two audio nodes
  26513. * @param inputAudioNode defines first node to connect
  26514. * @param outputAudioNode defines second node to connect
  26515. */
  26516. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26517. /**
  26518. * Releases all associated resources
  26519. */
  26520. dispose(): void;
  26521. }
  26522. }
  26523. declare module BABYLON {
  26524. /**
  26525. * This represents an audio engine and it is responsible
  26526. * to play, synchronize and analyse sounds throughout the application.
  26527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26528. */
  26529. export interface IAudioEngine extends IDisposable {
  26530. /**
  26531. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26532. */
  26533. readonly canUseWebAudio: boolean;
  26534. /**
  26535. * Gets the current AudioContext if available.
  26536. */
  26537. readonly audioContext: Nullable<AudioContext>;
  26538. /**
  26539. * The master gain node defines the global audio volume of your audio engine.
  26540. */
  26541. readonly masterGain: GainNode;
  26542. /**
  26543. * Gets whether or not mp3 are supported by your browser.
  26544. */
  26545. readonly isMP3supported: boolean;
  26546. /**
  26547. * Gets whether or not ogg are supported by your browser.
  26548. */
  26549. readonly isOGGsupported: boolean;
  26550. /**
  26551. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26552. * @ignoreNaming
  26553. */
  26554. WarnedWebAudioUnsupported: boolean;
  26555. /**
  26556. * Defines if the audio engine relies on a custom unlocked button.
  26557. * In this case, the embedded button will not be displayed.
  26558. */
  26559. useCustomUnlockedButton: boolean;
  26560. /**
  26561. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26562. */
  26563. readonly unlocked: boolean;
  26564. /**
  26565. * Event raised when audio has been unlocked on the browser.
  26566. */
  26567. onAudioUnlockedObservable: Observable<AudioEngine>;
  26568. /**
  26569. * Event raised when audio has been locked on the browser.
  26570. */
  26571. onAudioLockedObservable: Observable<AudioEngine>;
  26572. /**
  26573. * Flags the audio engine in Locked state.
  26574. * This happens due to new browser policies preventing audio to autoplay.
  26575. */
  26576. lock(): void;
  26577. /**
  26578. * Unlocks the audio engine once a user action has been done on the dom.
  26579. * This is helpful to resume play once browser policies have been satisfied.
  26580. */
  26581. unlock(): void;
  26582. }
  26583. /**
  26584. * This represents the default audio engine used in babylon.
  26585. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26586. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26587. */
  26588. export class AudioEngine implements IAudioEngine {
  26589. private _audioContext;
  26590. private _audioContextInitialized;
  26591. private _muteButton;
  26592. private _hostElement;
  26593. /**
  26594. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26595. */
  26596. canUseWebAudio: boolean;
  26597. /**
  26598. * The master gain node defines the global audio volume of your audio engine.
  26599. */
  26600. masterGain: GainNode;
  26601. /**
  26602. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26603. * @ignoreNaming
  26604. */
  26605. WarnedWebAudioUnsupported: boolean;
  26606. /**
  26607. * Gets whether or not mp3 are supported by your browser.
  26608. */
  26609. isMP3supported: boolean;
  26610. /**
  26611. * Gets whether or not ogg are supported by your browser.
  26612. */
  26613. isOGGsupported: boolean;
  26614. /**
  26615. * Gets whether audio has been unlocked on the device.
  26616. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26617. * a user interaction has happened.
  26618. */
  26619. unlocked: boolean;
  26620. /**
  26621. * Defines if the audio engine relies on a custom unlocked button.
  26622. * In this case, the embedded button will not be displayed.
  26623. */
  26624. useCustomUnlockedButton: boolean;
  26625. /**
  26626. * Event raised when audio has been unlocked on the browser.
  26627. */
  26628. onAudioUnlockedObservable: Observable<AudioEngine>;
  26629. /**
  26630. * Event raised when audio has been locked on the browser.
  26631. */
  26632. onAudioLockedObservable: Observable<AudioEngine>;
  26633. /**
  26634. * Gets the current AudioContext if available.
  26635. */
  26636. readonly audioContext: Nullable<AudioContext>;
  26637. private _connectedAnalyser;
  26638. /**
  26639. * Instantiates a new audio engine.
  26640. *
  26641. * There should be only one per page as some browsers restrict the number
  26642. * of audio contexts you can create.
  26643. * @param hostElement defines the host element where to display the mute icon if necessary
  26644. */
  26645. constructor(hostElement?: Nullable<HTMLElement>);
  26646. /**
  26647. * Flags the audio engine in Locked state.
  26648. * This happens due to new browser policies preventing audio to autoplay.
  26649. */
  26650. lock(): void;
  26651. /**
  26652. * Unlocks the audio engine once a user action has been done on the dom.
  26653. * This is helpful to resume play once browser policies have been satisfied.
  26654. */
  26655. unlock(): void;
  26656. private _resumeAudioContext;
  26657. private _initializeAudioContext;
  26658. private _tryToRun;
  26659. private _triggerRunningState;
  26660. private _triggerSuspendedState;
  26661. private _displayMuteButton;
  26662. private _moveButtonToTopLeft;
  26663. private _onResize;
  26664. private _hideMuteButton;
  26665. /**
  26666. * Destroy and release the resources associated with the audio ccontext.
  26667. */
  26668. dispose(): void;
  26669. /**
  26670. * Gets the global volume sets on the master gain.
  26671. * @returns the global volume if set or -1 otherwise
  26672. */
  26673. getGlobalVolume(): number;
  26674. /**
  26675. * Sets the global volume of your experience (sets on the master gain).
  26676. * @param newVolume Defines the new global volume of the application
  26677. */
  26678. setGlobalVolume(newVolume: number): void;
  26679. /**
  26680. * Connect the audio engine to an audio analyser allowing some amazing
  26681. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26682. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26683. * @param analyser The analyser to connect to the engine
  26684. */
  26685. connectToAnalyser(analyser: Analyser): void;
  26686. }
  26687. }
  26688. declare module BABYLON {
  26689. /**
  26690. * Interface used to present a loading screen while loading a scene
  26691. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26692. */
  26693. export interface ILoadingScreen {
  26694. /**
  26695. * Function called to display the loading screen
  26696. */
  26697. displayLoadingUI: () => void;
  26698. /**
  26699. * Function called to hide the loading screen
  26700. */
  26701. hideLoadingUI: () => void;
  26702. /**
  26703. * Gets or sets the color to use for the background
  26704. */
  26705. loadingUIBackgroundColor: string;
  26706. /**
  26707. * Gets or sets the text to display while loading
  26708. */
  26709. loadingUIText: string;
  26710. }
  26711. /**
  26712. * Class used for the default loading screen
  26713. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26714. */
  26715. export class DefaultLoadingScreen implements ILoadingScreen {
  26716. private _renderingCanvas;
  26717. private _loadingText;
  26718. private _loadingDivBackgroundColor;
  26719. private _loadingDiv;
  26720. private _loadingTextDiv;
  26721. /**
  26722. * Creates a new default loading screen
  26723. * @param _renderingCanvas defines the canvas used to render the scene
  26724. * @param _loadingText defines the default text to display
  26725. * @param _loadingDivBackgroundColor defines the default background color
  26726. */
  26727. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26728. /**
  26729. * Function called to display the loading screen
  26730. */
  26731. displayLoadingUI(): void;
  26732. /**
  26733. * Function called to hide the loading screen
  26734. */
  26735. hideLoadingUI(): void;
  26736. /**
  26737. * Gets or sets the text to display while loading
  26738. */
  26739. loadingUIText: string;
  26740. /**
  26741. * Gets or sets the color to use for the background
  26742. */
  26743. loadingUIBackgroundColor: string;
  26744. private _resizeLoadingUI;
  26745. }
  26746. }
  26747. declare module BABYLON {
  26748. /** @hidden */
  26749. export class WebGLPipelineContext implements IPipelineContext {
  26750. engine: Engine;
  26751. program: Nullable<WebGLProgram>;
  26752. context?: WebGLRenderingContext;
  26753. vertexShader?: WebGLShader;
  26754. fragmentShader?: WebGLShader;
  26755. isParallelCompiled: boolean;
  26756. onCompiled?: () => void;
  26757. transformFeedback?: WebGLTransformFeedback | null;
  26758. readonly isAsync: boolean;
  26759. readonly isReady: boolean;
  26760. }
  26761. }
  26762. declare module BABYLON {
  26763. /** @hidden */
  26764. export class WebGLDataBuffer extends DataBuffer {
  26765. private _buffer;
  26766. constructor(resource: WebGLBuffer);
  26767. readonly underlyingResource: any;
  26768. }
  26769. }
  26770. declare module BABYLON {
  26771. /**
  26772. * Settings for finer control over video usage
  26773. */
  26774. export interface VideoTextureSettings {
  26775. /**
  26776. * Applies `autoplay` to video, if specified
  26777. */
  26778. autoPlay?: boolean;
  26779. /**
  26780. * Applies `loop` to video, if specified
  26781. */
  26782. loop?: boolean;
  26783. /**
  26784. * Automatically updates internal texture from video at every frame in the render loop
  26785. */
  26786. autoUpdateTexture: boolean;
  26787. /**
  26788. * Image src displayed during the video loading or until the user interacts with the video.
  26789. */
  26790. poster?: string;
  26791. }
  26792. /**
  26793. * If you want to display a video in your scene, this is the special texture for that.
  26794. * This special texture works similar to other textures, with the exception of a few parameters.
  26795. * @see https://doc.babylonjs.com/how_to/video_texture
  26796. */
  26797. export class VideoTexture extends Texture {
  26798. /**
  26799. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26800. */
  26801. readonly autoUpdateTexture: boolean;
  26802. /**
  26803. * The video instance used by the texture internally
  26804. */
  26805. readonly video: HTMLVideoElement;
  26806. private _onUserActionRequestedObservable;
  26807. /**
  26808. * Event triggerd when a dom action is required by the user to play the video.
  26809. * This happens due to recent changes in browser policies preventing video to auto start.
  26810. */
  26811. readonly onUserActionRequestedObservable: Observable<Texture>;
  26812. private _generateMipMaps;
  26813. private _engine;
  26814. private _stillImageCaptured;
  26815. private _displayingPosterTexture;
  26816. private _settings;
  26817. private _createInternalTextureOnEvent;
  26818. /**
  26819. * Creates a video texture.
  26820. * If you want to display a video in your scene, this is the special texture for that.
  26821. * This special texture works similar to other textures, with the exception of a few parameters.
  26822. * @see https://doc.babylonjs.com/how_to/video_texture
  26823. * @param name optional name, will detect from video source, if not defined
  26824. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26825. * @param scene is obviously the current scene.
  26826. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26827. * @param invertY is false by default but can be used to invert video on Y axis
  26828. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26829. * @param settings allows finer control over video usage
  26830. */
  26831. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26832. private _getName;
  26833. private _getVideo;
  26834. private _createInternalTexture;
  26835. private reset;
  26836. /**
  26837. * @hidden Internal method to initiate `update`.
  26838. */
  26839. _rebuild(): void;
  26840. /**
  26841. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26842. */
  26843. update(): void;
  26844. /**
  26845. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26846. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26847. */
  26848. updateTexture(isVisible: boolean): void;
  26849. protected _updateInternalTexture: () => void;
  26850. /**
  26851. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26852. * @param url New url.
  26853. */
  26854. updateURL(url: string): void;
  26855. /**
  26856. * Dispose the texture and release its associated resources.
  26857. */
  26858. dispose(): void;
  26859. /**
  26860. * Creates a video texture straight from a stream.
  26861. * @param scene Define the scene the texture should be created in
  26862. * @param stream Define the stream the texture should be created from
  26863. * @returns The created video texture as a promise
  26864. */
  26865. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26866. /**
  26867. * Creates a video texture straight from your WebCam video feed.
  26868. * @param scene Define the scene the texture should be created in
  26869. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26870. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26871. * @returns The created video texture as a promise
  26872. */
  26873. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26874. minWidth: number;
  26875. maxWidth: number;
  26876. minHeight: number;
  26877. maxHeight: number;
  26878. deviceId: string;
  26879. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26880. /**
  26881. * Creates a video texture straight from your WebCam video feed.
  26882. * @param scene Define the scene the texture should be created in
  26883. * @param onReady Define a callback to triggered once the texture will be ready
  26884. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26885. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26886. */
  26887. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26888. minWidth: number;
  26889. maxWidth: number;
  26890. minHeight: number;
  26891. maxHeight: number;
  26892. deviceId: string;
  26893. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26894. }
  26895. }
  26896. declare module BABYLON {
  26897. /**
  26898. * Interface for attribute information associated with buffer instanciation
  26899. */
  26900. export class InstancingAttributeInfo {
  26901. /**
  26902. * Index/offset of the attribute in the vertex shader
  26903. */
  26904. index: number;
  26905. /**
  26906. * size of the attribute, 1, 2, 3 or 4
  26907. */
  26908. attributeSize: number;
  26909. /**
  26910. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26911. * default is FLOAT
  26912. */
  26913. attribyteType: number;
  26914. /**
  26915. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26916. */
  26917. normalized: boolean;
  26918. /**
  26919. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26920. */
  26921. offset: number;
  26922. /**
  26923. * Name of the GLSL attribute, for debugging purpose only
  26924. */
  26925. attributeName: string;
  26926. }
  26927. /**
  26928. * Define options used to create a depth texture
  26929. */
  26930. export class DepthTextureCreationOptions {
  26931. /** Specifies whether or not a stencil should be allocated in the texture */
  26932. generateStencil?: boolean;
  26933. /** Specifies whether or not bilinear filtering is enable on the texture */
  26934. bilinearFiltering?: boolean;
  26935. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26936. comparisonFunction?: number;
  26937. /** Specifies if the created texture is a cube texture */
  26938. isCube?: boolean;
  26939. }
  26940. /**
  26941. * Class used to describe the capabilities of the engine relatively to the current browser
  26942. */
  26943. export class EngineCapabilities {
  26944. /** Maximum textures units per fragment shader */
  26945. maxTexturesImageUnits: number;
  26946. /** Maximum texture units per vertex shader */
  26947. maxVertexTextureImageUnits: number;
  26948. /** Maximum textures units in the entire pipeline */
  26949. maxCombinedTexturesImageUnits: number;
  26950. /** Maximum texture size */
  26951. maxTextureSize: number;
  26952. /** Maximum cube texture size */
  26953. maxCubemapTextureSize: number;
  26954. /** Maximum render texture size */
  26955. maxRenderTextureSize: number;
  26956. /** Maximum number of vertex attributes */
  26957. maxVertexAttribs: number;
  26958. /** Maximum number of varyings */
  26959. maxVaryingVectors: number;
  26960. /** Maximum number of uniforms per vertex shader */
  26961. maxVertexUniformVectors: number;
  26962. /** Maximum number of uniforms per fragment shader */
  26963. maxFragmentUniformVectors: number;
  26964. /** Defines if standard derivates (dx/dy) are supported */
  26965. standardDerivatives: boolean;
  26966. /** Defines if s3tc texture compression is supported */
  26967. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26968. /** Defines if pvrtc texture compression is supported */
  26969. pvrtc: any;
  26970. /** Defines if etc1 texture compression is supported */
  26971. etc1: any;
  26972. /** Defines if etc2 texture compression is supported */
  26973. etc2: any;
  26974. /** Defines if astc texture compression is supported */
  26975. astc: any;
  26976. /** Defines if float textures are supported */
  26977. textureFloat: boolean;
  26978. /** Defines if vertex array objects are supported */
  26979. vertexArrayObject: boolean;
  26980. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26981. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26982. /** Gets the maximum level of anisotropy supported */
  26983. maxAnisotropy: number;
  26984. /** Defines if instancing is supported */
  26985. instancedArrays: boolean;
  26986. /** Defines if 32 bits indices are supported */
  26987. uintIndices: boolean;
  26988. /** Defines if high precision shaders are supported */
  26989. highPrecisionShaderSupported: boolean;
  26990. /** Defines if depth reading in the fragment shader is supported */
  26991. fragmentDepthSupported: boolean;
  26992. /** Defines if float texture linear filtering is supported*/
  26993. textureFloatLinearFiltering: boolean;
  26994. /** Defines if rendering to float textures is supported */
  26995. textureFloatRender: boolean;
  26996. /** Defines if half float textures are supported*/
  26997. textureHalfFloat: boolean;
  26998. /** Defines if half float texture linear filtering is supported*/
  26999. textureHalfFloatLinearFiltering: boolean;
  27000. /** Defines if rendering to half float textures is supported */
  27001. textureHalfFloatRender: boolean;
  27002. /** Defines if textureLOD shader command is supported */
  27003. textureLOD: boolean;
  27004. /** Defines if draw buffers extension is supported */
  27005. drawBuffersExtension: boolean;
  27006. /** Defines if depth textures are supported */
  27007. depthTextureExtension: boolean;
  27008. /** Defines if float color buffer are supported */
  27009. colorBufferFloat: boolean;
  27010. /** Gets disjoint timer query extension (null if not supported) */
  27011. timerQuery: EXT_disjoint_timer_query;
  27012. /** Defines if timestamp can be used with timer query */
  27013. canUseTimestampForTimerQuery: boolean;
  27014. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27015. multiview: any;
  27016. /** Function used to let the system compiles shaders in background */
  27017. parallelShaderCompile: {
  27018. COMPLETION_STATUS_KHR: number;
  27019. };
  27020. }
  27021. /** Interface defining initialization parameters for Engine class */
  27022. export interface EngineOptions extends WebGLContextAttributes {
  27023. /**
  27024. * Defines if the engine should no exceed a specified device ratio
  27025. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27026. */
  27027. limitDeviceRatio?: number;
  27028. /**
  27029. * Defines if webvr should be enabled automatically
  27030. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27031. */
  27032. autoEnableWebVR?: boolean;
  27033. /**
  27034. * Defines if webgl2 should be turned off even if supported
  27035. * @see http://doc.babylonjs.com/features/webgl2
  27036. */
  27037. disableWebGL2Support?: boolean;
  27038. /**
  27039. * Defines if webaudio should be initialized as well
  27040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27041. */
  27042. audioEngine?: boolean;
  27043. /**
  27044. * Defines if animations should run using a deterministic lock step
  27045. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27046. */
  27047. deterministicLockstep?: boolean;
  27048. /** Defines the maximum steps to use with deterministic lock step mode */
  27049. lockstepMaxSteps?: number;
  27050. /**
  27051. * Defines that engine should ignore context lost events
  27052. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27053. */
  27054. doNotHandleContextLost?: boolean;
  27055. /**
  27056. * Defines that engine should ignore modifying touch action attribute and style
  27057. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27058. */
  27059. doNotHandleTouchAction?: boolean;
  27060. /**
  27061. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27062. */
  27063. useHighPrecisionFloats?: boolean;
  27064. }
  27065. /**
  27066. * Defines the interface used by display changed events
  27067. */
  27068. export interface IDisplayChangedEventArgs {
  27069. /** Gets the vrDisplay object (if any) */
  27070. vrDisplay: Nullable<any>;
  27071. /** Gets a boolean indicating if webVR is supported */
  27072. vrSupported: boolean;
  27073. }
  27074. /**
  27075. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27076. */
  27077. export class Engine {
  27078. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27079. static ExceptionList: ({
  27080. key: string;
  27081. capture: string;
  27082. captureConstraint: number;
  27083. targets: string[];
  27084. } | {
  27085. key: string;
  27086. capture: null;
  27087. captureConstraint: null;
  27088. targets: string[];
  27089. })[];
  27090. /** Gets the list of created engines */
  27091. static readonly Instances: Engine[];
  27092. /**
  27093. * Gets the latest created engine
  27094. */
  27095. static readonly LastCreatedEngine: Nullable<Engine>;
  27096. /**
  27097. * Gets the latest created scene
  27098. */
  27099. static readonly LastCreatedScene: Nullable<Scene>;
  27100. /**
  27101. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27102. * @param flag defines which part of the materials must be marked as dirty
  27103. * @param predicate defines a predicate used to filter which materials should be affected
  27104. */
  27105. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27106. /**
  27107. * Hidden
  27108. */
  27109. static _TextureLoaders: IInternalTextureLoader[];
  27110. /** Defines that alpha blending is disabled */
  27111. static readonly ALPHA_DISABLE: number;
  27112. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27113. static readonly ALPHA_ADD: number;
  27114. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27115. static readonly ALPHA_COMBINE: number;
  27116. /** Defines that alpha blending to DEST - SRC * DEST */
  27117. static readonly ALPHA_SUBTRACT: number;
  27118. /** Defines that alpha blending to SRC * DEST */
  27119. static readonly ALPHA_MULTIPLY: number;
  27120. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27121. static readonly ALPHA_MAXIMIZED: number;
  27122. /** Defines that alpha blending to SRC + DEST */
  27123. static readonly ALPHA_ONEONE: number;
  27124. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27125. static readonly ALPHA_PREMULTIPLIED: number;
  27126. /**
  27127. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27128. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27129. */
  27130. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27131. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27132. static readonly ALPHA_INTERPOLATE: number;
  27133. /**
  27134. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27135. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27136. */
  27137. static readonly ALPHA_SCREENMODE: number;
  27138. /** Defines that the ressource is not delayed*/
  27139. static readonly DELAYLOADSTATE_NONE: number;
  27140. /** Defines that the ressource was successfully delay loaded */
  27141. static readonly DELAYLOADSTATE_LOADED: number;
  27142. /** Defines that the ressource is currently delay loading */
  27143. static readonly DELAYLOADSTATE_LOADING: number;
  27144. /** Defines that the ressource is delayed and has not started loading */
  27145. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27146. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27147. static readonly NEVER: number;
  27148. /** 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 */
  27149. static readonly ALWAYS: number;
  27150. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27151. static readonly LESS: number;
  27152. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27153. static readonly EQUAL: number;
  27154. /** 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 */
  27155. static readonly LEQUAL: number;
  27156. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27157. static readonly GREATER: number;
  27158. /** 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 */
  27159. static readonly GEQUAL: number;
  27160. /** 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 */
  27161. static readonly NOTEQUAL: number;
  27162. /** Passed to stencilOperation to specify that stencil value must be kept */
  27163. static readonly KEEP: number;
  27164. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27165. static readonly REPLACE: number;
  27166. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27167. static readonly INCR: number;
  27168. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27169. static readonly DECR: number;
  27170. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27171. static readonly INVERT: number;
  27172. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27173. static readonly INCR_WRAP: number;
  27174. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27175. static readonly DECR_WRAP: number;
  27176. /** Texture is not repeating outside of 0..1 UVs */
  27177. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27178. /** Texture is repeating outside of 0..1 UVs */
  27179. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27180. /** Texture is repeating and mirrored */
  27181. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27182. /** ALPHA */
  27183. static readonly TEXTUREFORMAT_ALPHA: number;
  27184. /** LUMINANCE */
  27185. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27186. /** LUMINANCE_ALPHA */
  27187. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27188. /** RGB */
  27189. static readonly TEXTUREFORMAT_RGB: number;
  27190. /** RGBA */
  27191. static readonly TEXTUREFORMAT_RGBA: number;
  27192. /** RED */
  27193. static readonly TEXTUREFORMAT_RED: number;
  27194. /** RED (2nd reference) */
  27195. static readonly TEXTUREFORMAT_R: number;
  27196. /** RG */
  27197. static readonly TEXTUREFORMAT_RG: number;
  27198. /** RED_INTEGER */
  27199. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27200. /** RED_INTEGER (2nd reference) */
  27201. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27202. /** RG_INTEGER */
  27203. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27204. /** RGB_INTEGER */
  27205. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27206. /** RGBA_INTEGER */
  27207. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27208. /** UNSIGNED_BYTE */
  27209. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27210. /** UNSIGNED_BYTE (2nd reference) */
  27211. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27212. /** FLOAT */
  27213. static readonly TEXTURETYPE_FLOAT: number;
  27214. /** HALF_FLOAT */
  27215. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27216. /** BYTE */
  27217. static readonly TEXTURETYPE_BYTE: number;
  27218. /** SHORT */
  27219. static readonly TEXTURETYPE_SHORT: number;
  27220. /** UNSIGNED_SHORT */
  27221. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27222. /** INT */
  27223. static readonly TEXTURETYPE_INT: number;
  27224. /** UNSIGNED_INT */
  27225. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27226. /** UNSIGNED_SHORT_4_4_4_4 */
  27227. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27228. /** UNSIGNED_SHORT_5_5_5_1 */
  27229. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27230. /** UNSIGNED_SHORT_5_6_5 */
  27231. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27232. /** UNSIGNED_INT_2_10_10_10_REV */
  27233. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27234. /** UNSIGNED_INT_24_8 */
  27235. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27236. /** UNSIGNED_INT_10F_11F_11F_REV */
  27237. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27238. /** UNSIGNED_INT_5_9_9_9_REV */
  27239. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27240. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27241. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27242. /** nearest is mag = nearest and min = nearest and mip = linear */
  27243. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27244. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27245. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27246. /** Trilinear is mag = linear and min = linear and mip = linear */
  27247. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27248. /** nearest is mag = nearest and min = nearest and mip = linear */
  27249. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27250. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27251. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27252. /** Trilinear is mag = linear and min = linear and mip = linear */
  27253. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27254. /** mag = nearest and min = nearest and mip = nearest */
  27255. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27256. /** mag = nearest and min = linear and mip = nearest */
  27257. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27258. /** mag = nearest and min = linear and mip = linear */
  27259. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27260. /** mag = nearest and min = linear and mip = none */
  27261. static readonly TEXTURE_NEAREST_LINEAR: number;
  27262. /** mag = nearest and min = nearest and mip = none */
  27263. static readonly TEXTURE_NEAREST_NEAREST: number;
  27264. /** mag = linear and min = nearest and mip = nearest */
  27265. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27266. /** mag = linear and min = nearest and mip = linear */
  27267. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27268. /** mag = linear and min = linear and mip = none */
  27269. static readonly TEXTURE_LINEAR_LINEAR: number;
  27270. /** mag = linear and min = nearest and mip = none */
  27271. static readonly TEXTURE_LINEAR_NEAREST: number;
  27272. /** Explicit coordinates mode */
  27273. static readonly TEXTURE_EXPLICIT_MODE: number;
  27274. /** Spherical coordinates mode */
  27275. static readonly TEXTURE_SPHERICAL_MODE: number;
  27276. /** Planar coordinates mode */
  27277. static readonly TEXTURE_PLANAR_MODE: number;
  27278. /** Cubic coordinates mode */
  27279. static readonly TEXTURE_CUBIC_MODE: number;
  27280. /** Projection coordinates mode */
  27281. static readonly TEXTURE_PROJECTION_MODE: number;
  27282. /** Skybox coordinates mode */
  27283. static readonly TEXTURE_SKYBOX_MODE: number;
  27284. /** Inverse Cubic coordinates mode */
  27285. static readonly TEXTURE_INVCUBIC_MODE: number;
  27286. /** Equirectangular coordinates mode */
  27287. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27288. /** Equirectangular Fixed coordinates mode */
  27289. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27290. /** Equirectangular Fixed Mirrored coordinates mode */
  27291. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27292. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27293. static readonly SCALEMODE_FLOOR: number;
  27294. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27295. static readonly SCALEMODE_NEAREST: number;
  27296. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27297. static readonly SCALEMODE_CEILING: number;
  27298. /**
  27299. * Returns the current npm package of the sdk
  27300. */
  27301. static readonly NpmPackage: string;
  27302. /**
  27303. * Returns the current version of the framework
  27304. */
  27305. static readonly Version: string;
  27306. /**
  27307. * Returns a string describing the current engine
  27308. */
  27309. readonly description: string;
  27310. /**
  27311. * Gets or sets the epsilon value used by collision engine
  27312. */
  27313. static CollisionsEpsilon: number;
  27314. /**
  27315. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27316. */
  27317. static ShadersRepository: string;
  27318. /**
  27319. * Method called to create the default loading screen.
  27320. * This can be overriden in your own app.
  27321. * @param canvas The rendering canvas element
  27322. * @returns The loading screen
  27323. */
  27324. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27325. /**
  27326. * Method called to create the default rescale post process on each engine.
  27327. */
  27328. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27329. /**
  27330. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27331. */
  27332. forcePOTTextures: boolean;
  27333. /**
  27334. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27335. */
  27336. isFullscreen: boolean;
  27337. /**
  27338. * Gets a boolean indicating if the pointer is currently locked
  27339. */
  27340. isPointerLock: boolean;
  27341. /**
  27342. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27343. */
  27344. cullBackFaces: boolean;
  27345. /**
  27346. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27347. */
  27348. renderEvenInBackground: boolean;
  27349. /**
  27350. * Gets or sets a boolean indicating that cache can be kept between frames
  27351. */
  27352. preventCacheWipeBetweenFrames: boolean;
  27353. /**
  27354. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27355. **/
  27356. enableOfflineSupport: boolean;
  27357. /**
  27358. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  27359. **/
  27360. disableManifestCheck: boolean;
  27361. /**
  27362. * Gets the list of created scenes
  27363. */
  27364. scenes: Scene[];
  27365. /**
  27366. * Event raised when a new scene is created
  27367. */
  27368. onNewSceneAddedObservable: Observable<Scene>;
  27369. /**
  27370. * Gets the list of created postprocesses
  27371. */
  27372. postProcesses: PostProcess[];
  27373. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27374. validateShaderPrograms: boolean;
  27375. /**
  27376. * Observable event triggered each time the rendering canvas is resized
  27377. */
  27378. onResizeObservable: Observable<Engine>;
  27379. /**
  27380. * Observable event triggered each time the canvas loses focus
  27381. */
  27382. onCanvasBlurObservable: Observable<Engine>;
  27383. /**
  27384. * Observable event triggered each time the canvas gains focus
  27385. */
  27386. onCanvasFocusObservable: Observable<Engine>;
  27387. /**
  27388. * Observable event triggered each time the canvas receives pointerout event
  27389. */
  27390. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27391. /**
  27392. * Observable event triggered before each texture is initialized
  27393. */
  27394. onBeforeTextureInitObservable: Observable<Texture>;
  27395. private _vrDisplay;
  27396. private _vrSupported;
  27397. private _oldSize;
  27398. private _oldHardwareScaleFactor;
  27399. private _vrExclusivePointerMode;
  27400. private _webVRInitPromise;
  27401. /**
  27402. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27403. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27404. */
  27405. readonly isInVRExclusivePointerMode: boolean;
  27406. /**
  27407. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27408. */
  27409. disableUniformBuffers: boolean;
  27410. /** @hidden */
  27411. _uniformBuffers: UniformBuffer[];
  27412. /**
  27413. * Gets a boolean indicating that the engine supports uniform buffers
  27414. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27415. */
  27416. readonly supportsUniformBuffers: boolean;
  27417. /**
  27418. * Observable raised when the engine begins a new frame
  27419. */
  27420. onBeginFrameObservable: Observable<Engine>;
  27421. /**
  27422. * If set, will be used to request the next animation frame for the render loop
  27423. */
  27424. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27425. /**
  27426. * Observable raised when the engine ends the current frame
  27427. */
  27428. onEndFrameObservable: Observable<Engine>;
  27429. /**
  27430. * Observable raised when the engine is about to compile a shader
  27431. */
  27432. onBeforeShaderCompilationObservable: Observable<Engine>;
  27433. /**
  27434. * Observable raised when the engine has jsut compiled a shader
  27435. */
  27436. onAfterShaderCompilationObservable: Observable<Engine>;
  27437. /** @hidden */
  27438. _gl: WebGLRenderingContext;
  27439. private _renderingCanvas;
  27440. private _windowIsBackground;
  27441. private _webGLVersion;
  27442. protected _highPrecisionShadersAllowed: boolean;
  27443. /** @hidden */
  27444. readonly _shouldUseHighPrecisionShader: boolean;
  27445. /**
  27446. * Gets a boolean indicating that only power of 2 textures are supported
  27447. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27448. */
  27449. readonly needPOTTextures: boolean;
  27450. /** @hidden */
  27451. _badOS: boolean;
  27452. /** @hidden */
  27453. _badDesktopOS: boolean;
  27454. /**
  27455. * Gets the audio engine
  27456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27457. * @ignorenaming
  27458. */
  27459. static audioEngine: IAudioEngine;
  27460. /**
  27461. * Default AudioEngine factory responsible of creating the Audio Engine.
  27462. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27463. */
  27464. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27465. /**
  27466. * Default offline support factory responsible of creating a tool used to store data locally.
  27467. * By default, this will create a Database object if the workload has been embedded.
  27468. */
  27469. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27470. private _onFocus;
  27471. private _onBlur;
  27472. private _onCanvasPointerOut;
  27473. private _onCanvasBlur;
  27474. private _onCanvasFocus;
  27475. private _onFullscreenChange;
  27476. private _onPointerLockChange;
  27477. private _onVRDisplayPointerRestricted;
  27478. private _onVRDisplayPointerUnrestricted;
  27479. private _onVrDisplayConnect;
  27480. private _onVrDisplayDisconnect;
  27481. private _onVrDisplayPresentChange;
  27482. /**
  27483. * Observable signaled when VR display mode changes
  27484. */
  27485. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27486. /**
  27487. * Observable signaled when VR request present is complete
  27488. */
  27489. onVRRequestPresentComplete: Observable<boolean>;
  27490. /**
  27491. * Observable signaled when VR request present starts
  27492. */
  27493. onVRRequestPresentStart: Observable<Engine>;
  27494. private _hardwareScalingLevel;
  27495. /** @hidden */
  27496. _caps: EngineCapabilities;
  27497. private _pointerLockRequested;
  27498. private _isStencilEnable;
  27499. private _colorWrite;
  27500. private _loadingScreen;
  27501. /** @hidden */
  27502. _drawCalls: PerfCounter;
  27503. private _glVersion;
  27504. private _glRenderer;
  27505. private _glVendor;
  27506. private _videoTextureSupported;
  27507. private _renderingQueueLaunched;
  27508. private _activeRenderLoops;
  27509. private _deterministicLockstep;
  27510. private _lockstepMaxSteps;
  27511. /**
  27512. * Observable signaled when a context lost event is raised
  27513. */
  27514. onContextLostObservable: Observable<Engine>;
  27515. /**
  27516. * Observable signaled when a context restored event is raised
  27517. */
  27518. onContextRestoredObservable: Observable<Engine>;
  27519. private _onContextLost;
  27520. private _onContextRestored;
  27521. private _contextWasLost;
  27522. /** @hidden */
  27523. _doNotHandleContextLost: boolean;
  27524. /**
  27525. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27526. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27527. */
  27528. doNotHandleContextLost: boolean;
  27529. private _performanceMonitor;
  27530. private _fps;
  27531. private _deltaTime;
  27532. /**
  27533. * Turn this value on if you want to pause FPS computation when in background
  27534. */
  27535. disablePerformanceMonitorInBackground: boolean;
  27536. /**
  27537. * Gets the performance monitor attached to this engine
  27538. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27539. */
  27540. readonly performanceMonitor: PerformanceMonitor;
  27541. /**
  27542. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27543. */
  27544. disableVertexArrayObjects: boolean;
  27545. /** @hidden */
  27546. protected _depthCullingState: _DepthCullingState;
  27547. /** @hidden */
  27548. protected _stencilState: _StencilState;
  27549. /** @hidden */
  27550. protected _alphaState: _AlphaState;
  27551. /** @hidden */
  27552. protected _alphaMode: number;
  27553. /** @hidden */
  27554. _internalTexturesCache: InternalTexture[];
  27555. /** @hidden */
  27556. protected _activeChannel: number;
  27557. private _currentTextureChannel;
  27558. /** @hidden */
  27559. protected _boundTexturesCache: {
  27560. [key: string]: Nullable<InternalTexture>;
  27561. };
  27562. /** @hidden */
  27563. protected _currentEffect: Nullable<Effect>;
  27564. /** @hidden */
  27565. protected _currentProgram: Nullable<WebGLProgram>;
  27566. private _compiledEffects;
  27567. private _vertexAttribArraysEnabled;
  27568. /** @hidden */
  27569. protected _cachedViewport: Nullable<Viewport>;
  27570. private _cachedVertexArrayObject;
  27571. /** @hidden */
  27572. protected _cachedVertexBuffers: any;
  27573. /** @hidden */
  27574. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27575. /** @hidden */
  27576. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27577. /** @hidden */
  27578. _currentRenderTarget: Nullable<InternalTexture>;
  27579. private _uintIndicesCurrentlySet;
  27580. private _currentBoundBuffer;
  27581. /** @hidden */
  27582. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27583. private _currentBufferPointers;
  27584. private _currentInstanceLocations;
  27585. private _currentInstanceBuffers;
  27586. private _textureUnits;
  27587. /** @hidden */
  27588. _workingCanvas: Nullable<HTMLCanvasElement>;
  27589. /** @hidden */
  27590. _workingContext: Nullable<CanvasRenderingContext2D>;
  27591. private _rescalePostProcess;
  27592. private _dummyFramebuffer;
  27593. private _externalData;
  27594. private _bindedRenderFunction;
  27595. private _vaoRecordInProgress;
  27596. private _mustWipeVertexAttributes;
  27597. private _emptyTexture;
  27598. private _emptyCubeTexture;
  27599. private _emptyTexture3D;
  27600. /** @hidden */
  27601. _frameHandler: number;
  27602. private _nextFreeTextureSlots;
  27603. private _maxSimultaneousTextures;
  27604. private _activeRequests;
  27605. private _texturesSupported;
  27606. /** @hidden */
  27607. _textureFormatInUse: Nullable<string>;
  27608. /**
  27609. * Gets the list of texture formats supported
  27610. */
  27611. readonly texturesSupported: Array<string>;
  27612. /**
  27613. * Gets the list of texture formats in use
  27614. */
  27615. readonly textureFormatInUse: Nullable<string>;
  27616. /**
  27617. * Gets the current viewport
  27618. */
  27619. readonly currentViewport: Nullable<Viewport>;
  27620. /**
  27621. * Gets the default empty texture
  27622. */
  27623. readonly emptyTexture: InternalTexture;
  27624. /**
  27625. * Gets the default empty 3D texture
  27626. */
  27627. readonly emptyTexture3D: InternalTexture;
  27628. /**
  27629. * Gets the default empty cube texture
  27630. */
  27631. readonly emptyCubeTexture: InternalTexture;
  27632. /**
  27633. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27634. */
  27635. readonly premultipliedAlpha: boolean;
  27636. /**
  27637. * Creates a new engine
  27638. * @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
  27639. * @param antialias defines enable antialiasing (default: false)
  27640. * @param options defines further options to be sent to the getContext() function
  27641. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27642. */
  27643. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27644. private _disableTouchAction;
  27645. private _rebuildInternalTextures;
  27646. private _rebuildEffects;
  27647. /**
  27648. * Gets a boolean indicating if all created effects are ready
  27649. * @returns true if all effects are ready
  27650. */
  27651. areAllEffectsReady(): boolean;
  27652. private _rebuildBuffers;
  27653. private _initGLContext;
  27654. /**
  27655. * Gets version of the current webGL context
  27656. */
  27657. readonly webGLVersion: number;
  27658. /**
  27659. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27660. */
  27661. readonly isStencilEnable: boolean;
  27662. /** @hidden */
  27663. _prepareWorkingCanvas(): void;
  27664. /**
  27665. * Reset the texture cache to empty state
  27666. */
  27667. resetTextureCache(): void;
  27668. /**
  27669. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27670. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27671. * @returns true if engine is in deterministic lock step mode
  27672. */
  27673. isDeterministicLockStep(): boolean;
  27674. /**
  27675. * Gets the max steps when engine is running in deterministic lock step
  27676. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27677. * @returns the max steps
  27678. */
  27679. getLockstepMaxSteps(): number;
  27680. /**
  27681. * Gets an object containing information about the current webGL context
  27682. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27683. */
  27684. getGlInfo(): {
  27685. vendor: string;
  27686. renderer: string;
  27687. version: string;
  27688. };
  27689. /**
  27690. * Gets current aspect ratio
  27691. * @param camera defines the camera to use to get the aspect ratio
  27692. * @param useScreen defines if screen size must be used (or the current render target if any)
  27693. * @returns a number defining the aspect ratio
  27694. */
  27695. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27696. /**
  27697. * Gets current screen aspect ratio
  27698. * @returns a number defining the aspect ratio
  27699. */
  27700. getScreenAspectRatio(): number;
  27701. /**
  27702. * Gets the current render width
  27703. * @param useScreen defines if screen size must be used (or the current render target if any)
  27704. * @returns a number defining the current render width
  27705. */
  27706. getRenderWidth(useScreen?: boolean): number;
  27707. /**
  27708. * Gets the current render height
  27709. * @param useScreen defines if screen size must be used (or the current render target if any)
  27710. * @returns a number defining the current render height
  27711. */
  27712. getRenderHeight(useScreen?: boolean): number;
  27713. /**
  27714. * Gets the HTML canvas attached with the current webGL context
  27715. * @returns a HTML canvas
  27716. */
  27717. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27718. /**
  27719. * Gets the client rect of the HTML canvas attached with the current webGL context
  27720. * @returns a client rectanglee
  27721. */
  27722. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27723. /**
  27724. * Defines the hardware scaling level.
  27725. * By default the hardware scaling level is computed from the window device ratio.
  27726. * 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.
  27727. * @param level defines the level to use
  27728. */
  27729. setHardwareScalingLevel(level: number): void;
  27730. /**
  27731. * Gets the current hardware scaling level.
  27732. * By default the hardware scaling level is computed from the window device ratio.
  27733. * 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.
  27734. * @returns a number indicating the current hardware scaling level
  27735. */
  27736. getHardwareScalingLevel(): number;
  27737. /**
  27738. * Gets the list of loaded textures
  27739. * @returns an array containing all loaded textures
  27740. */
  27741. getLoadedTexturesCache(): InternalTexture[];
  27742. /**
  27743. * Gets the object containing all engine capabilities
  27744. * @returns the EngineCapabilities object
  27745. */
  27746. getCaps(): EngineCapabilities;
  27747. /**
  27748. * Gets the current depth function
  27749. * @returns a number defining the depth function
  27750. */
  27751. getDepthFunction(): Nullable<number>;
  27752. /**
  27753. * Sets the current depth function
  27754. * @param depthFunc defines the function to use
  27755. */
  27756. setDepthFunction(depthFunc: number): void;
  27757. /**
  27758. * Sets the current depth function to GREATER
  27759. */
  27760. setDepthFunctionToGreater(): void;
  27761. /**
  27762. * Sets the current depth function to GEQUAL
  27763. */
  27764. setDepthFunctionToGreaterOrEqual(): void;
  27765. /**
  27766. * Sets the current depth function to LESS
  27767. */
  27768. setDepthFunctionToLess(): void;
  27769. private _cachedStencilBuffer;
  27770. private _cachedStencilFunction;
  27771. private _cachedStencilMask;
  27772. private _cachedStencilOperationPass;
  27773. private _cachedStencilOperationFail;
  27774. private _cachedStencilOperationDepthFail;
  27775. private _cachedStencilReference;
  27776. /**
  27777. * Caches the the state of the stencil buffer
  27778. */
  27779. cacheStencilState(): void;
  27780. /**
  27781. * Restores the state of the stencil buffer
  27782. */
  27783. restoreStencilState(): void;
  27784. /**
  27785. * Sets the current depth function to LEQUAL
  27786. */
  27787. setDepthFunctionToLessOrEqual(): void;
  27788. /**
  27789. * Gets a boolean indicating if stencil buffer is enabled
  27790. * @returns the current stencil buffer state
  27791. */
  27792. getStencilBuffer(): boolean;
  27793. /**
  27794. * Enable or disable the stencil buffer
  27795. * @param enable defines if the stencil buffer must be enabled or disabled
  27796. */
  27797. setStencilBuffer(enable: boolean): void;
  27798. /**
  27799. * Gets the current stencil mask
  27800. * @returns a number defining the new stencil mask to use
  27801. */
  27802. getStencilMask(): number;
  27803. /**
  27804. * Sets the current stencil mask
  27805. * @param mask defines the new stencil mask to use
  27806. */
  27807. setStencilMask(mask: number): void;
  27808. /**
  27809. * Gets the current stencil function
  27810. * @returns a number defining the stencil function to use
  27811. */
  27812. getStencilFunction(): number;
  27813. /**
  27814. * Gets the current stencil reference value
  27815. * @returns a number defining the stencil reference value to use
  27816. */
  27817. getStencilFunctionReference(): number;
  27818. /**
  27819. * Gets the current stencil mask
  27820. * @returns a number defining the stencil mask to use
  27821. */
  27822. getStencilFunctionMask(): number;
  27823. /**
  27824. * Sets the current stencil function
  27825. * @param stencilFunc defines the new stencil function to use
  27826. */
  27827. setStencilFunction(stencilFunc: number): void;
  27828. /**
  27829. * Sets the current stencil reference
  27830. * @param reference defines the new stencil reference to use
  27831. */
  27832. setStencilFunctionReference(reference: number): void;
  27833. /**
  27834. * Sets the current stencil mask
  27835. * @param mask defines the new stencil mask to use
  27836. */
  27837. setStencilFunctionMask(mask: number): void;
  27838. /**
  27839. * Gets the current stencil operation when stencil fails
  27840. * @returns a number defining stencil operation to use when stencil fails
  27841. */
  27842. getStencilOperationFail(): number;
  27843. /**
  27844. * Gets the current stencil operation when depth fails
  27845. * @returns a number defining stencil operation to use when depth fails
  27846. */
  27847. getStencilOperationDepthFail(): number;
  27848. /**
  27849. * Gets the current stencil operation when stencil passes
  27850. * @returns a number defining stencil operation to use when stencil passes
  27851. */
  27852. getStencilOperationPass(): number;
  27853. /**
  27854. * Sets the stencil operation to use when stencil fails
  27855. * @param operation defines the stencil operation to use when stencil fails
  27856. */
  27857. setStencilOperationFail(operation: number): void;
  27858. /**
  27859. * Sets the stencil operation to use when depth fails
  27860. * @param operation defines the stencil operation to use when depth fails
  27861. */
  27862. setStencilOperationDepthFail(operation: number): void;
  27863. /**
  27864. * Sets the stencil operation to use when stencil passes
  27865. * @param operation defines the stencil operation to use when stencil passes
  27866. */
  27867. setStencilOperationPass(operation: number): void;
  27868. /**
  27869. * Sets a boolean indicating if the dithering state is enabled or disabled
  27870. * @param value defines the dithering state
  27871. */
  27872. setDitheringState(value: boolean): void;
  27873. /**
  27874. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27875. * @param value defines the rasterizer state
  27876. */
  27877. setRasterizerState(value: boolean): void;
  27878. /**
  27879. * stop executing a render loop function and remove it from the execution array
  27880. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27881. */
  27882. stopRenderLoop(renderFunction?: () => void): void;
  27883. /** @hidden */
  27884. _renderLoop(): void;
  27885. /**
  27886. * Register and execute a render loop. The engine can have more than one render function
  27887. * @param renderFunction defines the function to continuously execute
  27888. */
  27889. runRenderLoop(renderFunction: () => void): void;
  27890. /**
  27891. * Toggle full screen mode
  27892. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27893. */
  27894. switchFullscreen(requestPointerLock: boolean): void;
  27895. /**
  27896. * Enters full screen mode
  27897. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27898. */
  27899. enterFullscreen(requestPointerLock: boolean): void;
  27900. /**
  27901. * Exits full screen mode
  27902. */
  27903. exitFullscreen(): void;
  27904. /**
  27905. * Clear the current render buffer or the current render target (if any is set up)
  27906. * @param color defines the color to use
  27907. * @param backBuffer defines if the back buffer must be cleared
  27908. * @param depth defines if the depth buffer must be cleared
  27909. * @param stencil defines if the stencil buffer must be cleared
  27910. */
  27911. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27912. /**
  27913. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27914. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27915. * @param y defines the y-coordinate of the corner of the clear rectangle
  27916. * @param width defines the width of the clear rectangle
  27917. * @param height defines the height of the clear rectangle
  27918. * @param clearColor defines the clear color
  27919. */
  27920. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27921. /**
  27922. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27923. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27924. * @param y defines the y-coordinate of the corner of the clear rectangle
  27925. * @param width defines the width of the clear rectangle
  27926. * @param height defines the height of the clear rectangle
  27927. */
  27928. enableScissor(x: number, y: number, width: number, height: number): void;
  27929. /**
  27930. * Disable previously set scissor test rectangle
  27931. */
  27932. disableScissor(): void;
  27933. private _viewportCached;
  27934. /** @hidden */
  27935. _viewport(x: number, y: number, width: number, height: number): void;
  27936. /**
  27937. * Set the WebGL's viewport
  27938. * @param viewport defines the viewport element to be used
  27939. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27940. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27941. */
  27942. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27943. /**
  27944. * Directly set the WebGL Viewport
  27945. * @param x defines the x coordinate of the viewport (in screen space)
  27946. * @param y defines the y coordinate of the viewport (in screen space)
  27947. * @param width defines the width of the viewport (in screen space)
  27948. * @param height defines the height of the viewport (in screen space)
  27949. * @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
  27950. */
  27951. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27952. /**
  27953. * Begin a new frame
  27954. */
  27955. beginFrame(): void;
  27956. /**
  27957. * Enf the current frame
  27958. */
  27959. endFrame(): void;
  27960. /**
  27961. * Resize the view according to the canvas' size
  27962. */
  27963. resize(): void;
  27964. /**
  27965. * Force a specific size of the canvas
  27966. * @param width defines the new canvas' width
  27967. * @param height defines the new canvas' height
  27968. */
  27969. setSize(width: number, height: number): void;
  27970. /**
  27971. * Gets a boolean indicating if a webVR device was detected
  27972. * @returns true if a webVR device was detected
  27973. */
  27974. isVRDevicePresent(): boolean;
  27975. /**
  27976. * Gets the current webVR device
  27977. * @returns the current webVR device (or null)
  27978. */
  27979. getVRDevice(): any;
  27980. /**
  27981. * Initializes a webVR display and starts listening to display change events
  27982. * The onVRDisplayChangedObservable will be notified upon these changes
  27983. * @returns The onVRDisplayChangedObservable
  27984. */
  27985. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27986. /**
  27987. * Initializes a webVR display and starts listening to display change events
  27988. * The onVRDisplayChangedObservable will be notified upon these changes
  27989. * @returns A promise containing a VRDisplay and if vr is supported
  27990. */
  27991. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27992. /**
  27993. * Call this function to switch to webVR mode
  27994. * Will do nothing if webVR is not supported or if there is no webVR device
  27995. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27996. */
  27997. enableVR(): void;
  27998. /**
  27999. * Call this function to leave webVR mode
  28000. * Will do nothing if webVR is not supported or if there is no webVR device
  28001. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28002. */
  28003. disableVR(): void;
  28004. private _onVRFullScreenTriggered;
  28005. private _getVRDisplaysAsync;
  28006. /**
  28007. * Binds the frame buffer to the specified texture.
  28008. * @param texture The texture to render to or null for the default canvas
  28009. * @param faceIndex The face of the texture to render to in case of cube texture
  28010. * @param requiredWidth The width of the target to render to
  28011. * @param requiredHeight The height of the target to render to
  28012. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28013. * @param depthStencilTexture The depth stencil texture to use to render
  28014. * @param lodLevel defines le lod level to bind to the frame buffer
  28015. */
  28016. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28017. /** @hidden */
  28018. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28019. /**
  28020. * Unbind the current render target texture from the webGL context
  28021. * @param texture defines the render target texture to unbind
  28022. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28023. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28024. */
  28025. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28026. /**
  28027. * Force the mipmap generation for the given render target texture
  28028. * @param texture defines the render target texture to use
  28029. */
  28030. generateMipMapsForCubemap(texture: InternalTexture): void;
  28031. /**
  28032. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28033. */
  28034. flushFramebuffer(): void;
  28035. /**
  28036. * Unbind the current render target and bind the default framebuffer
  28037. */
  28038. restoreDefaultFramebuffer(): void;
  28039. /**
  28040. * Create an uniform buffer
  28041. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28042. * @param elements defines the content of the uniform buffer
  28043. * @returns the webGL uniform buffer
  28044. */
  28045. createUniformBuffer(elements: FloatArray): DataBuffer;
  28046. /**
  28047. * Create a dynamic uniform buffer
  28048. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28049. * @param elements defines the content of the uniform buffer
  28050. * @returns the webGL uniform buffer
  28051. */
  28052. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28053. /**
  28054. * Update an existing uniform buffer
  28055. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28056. * @param uniformBuffer defines the target uniform buffer
  28057. * @param elements defines the content to update
  28058. * @param offset defines the offset in the uniform buffer where update should start
  28059. * @param count defines the size of the data to update
  28060. */
  28061. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28062. private _resetVertexBufferBinding;
  28063. /**
  28064. * Creates a vertex buffer
  28065. * @param data the data for the vertex buffer
  28066. * @returns the new WebGL static buffer
  28067. */
  28068. createVertexBuffer(data: DataArray): DataBuffer;
  28069. /**
  28070. * Creates a dynamic vertex buffer
  28071. * @param data the data for the dynamic vertex buffer
  28072. * @returns the new WebGL dynamic buffer
  28073. */
  28074. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28075. /**
  28076. * Update a dynamic index buffer
  28077. * @param indexBuffer defines the target index buffer
  28078. * @param indices defines the data to update
  28079. * @param offset defines the offset in the target index buffer where update should start
  28080. */
  28081. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28082. /**
  28083. * Updates a dynamic vertex buffer.
  28084. * @param vertexBuffer the vertex buffer to update
  28085. * @param data the data used to update the vertex buffer
  28086. * @param byteOffset the byte offset of the data
  28087. * @param byteLength the byte length of the data
  28088. */
  28089. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28090. private _resetIndexBufferBinding;
  28091. /**
  28092. * Creates a new index buffer
  28093. * @param indices defines the content of the index buffer
  28094. * @param updatable defines if the index buffer must be updatable
  28095. * @returns a new webGL buffer
  28096. */
  28097. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28098. /**
  28099. * Bind a webGL buffer to the webGL context
  28100. * @param buffer defines the buffer to bind
  28101. */
  28102. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28103. /**
  28104. * Bind an uniform buffer to the current webGL context
  28105. * @param buffer defines the buffer to bind
  28106. */
  28107. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28108. /**
  28109. * Bind a buffer to the current webGL context at a given location
  28110. * @param buffer defines the buffer to bind
  28111. * @param location defines the index where to bind the buffer
  28112. */
  28113. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28114. /**
  28115. * Bind a specific block at a given index in a specific shader program
  28116. * @param pipelineContext defines the pipeline context to use
  28117. * @param blockName defines the block name
  28118. * @param index defines the index where to bind the block
  28119. */
  28120. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28121. private bindIndexBuffer;
  28122. private bindBuffer;
  28123. /**
  28124. * update the bound buffer with the given data
  28125. * @param data defines the data to update
  28126. */
  28127. updateArrayBuffer(data: Float32Array): void;
  28128. private _vertexAttribPointer;
  28129. private _bindIndexBufferWithCache;
  28130. private _bindVertexBuffersAttributes;
  28131. /**
  28132. * Records a vertex array object
  28133. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28134. * @param vertexBuffers defines the list of vertex buffers to store
  28135. * @param indexBuffer defines the index buffer to store
  28136. * @param effect defines the effect to store
  28137. * @returns the new vertex array object
  28138. */
  28139. recordVertexArrayObject(vertexBuffers: {
  28140. [key: string]: VertexBuffer;
  28141. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28142. /**
  28143. * Bind a specific vertex array object
  28144. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28145. * @param vertexArrayObject defines the vertex array object to bind
  28146. * @param indexBuffer defines the index buffer to bind
  28147. */
  28148. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28149. /**
  28150. * Bind webGl buffers directly to the webGL context
  28151. * @param vertexBuffer defines the vertex buffer to bind
  28152. * @param indexBuffer defines the index buffer to bind
  28153. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28154. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28155. * @param effect defines the effect associated with the vertex buffer
  28156. */
  28157. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28158. private _unbindVertexArrayObject;
  28159. /**
  28160. * Bind a list of vertex buffers to the webGL context
  28161. * @param vertexBuffers defines the list of vertex buffers to bind
  28162. * @param indexBuffer defines the index buffer to bind
  28163. * @param effect defines the effect associated with the vertex buffers
  28164. */
  28165. bindBuffers(vertexBuffers: {
  28166. [key: string]: Nullable<VertexBuffer>;
  28167. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28168. /**
  28169. * Unbind all instance attributes
  28170. */
  28171. unbindInstanceAttributes(): void;
  28172. /**
  28173. * Release and free the memory of a vertex array object
  28174. * @param vao defines the vertex array object to delete
  28175. */
  28176. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28177. /** @hidden */
  28178. _releaseBuffer(buffer: DataBuffer): boolean;
  28179. /**
  28180. * Creates a webGL buffer to use with instanciation
  28181. * @param capacity defines the size of the buffer
  28182. * @returns the webGL buffer
  28183. */
  28184. createInstancesBuffer(capacity: number): DataBuffer;
  28185. /**
  28186. * Delete a webGL buffer used with instanciation
  28187. * @param buffer defines the webGL buffer to delete
  28188. */
  28189. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28190. /**
  28191. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28192. * @param instancesBuffer defines the webGL buffer to update and bind
  28193. * @param data defines the data to store in the buffer
  28194. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28195. */
  28196. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28197. /**
  28198. * Apply all cached states (depth, culling, stencil and alpha)
  28199. */
  28200. applyStates(): void;
  28201. /**
  28202. * Send a draw order
  28203. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28204. * @param indexStart defines the starting index
  28205. * @param indexCount defines the number of index to draw
  28206. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28207. */
  28208. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28209. /**
  28210. * Draw a list of points
  28211. * @param verticesStart defines the index of first vertex to draw
  28212. * @param verticesCount defines the count of vertices to draw
  28213. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28214. */
  28215. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28216. /**
  28217. * Draw a list of unindexed primitives
  28218. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28219. * @param verticesStart defines the index of first vertex to draw
  28220. * @param verticesCount defines the count of vertices to draw
  28221. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28222. */
  28223. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28224. /**
  28225. * Draw a list of indexed primitives
  28226. * @param fillMode defines the primitive to use
  28227. * @param indexStart defines the starting index
  28228. * @param indexCount defines the number of index to draw
  28229. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28230. */
  28231. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28232. /**
  28233. * Draw a list of unindexed primitives
  28234. * @param fillMode defines the primitive to use
  28235. * @param verticesStart defines the index of first vertex to draw
  28236. * @param verticesCount defines the count of vertices to draw
  28237. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28238. */
  28239. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28240. private _drawMode;
  28241. /** @hidden */
  28242. _releaseEffect(effect: Effect): void;
  28243. /** @hidden */
  28244. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28245. /**
  28246. * Create a new effect (used to store vertex/fragment shaders)
  28247. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28248. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28249. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28250. * @param samplers defines an array of string used to represent textures
  28251. * @param defines defines the string containing the defines to use to compile the shaders
  28252. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28253. * @param onCompiled defines a function to call when the effect creation is successful
  28254. * @param onError defines a function to call when the effect creation has failed
  28255. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28256. * @returns the new Effect
  28257. */
  28258. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  28259. private _compileShader;
  28260. private _compileRawShader;
  28261. /**
  28262. * Directly creates a webGL program
  28263. * @param pipelineContext defines the pipeline context to attach to
  28264. * @param vertexCode defines the vertex shader code to use
  28265. * @param fragmentCode defines the fragment shader code to use
  28266. * @param context defines the webGL context to use (if not set, the current one will be used)
  28267. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28268. * @returns the new webGL program
  28269. */
  28270. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28271. /**
  28272. * Creates a webGL program
  28273. * @param pipelineContext defines the pipeline context to attach to
  28274. * @param vertexCode defines the vertex shader code to use
  28275. * @param fragmentCode defines the fragment shader code to use
  28276. * @param defines defines the string containing the defines to use to compile the shaders
  28277. * @param context defines the webGL context to use (if not set, the current one will be used)
  28278. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28279. * @returns the new webGL program
  28280. */
  28281. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28282. /**
  28283. * Creates a new pipeline context
  28284. * @returns the new pipeline
  28285. */
  28286. createPipelineContext(): WebGLPipelineContext;
  28287. private _createShaderProgram;
  28288. private _finalizePipelineContext;
  28289. /** @hidden */
  28290. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28291. /** @hidden */
  28292. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28293. /** @hidden */
  28294. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28295. /**
  28296. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28297. * @param pipelineContext defines the pipeline context to use
  28298. * @param uniformsNames defines the list of uniform names
  28299. * @returns an array of webGL uniform locations
  28300. */
  28301. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28302. /**
  28303. * Gets the lsit of active attributes for a given webGL program
  28304. * @param pipelineContext defines the pipeline context to use
  28305. * @param attributesNames defines the list of attribute names to get
  28306. * @returns an array of indices indicating the offset of each attribute
  28307. */
  28308. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28309. /**
  28310. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28311. * @param effect defines the effect to activate
  28312. */
  28313. enableEffect(effect: Nullable<Effect>): void;
  28314. /**
  28315. * Set the value of an uniform to an array of int32
  28316. * @param uniform defines the webGL uniform location where to store the value
  28317. * @param array defines the array of int32 to store
  28318. */
  28319. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28320. /**
  28321. * Set the value of an uniform to an array of int32 (stored as vec2)
  28322. * @param uniform defines the webGL uniform location where to store the value
  28323. * @param array defines the array of int32 to store
  28324. */
  28325. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28326. /**
  28327. * Set the value of an uniform to an array of int32 (stored as vec3)
  28328. * @param uniform defines the webGL uniform location where to store the value
  28329. * @param array defines the array of int32 to store
  28330. */
  28331. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28332. /**
  28333. * Set the value of an uniform to an array of int32 (stored as vec4)
  28334. * @param uniform defines the webGL uniform location where to store the value
  28335. * @param array defines the array of int32 to store
  28336. */
  28337. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28338. /**
  28339. * Set the value of an uniform to an array of float32
  28340. * @param uniform defines the webGL uniform location where to store the value
  28341. * @param array defines the array of float32 to store
  28342. */
  28343. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28344. /**
  28345. * Set the value of an uniform to an array of float32 (stored as vec2)
  28346. * @param uniform defines the webGL uniform location where to store the value
  28347. * @param array defines the array of float32 to store
  28348. */
  28349. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28350. /**
  28351. * Set the value of an uniform to an array of float32 (stored as vec3)
  28352. * @param uniform defines the webGL uniform location where to store the value
  28353. * @param array defines the array of float32 to store
  28354. */
  28355. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28356. /**
  28357. * Set the value of an uniform to an array of float32 (stored as vec4)
  28358. * @param uniform defines the webGL uniform location where to store the value
  28359. * @param array defines the array of float32 to store
  28360. */
  28361. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28362. /**
  28363. * Set the value of an uniform to an array of number
  28364. * @param uniform defines the webGL uniform location where to store the value
  28365. * @param array defines the array of number to store
  28366. */
  28367. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28368. /**
  28369. * Set the value of an uniform to an array of number (stored as vec2)
  28370. * @param uniform defines the webGL uniform location where to store the value
  28371. * @param array defines the array of number to store
  28372. */
  28373. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28374. /**
  28375. * Set the value of an uniform to an array of number (stored as vec3)
  28376. * @param uniform defines the webGL uniform location where to store the value
  28377. * @param array defines the array of number to store
  28378. */
  28379. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28380. /**
  28381. * Set the value of an uniform to an array of number (stored as vec4)
  28382. * @param uniform defines the webGL uniform location where to store the value
  28383. * @param array defines the array of number to store
  28384. */
  28385. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28386. /**
  28387. * Set the value of an uniform to an array of float32 (stored as matrices)
  28388. * @param uniform defines the webGL uniform location where to store the value
  28389. * @param matrices defines the array of float32 to store
  28390. */
  28391. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28392. /**
  28393. * Set the value of an uniform to a matrix
  28394. * @param uniform defines the webGL uniform location where to store the value
  28395. * @param matrix defines the matrix to store
  28396. */
  28397. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28398. /**
  28399. * Set the value of an uniform to a matrix (3x3)
  28400. * @param uniform defines the webGL uniform location where to store the value
  28401. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28402. */
  28403. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28404. /**
  28405. * Set the value of an uniform to a matrix (2x2)
  28406. * @param uniform defines the webGL uniform location where to store the value
  28407. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28408. */
  28409. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28410. /**
  28411. * Set the value of an uniform to a number (int)
  28412. * @param uniform defines the webGL uniform location where to store the value
  28413. * @param value defines the int number to store
  28414. */
  28415. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28416. /**
  28417. * Set the value of an uniform to a number (float)
  28418. * @param uniform defines the webGL uniform location where to store the value
  28419. * @param value defines the float number to store
  28420. */
  28421. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28422. /**
  28423. * Set the value of an uniform to a vec2
  28424. * @param uniform defines the webGL uniform location where to store the value
  28425. * @param x defines the 1st component of the value
  28426. * @param y defines the 2nd component of the value
  28427. */
  28428. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28429. /**
  28430. * Set the value of an uniform to a vec3
  28431. * @param uniform defines the webGL uniform location where to store the value
  28432. * @param x defines the 1st component of the value
  28433. * @param y defines the 2nd component of the value
  28434. * @param z defines the 3rd component of the value
  28435. */
  28436. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28437. /**
  28438. * Set the value of an uniform to a boolean
  28439. * @param uniform defines the webGL uniform location where to store the value
  28440. * @param bool defines the boolean to store
  28441. */
  28442. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28443. /**
  28444. * Set the value of an uniform to a vec4
  28445. * @param uniform defines the webGL uniform location where to store the value
  28446. * @param x defines the 1st component of the value
  28447. * @param y defines the 2nd component of the value
  28448. * @param z defines the 3rd component of the value
  28449. * @param w defines the 4th component of the value
  28450. */
  28451. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28452. /**
  28453. * Set the value of an uniform to a Color3
  28454. * @param uniform defines the webGL uniform location where to store the value
  28455. * @param color3 defines the color to store
  28456. */
  28457. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28458. /**
  28459. * Set the value of an uniform to a Color3 and an alpha value
  28460. * @param uniform defines the webGL uniform location where to store the value
  28461. * @param color3 defines the color to store
  28462. * @param alpha defines the alpha component to store
  28463. */
  28464. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28465. /**
  28466. * Sets a Color4 on a uniform variable
  28467. * @param uniform defines the uniform location
  28468. * @param color4 defines the value to be set
  28469. */
  28470. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28471. /**
  28472. * Set various states to the webGL context
  28473. * @param culling defines backface culling state
  28474. * @param zOffset defines the value to apply to zOffset (0 by default)
  28475. * @param force defines if states must be applied even if cache is up to date
  28476. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28477. */
  28478. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28479. /**
  28480. * Set the z offset to apply to current rendering
  28481. * @param value defines the offset to apply
  28482. */
  28483. setZOffset(value: number): void;
  28484. /**
  28485. * Gets the current value of the zOffset
  28486. * @returns the current zOffset state
  28487. */
  28488. getZOffset(): number;
  28489. /**
  28490. * Enable or disable depth buffering
  28491. * @param enable defines the state to set
  28492. */
  28493. setDepthBuffer(enable: boolean): void;
  28494. /**
  28495. * Gets a boolean indicating if depth writing is enabled
  28496. * @returns the current depth writing state
  28497. */
  28498. getDepthWrite(): boolean;
  28499. /**
  28500. * Enable or disable depth writing
  28501. * @param enable defines the state to set
  28502. */
  28503. setDepthWrite(enable: boolean): void;
  28504. /**
  28505. * Enable or disable color writing
  28506. * @param enable defines the state to set
  28507. */
  28508. setColorWrite(enable: boolean): void;
  28509. /**
  28510. * Gets a boolean indicating if color writing is enabled
  28511. * @returns the current color writing state
  28512. */
  28513. getColorWrite(): boolean;
  28514. /**
  28515. * Sets alpha constants used by some alpha blending modes
  28516. * @param r defines the red component
  28517. * @param g defines the green component
  28518. * @param b defines the blue component
  28519. * @param a defines the alpha component
  28520. */
  28521. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28522. /**
  28523. * Sets the current alpha mode
  28524. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28525. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28526. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28527. */
  28528. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28529. /**
  28530. * Gets the current alpha mode
  28531. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28532. * @returns the current alpha mode
  28533. */
  28534. getAlphaMode(): number;
  28535. /**
  28536. * Clears the list of texture accessible through engine.
  28537. * This can help preventing texture load conflict due to name collision.
  28538. */
  28539. clearInternalTexturesCache(): void;
  28540. /**
  28541. * Force the entire cache to be cleared
  28542. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28543. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28544. */
  28545. wipeCaches(bruteForce?: boolean): void;
  28546. /**
  28547. * Set the compressed texture format to use, based on the formats you have, and the formats
  28548. * supported by the hardware / browser.
  28549. *
  28550. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28551. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28552. * to API arguments needed to compressed textures. This puts the burden on the container
  28553. * generator to house the arcane code for determining these for current & future formats.
  28554. *
  28555. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28556. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28557. *
  28558. * Note: The result of this call is not taken into account when a texture is base64.
  28559. *
  28560. * @param formatsAvailable defines the list of those format families you have created
  28561. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28562. *
  28563. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28564. * @returns The extension selected.
  28565. */
  28566. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28567. /** @hidden */
  28568. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28569. min: number;
  28570. mag: number;
  28571. };
  28572. /** @hidden */
  28573. _createTexture(): WebGLTexture;
  28574. /**
  28575. * Usually called from Texture.ts.
  28576. * Passed information to create a WebGLTexture
  28577. * @param urlArg defines a value which contains one of the following:
  28578. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28579. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28580. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28581. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28582. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  28583. * @param scene needed for loading to the correct scene
  28584. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28585. * @param onLoad optional callback to be called upon successful completion
  28586. * @param onError optional callback to be called upon failure
  28587. * @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
  28588. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28589. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28590. * @param forcedExtension defines the extension to use to pick the right loader
  28591. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28592. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28593. */
  28594. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28595. private _rescaleTexture;
  28596. private _unpackFlipYCached;
  28597. /**
  28598. * In case you are sharing the context with other applications, it might
  28599. * be interested to not cache the unpack flip y state to ensure a consistent
  28600. * value would be set.
  28601. */
  28602. enableUnpackFlipYCached: boolean;
  28603. /** @hidden */
  28604. _unpackFlipY(value: boolean): void;
  28605. /** @hidden */
  28606. _getUnpackAlignement(): number;
  28607. /**
  28608. * Creates a dynamic texture
  28609. * @param width defines the width of the texture
  28610. * @param height defines the height of the texture
  28611. * @param generateMipMaps defines if the engine should generate the mip levels
  28612. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28613. * @returns the dynamic texture inside an InternalTexture
  28614. */
  28615. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28616. /**
  28617. * Update the sampling mode of a given texture
  28618. * @param samplingMode defines the required sampling mode
  28619. * @param texture defines the texture to update
  28620. */
  28621. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28622. /**
  28623. * Update the content of a dynamic texture
  28624. * @param texture defines the texture to update
  28625. * @param canvas defines the canvas containing the source
  28626. * @param invertY defines if data must be stored with Y axis inverted
  28627. * @param premulAlpha defines if alpha is stored as premultiplied
  28628. * @param format defines the format of the data
  28629. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28630. */
  28631. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28632. /**
  28633. * Update a video texture
  28634. * @param texture defines the texture to update
  28635. * @param video defines the video element to use
  28636. * @param invertY defines if data must be stored with Y axis inverted
  28637. */
  28638. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28639. /**
  28640. * Updates a depth texture Comparison Mode and Function.
  28641. * If the comparison Function is equal to 0, the mode will be set to none.
  28642. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28643. * @param texture The texture to set the comparison function for
  28644. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28645. */
  28646. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28647. /** @hidden */
  28648. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28649. width: number;
  28650. height: number;
  28651. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28652. /**
  28653. * Creates a depth stencil texture.
  28654. * This is only available in WebGL 2 or with the depth texture extension available.
  28655. * @param size The size of face edge in the texture.
  28656. * @param options The options defining the texture.
  28657. * @returns The texture
  28658. */
  28659. createDepthStencilTexture(size: number | {
  28660. width: number;
  28661. height: number;
  28662. }, options: DepthTextureCreationOptions): InternalTexture;
  28663. /**
  28664. * Creates a depth stencil texture.
  28665. * This is only available in WebGL 2 or with the depth texture extension available.
  28666. * @param size The size of face edge in the texture.
  28667. * @param options The options defining the texture.
  28668. * @returns The texture
  28669. */
  28670. private _createDepthStencilTexture;
  28671. /**
  28672. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28673. * @param renderTarget The render target to set the frame buffer for
  28674. */
  28675. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28676. /**
  28677. * Creates a new render target texture
  28678. * @param size defines the size of the texture
  28679. * @param options defines the options used to create the texture
  28680. * @returns a new render target texture stored in an InternalTexture
  28681. */
  28682. createRenderTargetTexture(size: number | {
  28683. width: number;
  28684. height: number;
  28685. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28686. /** @hidden */
  28687. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28688. /**
  28689. * Updates the sample count of a render target texture
  28690. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28691. * @param texture defines the texture to update
  28692. * @param samples defines the sample count to set
  28693. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28694. */
  28695. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28696. /** @hidden */
  28697. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28698. /** @hidden */
  28699. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28700. /** @hidden */
  28701. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28702. /** @hidden */
  28703. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28704. /**
  28705. * @hidden
  28706. */
  28707. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28708. private _prepareWebGLTextureContinuation;
  28709. private _prepareWebGLTexture;
  28710. /** @hidden */
  28711. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28712. /** @hidden */
  28713. _releaseFramebufferObjects(texture: InternalTexture): void;
  28714. /** @hidden */
  28715. _releaseTexture(texture: InternalTexture): void;
  28716. private setProgram;
  28717. private _boundUniforms;
  28718. /**
  28719. * Binds an effect to the webGL context
  28720. * @param effect defines the effect to bind
  28721. */
  28722. bindSamplers(effect: Effect): void;
  28723. private _activateCurrentTexture;
  28724. /** @hidden */
  28725. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28726. /** @hidden */
  28727. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28728. /**
  28729. * Sets a texture to the webGL context from a postprocess
  28730. * @param channel defines the channel to use
  28731. * @param postProcess defines the source postprocess
  28732. */
  28733. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28734. /**
  28735. * Binds the output of the passed in post process to the texture channel specified
  28736. * @param channel The channel the texture should be bound to
  28737. * @param postProcess The post process which's output should be bound
  28738. */
  28739. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28740. /**
  28741. * Unbind all textures from the webGL context
  28742. */
  28743. unbindAllTextures(): void;
  28744. /**
  28745. * Sets a texture to the according uniform.
  28746. * @param channel The texture channel
  28747. * @param uniform The uniform to set
  28748. * @param texture The texture to apply
  28749. */
  28750. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28751. /**
  28752. * Sets a depth stencil texture from a render target to the according uniform.
  28753. * @param channel The texture channel
  28754. * @param uniform The uniform to set
  28755. * @param texture The render target texture containing the depth stencil texture to apply
  28756. */
  28757. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28758. private _bindSamplerUniformToChannel;
  28759. private _getTextureWrapMode;
  28760. private _setTexture;
  28761. /**
  28762. * Sets an array of texture to the webGL context
  28763. * @param channel defines the channel where the texture array must be set
  28764. * @param uniform defines the associated uniform location
  28765. * @param textures defines the array of textures to bind
  28766. */
  28767. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28768. /** @hidden */
  28769. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28770. private _setTextureParameterFloat;
  28771. private _setTextureParameterInteger;
  28772. /**
  28773. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28774. * @param x defines the x coordinate of the rectangle where pixels must be read
  28775. * @param y defines the y coordinate of the rectangle where pixels must be read
  28776. * @param width defines the width of the rectangle where pixels must be read
  28777. * @param height defines the height of the rectangle where pixels must be read
  28778. * @returns a Uint8Array containing RGBA colors
  28779. */
  28780. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28781. /**
  28782. * Add an externaly attached data from its key.
  28783. * This method call will fail and return false, if such key already exists.
  28784. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28785. * @param key the unique key that identifies the data
  28786. * @param data the data object to associate to the key for this Engine instance
  28787. * @return true if no such key were already present and the data was added successfully, false otherwise
  28788. */
  28789. addExternalData<T>(key: string, data: T): boolean;
  28790. /**
  28791. * Get an externaly attached data from its key
  28792. * @param key the unique key that identifies the data
  28793. * @return the associated data, if present (can be null), or undefined if not present
  28794. */
  28795. getExternalData<T>(key: string): T;
  28796. /**
  28797. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28798. * @param key the unique key that identifies the data
  28799. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28800. * @return the associated data, can be null if the factory returned null.
  28801. */
  28802. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28803. /**
  28804. * Remove an externaly attached data from the Engine instance
  28805. * @param key the unique key that identifies the data
  28806. * @return true if the data was successfully removed, false if it doesn't exist
  28807. */
  28808. removeExternalData(key: string): boolean;
  28809. /**
  28810. * Unbind all vertex attributes from the webGL context
  28811. */
  28812. unbindAllAttributes(): void;
  28813. /**
  28814. * 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
  28815. */
  28816. releaseEffects(): void;
  28817. /**
  28818. * Dispose and release all associated resources
  28819. */
  28820. dispose(): void;
  28821. /**
  28822. * Display the loading screen
  28823. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28824. */
  28825. displayLoadingUI(): void;
  28826. /**
  28827. * Hide the loading screen
  28828. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28829. */
  28830. hideLoadingUI(): void;
  28831. /**
  28832. * Gets the current loading screen object
  28833. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28834. */
  28835. /**
  28836. * Sets the current loading screen object
  28837. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28838. */
  28839. loadingScreen: ILoadingScreen;
  28840. /**
  28841. * Sets the current loading screen text
  28842. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28843. */
  28844. loadingUIText: string;
  28845. /**
  28846. * Sets the current loading screen background color
  28847. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28848. */
  28849. loadingUIBackgroundColor: string;
  28850. /**
  28851. * Attach a new callback raised when context lost event is fired
  28852. * @param callback defines the callback to call
  28853. */
  28854. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28855. /**
  28856. * Attach a new callback raised when context restored event is fired
  28857. * @param callback defines the callback to call
  28858. */
  28859. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28860. /**
  28861. * Gets the source code of the vertex shader associated with a specific webGL program
  28862. * @param program defines the program to use
  28863. * @returns a string containing the source code of the vertex shader associated with the program
  28864. */
  28865. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28866. /**
  28867. * Gets the source code of the fragment shader associated with a specific webGL program
  28868. * @param program defines the program to use
  28869. * @returns a string containing the source code of the fragment shader associated with the program
  28870. */
  28871. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28872. /**
  28873. * Get the current error code of the webGL context
  28874. * @returns the error code
  28875. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28876. */
  28877. getError(): number;
  28878. /**
  28879. * Gets the current framerate
  28880. * @returns a number representing the framerate
  28881. */
  28882. getFps(): number;
  28883. /**
  28884. * Gets the time spent between current and previous frame
  28885. * @returns a number representing the delta time in ms
  28886. */
  28887. getDeltaTime(): number;
  28888. private _measureFps;
  28889. /** @hidden */
  28890. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28891. private _canRenderToFloatFramebuffer;
  28892. private _canRenderToHalfFloatFramebuffer;
  28893. private _canRenderToFramebuffer;
  28894. /** @hidden */
  28895. _getWebGLTextureType(type: number): number;
  28896. /** @hidden */
  28897. _getInternalFormat(format: number): number;
  28898. /** @hidden */
  28899. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28900. /** @hidden */
  28901. _getRGBAMultiSampleBufferFormat(type: number): number;
  28902. /** @hidden */
  28903. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  28904. /** @hidden */
  28905. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28906. /**
  28907. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28908. * @returns true if the engine can be created
  28909. * @ignorenaming
  28910. */
  28911. static isSupported(): boolean;
  28912. }
  28913. }
  28914. declare module BABYLON {
  28915. /**
  28916. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28917. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28918. */
  28919. export class EffectFallbacks {
  28920. private _defines;
  28921. private _currentRank;
  28922. private _maxRank;
  28923. private _mesh;
  28924. /**
  28925. * Removes the fallback from the bound mesh.
  28926. */
  28927. unBindMesh(): void;
  28928. /**
  28929. * Adds a fallback on the specified property.
  28930. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28931. * @param define The name of the define in the shader
  28932. */
  28933. addFallback(rank: number, define: string): void;
  28934. /**
  28935. * Sets the mesh to use CPU skinning when needing to fallback.
  28936. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28937. * @param mesh The mesh to use the fallbacks.
  28938. */
  28939. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28940. /**
  28941. * Checks to see if more fallbacks are still availible.
  28942. */
  28943. readonly isMoreFallbacks: boolean;
  28944. /**
  28945. * Removes the defines that shoould be removed when falling back.
  28946. * @param currentDefines defines the current define statements for the shader.
  28947. * @param effect defines the current effect we try to compile
  28948. * @returns The resulting defines with defines of the current rank removed.
  28949. */
  28950. reduce(currentDefines: string, effect: Effect): string;
  28951. }
  28952. /**
  28953. * Options to be used when creating an effect.
  28954. */
  28955. export class EffectCreationOptions {
  28956. /**
  28957. * Atrributes that will be used in the shader.
  28958. */
  28959. attributes: string[];
  28960. /**
  28961. * Uniform varible names that will be set in the shader.
  28962. */
  28963. uniformsNames: string[];
  28964. /**
  28965. * Uniform buffer varible names that will be set in the shader.
  28966. */
  28967. uniformBuffersNames: string[];
  28968. /**
  28969. * Sampler texture variable names that will be set in the shader.
  28970. */
  28971. samplers: string[];
  28972. /**
  28973. * Define statements that will be set in the shader.
  28974. */
  28975. defines: any;
  28976. /**
  28977. * Possible fallbacks for this effect to improve performance when needed.
  28978. */
  28979. fallbacks: Nullable<EffectFallbacks>;
  28980. /**
  28981. * Callback that will be called when the shader is compiled.
  28982. */
  28983. onCompiled: Nullable<(effect: Effect) => void>;
  28984. /**
  28985. * Callback that will be called if an error occurs during shader compilation.
  28986. */
  28987. onError: Nullable<(effect: Effect, errors: string) => void>;
  28988. /**
  28989. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28990. */
  28991. indexParameters: any;
  28992. /**
  28993. * Max number of lights that can be used in the shader.
  28994. */
  28995. maxSimultaneousLights: number;
  28996. /**
  28997. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28998. */
  28999. transformFeedbackVaryings: Nullable<string[]>;
  29000. }
  29001. /**
  29002. * Effect containing vertex and fragment shader that can be executed on an object.
  29003. */
  29004. export class Effect implements IDisposable {
  29005. /**
  29006. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29007. */
  29008. static ShadersRepository: string;
  29009. /**
  29010. * Name of the effect.
  29011. */
  29012. name: any;
  29013. /**
  29014. * String container all the define statements that should be set on the shader.
  29015. */
  29016. defines: string;
  29017. /**
  29018. * Callback that will be called when the shader is compiled.
  29019. */
  29020. onCompiled: Nullable<(effect: Effect) => void>;
  29021. /**
  29022. * Callback that will be called if an error occurs during shader compilation.
  29023. */
  29024. onError: Nullable<(effect: Effect, errors: string) => void>;
  29025. /**
  29026. * Callback that will be called when effect is bound.
  29027. */
  29028. onBind: Nullable<(effect: Effect) => void>;
  29029. /**
  29030. * Unique ID of the effect.
  29031. */
  29032. uniqueId: number;
  29033. /**
  29034. * Observable that will be called when the shader is compiled.
  29035. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29036. */
  29037. onCompileObservable: Observable<Effect>;
  29038. /**
  29039. * Observable that will be called if an error occurs during shader compilation.
  29040. */
  29041. onErrorObservable: Observable<Effect>;
  29042. /** @hidden */
  29043. _onBindObservable: Nullable<Observable<Effect>>;
  29044. /**
  29045. * Observable that will be called when effect is bound.
  29046. */
  29047. readonly onBindObservable: Observable<Effect>;
  29048. /** @hidden */
  29049. _bonesComputationForcedToCPU: boolean;
  29050. private static _uniqueIdSeed;
  29051. private _engine;
  29052. private _uniformBuffersNames;
  29053. private _uniformsNames;
  29054. private _samplerList;
  29055. private _samplers;
  29056. private _isReady;
  29057. private _compilationError;
  29058. private _attributesNames;
  29059. private _attributes;
  29060. private _uniforms;
  29061. /**
  29062. * Key for the effect.
  29063. * @hidden
  29064. */
  29065. _key: string;
  29066. private _indexParameters;
  29067. private _fallbacks;
  29068. private _vertexSourceCode;
  29069. private _fragmentSourceCode;
  29070. private _vertexSourceCodeOverride;
  29071. private _fragmentSourceCodeOverride;
  29072. private _transformFeedbackVaryings;
  29073. /**
  29074. * Compiled shader to webGL program.
  29075. * @hidden
  29076. */
  29077. _pipelineContext: IPipelineContext;
  29078. private _valueCache;
  29079. private static _baseCache;
  29080. /**
  29081. * Instantiates an effect.
  29082. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29083. * @param baseName Name of the effect.
  29084. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29085. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29086. * @param samplers List of sampler variables that will be passed to the shader.
  29087. * @param engine Engine to be used to render the effect
  29088. * @param defines Define statements to be added to the shader.
  29089. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29090. * @param onCompiled Callback that will be called when the shader is compiled.
  29091. * @param onError Callback that will be called if an error occurs during shader compilation.
  29092. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29093. */
  29094. 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);
  29095. /**
  29096. * Unique key for this effect
  29097. */
  29098. readonly key: string;
  29099. /**
  29100. * If the effect has been compiled and prepared.
  29101. * @returns if the effect is compiled and prepared.
  29102. */
  29103. isReady(): boolean;
  29104. /**
  29105. * The engine the effect was initialized with.
  29106. * @returns the engine.
  29107. */
  29108. getEngine(): Engine;
  29109. /**
  29110. * The pipeline context for this effect
  29111. * @returns the associated pipeline context
  29112. */
  29113. getPipelineContext(): IPipelineContext;
  29114. /**
  29115. * The set of names of attribute variables for the shader.
  29116. * @returns An array of attribute names.
  29117. */
  29118. getAttributesNames(): string[];
  29119. /**
  29120. * Returns the attribute at the given index.
  29121. * @param index The index of the attribute.
  29122. * @returns The location of the attribute.
  29123. */
  29124. getAttributeLocation(index: number): number;
  29125. /**
  29126. * Returns the attribute based on the name of the variable.
  29127. * @param name of the attribute to look up.
  29128. * @returns the attribute location.
  29129. */
  29130. getAttributeLocationByName(name: string): number;
  29131. /**
  29132. * The number of attributes.
  29133. * @returns the numnber of attributes.
  29134. */
  29135. getAttributesCount(): number;
  29136. /**
  29137. * Gets the index of a uniform variable.
  29138. * @param uniformName of the uniform to look up.
  29139. * @returns the index.
  29140. */
  29141. getUniformIndex(uniformName: string): number;
  29142. /**
  29143. * Returns the attribute based on the name of the variable.
  29144. * @param uniformName of the uniform to look up.
  29145. * @returns the location of the uniform.
  29146. */
  29147. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29148. /**
  29149. * Returns an array of sampler variable names
  29150. * @returns The array of sampler variable neames.
  29151. */
  29152. getSamplers(): string[];
  29153. /**
  29154. * The error from the last compilation.
  29155. * @returns the error string.
  29156. */
  29157. getCompilationError(): string;
  29158. /**
  29159. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29160. * @param func The callback to be used.
  29161. */
  29162. executeWhenCompiled(func: (effect: Effect) => void): void;
  29163. private _checkIsReady;
  29164. /** @hidden */
  29165. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29166. /** @hidden */
  29167. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29168. /** @hidden */
  29169. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29170. private _processShaderConversion;
  29171. private _processIncludes;
  29172. private _processPrecision;
  29173. /**
  29174. * Recompiles the webGL program
  29175. * @param vertexSourceCode The source code for the vertex shader.
  29176. * @param fragmentSourceCode The source code for the fragment shader.
  29177. * @param onCompiled Callback called when completed.
  29178. * @param onError Callback called on error.
  29179. * @hidden
  29180. */
  29181. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29182. /**
  29183. * Prepares the effect
  29184. * @hidden
  29185. */
  29186. _prepareEffect(): void;
  29187. /**
  29188. * Checks if the effect is supported. (Must be called after compilation)
  29189. */
  29190. readonly isSupported: boolean;
  29191. /**
  29192. * Binds a texture to the engine to be used as output of the shader.
  29193. * @param channel Name of the output variable.
  29194. * @param texture Texture to bind.
  29195. * @hidden
  29196. */
  29197. _bindTexture(channel: string, texture: InternalTexture): void;
  29198. /**
  29199. * Sets a texture on the engine to be used in the shader.
  29200. * @param channel Name of the sampler variable.
  29201. * @param texture Texture to set.
  29202. */
  29203. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29204. /**
  29205. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29206. * @param channel Name of the sampler variable.
  29207. * @param texture Texture to set.
  29208. */
  29209. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29210. /**
  29211. * Sets an array of textures on the engine to be used in the shader.
  29212. * @param channel Name of the variable.
  29213. * @param textures Textures to set.
  29214. */
  29215. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29216. /**
  29217. * 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)
  29218. * @param channel Name of the sampler variable.
  29219. * @param postProcess Post process to get the input texture from.
  29220. */
  29221. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29222. /**
  29223. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29224. * 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)
  29225. * @param channel Name of the sampler variable.
  29226. * @param postProcess Post process to get the output texture from.
  29227. */
  29228. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29229. /** @hidden */
  29230. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29231. /** @hidden */
  29232. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29233. /** @hidden */
  29234. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29235. /** @hidden */
  29236. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29237. /**
  29238. * Binds a buffer to a uniform.
  29239. * @param buffer Buffer to bind.
  29240. * @param name Name of the uniform variable to bind to.
  29241. */
  29242. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29243. /**
  29244. * Binds block to a uniform.
  29245. * @param blockName Name of the block to bind.
  29246. * @param index Index to bind.
  29247. */
  29248. bindUniformBlock(blockName: string, index: number): void;
  29249. /**
  29250. * Sets an interger value on a uniform variable.
  29251. * @param uniformName Name of the variable.
  29252. * @param value Value to be set.
  29253. * @returns this effect.
  29254. */
  29255. setInt(uniformName: string, value: number): Effect;
  29256. /**
  29257. * Sets an int array on a uniform variable.
  29258. * @param uniformName Name of the variable.
  29259. * @param array array to be set.
  29260. * @returns this effect.
  29261. */
  29262. setIntArray(uniformName: string, array: Int32Array): Effect;
  29263. /**
  29264. * 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)
  29265. * @param uniformName Name of the variable.
  29266. * @param array array to be set.
  29267. * @returns this effect.
  29268. */
  29269. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29270. /**
  29271. * 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)
  29272. * @param uniformName Name of the variable.
  29273. * @param array array to be set.
  29274. * @returns this effect.
  29275. */
  29276. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29277. /**
  29278. * 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)
  29279. * @param uniformName Name of the variable.
  29280. * @param array array to be set.
  29281. * @returns this effect.
  29282. */
  29283. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29284. /**
  29285. * Sets an float array on a uniform variable.
  29286. * @param uniformName Name of the variable.
  29287. * @param array array to be set.
  29288. * @returns this effect.
  29289. */
  29290. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29291. /**
  29292. * 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)
  29293. * @param uniformName Name of the variable.
  29294. * @param array array to be set.
  29295. * @returns this effect.
  29296. */
  29297. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29298. /**
  29299. * 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)
  29300. * @param uniformName Name of the variable.
  29301. * @param array array to be set.
  29302. * @returns this effect.
  29303. */
  29304. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29305. /**
  29306. * 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)
  29307. * @param uniformName Name of the variable.
  29308. * @param array array to be set.
  29309. * @returns this effect.
  29310. */
  29311. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29312. /**
  29313. * Sets an array on a uniform variable.
  29314. * @param uniformName Name of the variable.
  29315. * @param array array to be set.
  29316. * @returns this effect.
  29317. */
  29318. setArray(uniformName: string, array: number[]): Effect;
  29319. /**
  29320. * 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)
  29321. * @param uniformName Name of the variable.
  29322. * @param array array to be set.
  29323. * @returns this effect.
  29324. */
  29325. setArray2(uniformName: string, array: number[]): Effect;
  29326. /**
  29327. * 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)
  29328. * @param uniformName Name of the variable.
  29329. * @param array array to be set.
  29330. * @returns this effect.
  29331. */
  29332. setArray3(uniformName: string, array: number[]): Effect;
  29333. /**
  29334. * 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)
  29335. * @param uniformName Name of the variable.
  29336. * @param array array to be set.
  29337. * @returns this effect.
  29338. */
  29339. setArray4(uniformName: string, array: number[]): Effect;
  29340. /**
  29341. * Sets matrices on a uniform variable.
  29342. * @param uniformName Name of the variable.
  29343. * @param matrices matrices to be set.
  29344. * @returns this effect.
  29345. */
  29346. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29347. /**
  29348. * Sets matrix on a uniform variable.
  29349. * @param uniformName Name of the variable.
  29350. * @param matrix matrix to be set.
  29351. * @returns this effect.
  29352. */
  29353. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29354. /**
  29355. * 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)
  29356. * @param uniformName Name of the variable.
  29357. * @param matrix matrix to be set.
  29358. * @returns this effect.
  29359. */
  29360. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29361. /**
  29362. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29363. * @param uniformName Name of the variable.
  29364. * @param matrix matrix to be set.
  29365. * @returns this effect.
  29366. */
  29367. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29368. /**
  29369. * Sets a float on a uniform variable.
  29370. * @param uniformName Name of the variable.
  29371. * @param value value to be set.
  29372. * @returns this effect.
  29373. */
  29374. setFloat(uniformName: string, value: number): Effect;
  29375. /**
  29376. * Sets a boolean on a uniform variable.
  29377. * @param uniformName Name of the variable.
  29378. * @param bool value to be set.
  29379. * @returns this effect.
  29380. */
  29381. setBool(uniformName: string, bool: boolean): Effect;
  29382. /**
  29383. * Sets a Vector2 on a uniform variable.
  29384. * @param uniformName Name of the variable.
  29385. * @param vector2 vector2 to be set.
  29386. * @returns this effect.
  29387. */
  29388. setVector2(uniformName: string, vector2: Vector2): Effect;
  29389. /**
  29390. * Sets a float2 on a uniform variable.
  29391. * @param uniformName Name of the variable.
  29392. * @param x First float in float2.
  29393. * @param y Second float in float2.
  29394. * @returns this effect.
  29395. */
  29396. setFloat2(uniformName: string, x: number, y: number): Effect;
  29397. /**
  29398. * Sets a Vector3 on a uniform variable.
  29399. * @param uniformName Name of the variable.
  29400. * @param vector3 Value to be set.
  29401. * @returns this effect.
  29402. */
  29403. setVector3(uniformName: string, vector3: Vector3): Effect;
  29404. /**
  29405. * Sets a float3 on a uniform variable.
  29406. * @param uniformName Name of the variable.
  29407. * @param x First float in float3.
  29408. * @param y Second float in float3.
  29409. * @param z Third float in float3.
  29410. * @returns this effect.
  29411. */
  29412. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29413. /**
  29414. * Sets a Vector4 on a uniform variable.
  29415. * @param uniformName Name of the variable.
  29416. * @param vector4 Value to be set.
  29417. * @returns this effect.
  29418. */
  29419. setVector4(uniformName: string, vector4: Vector4): Effect;
  29420. /**
  29421. * Sets a float4 on a uniform variable.
  29422. * @param uniformName Name of the variable.
  29423. * @param x First float in float4.
  29424. * @param y Second float in float4.
  29425. * @param z Third float in float4.
  29426. * @param w Fourth float in float4.
  29427. * @returns this effect.
  29428. */
  29429. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29430. /**
  29431. * Sets a Color3 on a uniform variable.
  29432. * @param uniformName Name of the variable.
  29433. * @param color3 Value to be set.
  29434. * @returns this effect.
  29435. */
  29436. setColor3(uniformName: string, color3: Color3): Effect;
  29437. /**
  29438. * Sets a Color4 on a uniform variable.
  29439. * @param uniformName Name of the variable.
  29440. * @param color3 Value to be set.
  29441. * @param alpha Alpha value to be set.
  29442. * @returns this effect.
  29443. */
  29444. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29445. /**
  29446. * Sets a Color4 on a uniform variable
  29447. * @param uniformName defines the name of the variable
  29448. * @param color4 defines the value to be set
  29449. * @returns this effect.
  29450. */
  29451. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29452. /** Release all associated resources */
  29453. dispose(): void;
  29454. /**
  29455. * This function will add a new shader to the shader store
  29456. * @param name the name of the shader
  29457. * @param pixelShader optional pixel shader content
  29458. * @param vertexShader optional vertex shader content
  29459. */
  29460. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29461. /**
  29462. * Store of each shader (The can be looked up using effect.key)
  29463. */
  29464. static ShadersStore: {
  29465. [key: string]: string;
  29466. };
  29467. /**
  29468. * Store of each included file for a shader (The can be looked up using effect.key)
  29469. */
  29470. static IncludesShadersStore: {
  29471. [key: string]: string;
  29472. };
  29473. /**
  29474. * Resets the cache of effects.
  29475. */
  29476. static ResetCache(): void;
  29477. }
  29478. }
  29479. declare module BABYLON {
  29480. /**
  29481. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29482. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29483. * 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;
  29484. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29485. */
  29486. export class ColorCurves {
  29487. private _dirty;
  29488. private _tempColor;
  29489. private _globalCurve;
  29490. private _highlightsCurve;
  29491. private _midtonesCurve;
  29492. private _shadowsCurve;
  29493. private _positiveCurve;
  29494. private _negativeCurve;
  29495. private _globalHue;
  29496. private _globalDensity;
  29497. private _globalSaturation;
  29498. private _globalExposure;
  29499. /**
  29500. * Gets the global Hue value.
  29501. * 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).
  29502. */
  29503. /**
  29504. * Sets the global Hue value.
  29505. * 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).
  29506. */
  29507. globalHue: number;
  29508. /**
  29509. * Gets the global Density value.
  29510. * 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.
  29511. * Values less than zero provide a filter of opposite hue.
  29512. */
  29513. /**
  29514. * Sets the global Density value.
  29515. * 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.
  29516. * Values less than zero provide a filter of opposite hue.
  29517. */
  29518. globalDensity: number;
  29519. /**
  29520. * Gets the global Saturation value.
  29521. * 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.
  29522. */
  29523. /**
  29524. * Sets the global Saturation value.
  29525. * 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.
  29526. */
  29527. globalSaturation: number;
  29528. /**
  29529. * Gets the global Exposure value.
  29530. * 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.
  29531. */
  29532. /**
  29533. * Sets the global Exposure value.
  29534. * 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.
  29535. */
  29536. globalExposure: number;
  29537. private _highlightsHue;
  29538. private _highlightsDensity;
  29539. private _highlightsSaturation;
  29540. private _highlightsExposure;
  29541. /**
  29542. * Gets the highlights Hue value.
  29543. * 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).
  29544. */
  29545. /**
  29546. * Sets the highlights Hue value.
  29547. * 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).
  29548. */
  29549. highlightsHue: number;
  29550. /**
  29551. * Gets the highlights Density value.
  29552. * 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.
  29553. * Values less than zero provide a filter of opposite hue.
  29554. */
  29555. /**
  29556. * Sets the highlights Density value.
  29557. * 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.
  29558. * Values less than zero provide a filter of opposite hue.
  29559. */
  29560. highlightsDensity: number;
  29561. /**
  29562. * Gets the highlights Saturation value.
  29563. * 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.
  29564. */
  29565. /**
  29566. * Sets the highlights Saturation value.
  29567. * 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.
  29568. */
  29569. highlightsSaturation: number;
  29570. /**
  29571. * Gets the highlights Exposure value.
  29572. * 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.
  29573. */
  29574. /**
  29575. * Sets the highlights Exposure value.
  29576. * 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.
  29577. */
  29578. highlightsExposure: number;
  29579. private _midtonesHue;
  29580. private _midtonesDensity;
  29581. private _midtonesSaturation;
  29582. private _midtonesExposure;
  29583. /**
  29584. * Gets the midtones Hue value.
  29585. * 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).
  29586. */
  29587. /**
  29588. * Sets the midtones Hue value.
  29589. * 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).
  29590. */
  29591. midtonesHue: number;
  29592. /**
  29593. * Gets the midtones Density value.
  29594. * 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.
  29595. * Values less than zero provide a filter of opposite hue.
  29596. */
  29597. /**
  29598. * Sets the midtones Density value.
  29599. * 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.
  29600. * Values less than zero provide a filter of opposite hue.
  29601. */
  29602. midtonesDensity: number;
  29603. /**
  29604. * Gets the midtones Saturation value.
  29605. * 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.
  29606. */
  29607. /**
  29608. * Sets the midtones Saturation value.
  29609. * 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.
  29610. */
  29611. midtonesSaturation: number;
  29612. /**
  29613. * Gets the midtones Exposure value.
  29614. * 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.
  29615. */
  29616. /**
  29617. * Sets the midtones Exposure value.
  29618. * 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.
  29619. */
  29620. midtonesExposure: number;
  29621. private _shadowsHue;
  29622. private _shadowsDensity;
  29623. private _shadowsSaturation;
  29624. private _shadowsExposure;
  29625. /**
  29626. * Gets the shadows Hue value.
  29627. * 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).
  29628. */
  29629. /**
  29630. * Sets the shadows Hue value.
  29631. * 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).
  29632. */
  29633. shadowsHue: number;
  29634. /**
  29635. * Gets the shadows Density value.
  29636. * 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.
  29637. * Values less than zero provide a filter of opposite hue.
  29638. */
  29639. /**
  29640. * Sets the shadows Density value.
  29641. * 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.
  29642. * Values less than zero provide a filter of opposite hue.
  29643. */
  29644. shadowsDensity: number;
  29645. /**
  29646. * Gets the shadows Saturation value.
  29647. * 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.
  29648. */
  29649. /**
  29650. * Sets the shadows Saturation value.
  29651. * 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.
  29652. */
  29653. shadowsSaturation: number;
  29654. /**
  29655. * Gets the shadows Exposure value.
  29656. * 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.
  29657. */
  29658. /**
  29659. * Sets the shadows Exposure value.
  29660. * 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.
  29661. */
  29662. shadowsExposure: number;
  29663. /**
  29664. * Returns the class name
  29665. * @returns The class name
  29666. */
  29667. getClassName(): string;
  29668. /**
  29669. * Binds the color curves to the shader.
  29670. * @param colorCurves The color curve to bind
  29671. * @param effect The effect to bind to
  29672. * @param positiveUniform The positive uniform shader parameter
  29673. * @param neutralUniform The neutral uniform shader parameter
  29674. * @param negativeUniform The negative uniform shader parameter
  29675. */
  29676. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29677. /**
  29678. * Prepare the list of uniforms associated with the ColorCurves effects.
  29679. * @param uniformsList The list of uniforms used in the effect
  29680. */
  29681. static PrepareUniforms(uniformsList: string[]): void;
  29682. /**
  29683. * Returns color grading data based on a hue, density, saturation and exposure value.
  29684. * @param filterHue The hue of the color filter.
  29685. * @param filterDensity The density of the color filter.
  29686. * @param saturation The saturation.
  29687. * @param exposure The exposure.
  29688. * @param result The result data container.
  29689. */
  29690. private getColorGradingDataToRef;
  29691. /**
  29692. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29693. * @param value The input slider value in range [-100,100].
  29694. * @returns Adjusted value.
  29695. */
  29696. private static applyColorGradingSliderNonlinear;
  29697. /**
  29698. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29699. * @param hue The hue (H) input.
  29700. * @param saturation The saturation (S) input.
  29701. * @param brightness The brightness (B) input.
  29702. * @result An RGBA color represented as Vector4.
  29703. */
  29704. private static fromHSBToRef;
  29705. /**
  29706. * Returns a value clamped between min and max
  29707. * @param value The value to clamp
  29708. * @param min The minimum of value
  29709. * @param max The maximum of value
  29710. * @returns The clamped value.
  29711. */
  29712. private static clamp;
  29713. /**
  29714. * Clones the current color curve instance.
  29715. * @return The cloned curves
  29716. */
  29717. clone(): ColorCurves;
  29718. /**
  29719. * Serializes the current color curve instance to a json representation.
  29720. * @return a JSON representation
  29721. */
  29722. serialize(): any;
  29723. /**
  29724. * Parses the color curve from a json representation.
  29725. * @param source the JSON source to parse
  29726. * @return The parsed curves
  29727. */
  29728. static Parse(source: any): ColorCurves;
  29729. }
  29730. }
  29731. declare module BABYLON {
  29732. /**
  29733. * Interface to follow in your material defines to integrate easily the
  29734. * Image proccessing functions.
  29735. * @hidden
  29736. */
  29737. export interface IImageProcessingConfigurationDefines {
  29738. IMAGEPROCESSING: boolean;
  29739. VIGNETTE: boolean;
  29740. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29741. VIGNETTEBLENDMODEOPAQUE: boolean;
  29742. TONEMAPPING: boolean;
  29743. TONEMAPPING_ACES: boolean;
  29744. CONTRAST: boolean;
  29745. EXPOSURE: boolean;
  29746. COLORCURVES: boolean;
  29747. COLORGRADING: boolean;
  29748. COLORGRADING3D: boolean;
  29749. SAMPLER3DGREENDEPTH: boolean;
  29750. SAMPLER3DBGRMAP: boolean;
  29751. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29752. }
  29753. /**
  29754. * @hidden
  29755. */
  29756. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29757. IMAGEPROCESSING: boolean;
  29758. VIGNETTE: boolean;
  29759. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29760. VIGNETTEBLENDMODEOPAQUE: boolean;
  29761. TONEMAPPING: boolean;
  29762. TONEMAPPING_ACES: boolean;
  29763. CONTRAST: boolean;
  29764. COLORCURVES: boolean;
  29765. COLORGRADING: boolean;
  29766. COLORGRADING3D: boolean;
  29767. SAMPLER3DGREENDEPTH: boolean;
  29768. SAMPLER3DBGRMAP: boolean;
  29769. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29770. EXPOSURE: boolean;
  29771. constructor();
  29772. }
  29773. /**
  29774. * This groups together the common properties used for image processing either in direct forward pass
  29775. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29776. * or not.
  29777. */
  29778. export class ImageProcessingConfiguration {
  29779. /**
  29780. * Default tone mapping applied in BabylonJS.
  29781. */
  29782. static readonly TONEMAPPING_STANDARD: number;
  29783. /**
  29784. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29785. * to other engines rendering to increase portability.
  29786. */
  29787. static readonly TONEMAPPING_ACES: number;
  29788. /**
  29789. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29790. */
  29791. colorCurves: Nullable<ColorCurves>;
  29792. private _colorCurvesEnabled;
  29793. /**
  29794. * Gets wether the color curves effect is enabled.
  29795. */
  29796. /**
  29797. * Sets wether the color curves effect is enabled.
  29798. */
  29799. colorCurvesEnabled: boolean;
  29800. private _colorGradingTexture;
  29801. /**
  29802. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29803. */
  29804. /**
  29805. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29806. */
  29807. colorGradingTexture: Nullable<BaseTexture>;
  29808. private _colorGradingEnabled;
  29809. /**
  29810. * Gets wether the color grading effect is enabled.
  29811. */
  29812. /**
  29813. * Sets wether the color grading effect is enabled.
  29814. */
  29815. colorGradingEnabled: boolean;
  29816. private _colorGradingWithGreenDepth;
  29817. /**
  29818. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29819. */
  29820. /**
  29821. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29822. */
  29823. colorGradingWithGreenDepth: boolean;
  29824. private _colorGradingBGR;
  29825. /**
  29826. * Gets wether the color grading texture contains BGR values.
  29827. */
  29828. /**
  29829. * Sets wether the color grading texture contains BGR values.
  29830. */
  29831. colorGradingBGR: boolean;
  29832. /** @hidden */
  29833. _exposure: number;
  29834. /**
  29835. * Gets the Exposure used in the effect.
  29836. */
  29837. /**
  29838. * Sets the Exposure used in the effect.
  29839. */
  29840. exposure: number;
  29841. private _toneMappingEnabled;
  29842. /**
  29843. * Gets wether the tone mapping effect is enabled.
  29844. */
  29845. /**
  29846. * Sets wether the tone mapping effect is enabled.
  29847. */
  29848. toneMappingEnabled: boolean;
  29849. private _toneMappingType;
  29850. /**
  29851. * Gets the type of tone mapping effect.
  29852. */
  29853. /**
  29854. * Sets the type of tone mapping effect used in BabylonJS.
  29855. */
  29856. toneMappingType: number;
  29857. protected _contrast: number;
  29858. /**
  29859. * Gets the contrast used in the effect.
  29860. */
  29861. /**
  29862. * Sets the contrast used in the effect.
  29863. */
  29864. contrast: number;
  29865. /**
  29866. * Vignette stretch size.
  29867. */
  29868. vignetteStretch: number;
  29869. /**
  29870. * Vignette centre X Offset.
  29871. */
  29872. vignetteCentreX: number;
  29873. /**
  29874. * Vignette centre Y Offset.
  29875. */
  29876. vignetteCentreY: number;
  29877. /**
  29878. * Vignette weight or intensity of the vignette effect.
  29879. */
  29880. vignetteWeight: number;
  29881. /**
  29882. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29883. * if vignetteEnabled is set to true.
  29884. */
  29885. vignetteColor: Color4;
  29886. /**
  29887. * Camera field of view used by the Vignette effect.
  29888. */
  29889. vignetteCameraFov: number;
  29890. private _vignetteBlendMode;
  29891. /**
  29892. * Gets the vignette blend mode allowing different kind of effect.
  29893. */
  29894. /**
  29895. * Sets the vignette blend mode allowing different kind of effect.
  29896. */
  29897. vignetteBlendMode: number;
  29898. private _vignetteEnabled;
  29899. /**
  29900. * Gets wether the vignette effect is enabled.
  29901. */
  29902. /**
  29903. * Sets wether the vignette effect is enabled.
  29904. */
  29905. vignetteEnabled: boolean;
  29906. private _applyByPostProcess;
  29907. /**
  29908. * Gets wether the image processing is applied through a post process or not.
  29909. */
  29910. /**
  29911. * Sets wether the image processing is applied through a post process or not.
  29912. */
  29913. applyByPostProcess: boolean;
  29914. private _isEnabled;
  29915. /**
  29916. * Gets wether the image processing is enabled or not.
  29917. */
  29918. /**
  29919. * Sets wether the image processing is enabled or not.
  29920. */
  29921. isEnabled: boolean;
  29922. /**
  29923. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29924. */
  29925. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29926. /**
  29927. * Method called each time the image processing information changes requires to recompile the effect.
  29928. */
  29929. protected _updateParameters(): void;
  29930. /**
  29931. * Gets the current class name.
  29932. * @return "ImageProcessingConfiguration"
  29933. */
  29934. getClassName(): string;
  29935. /**
  29936. * Prepare the list of uniforms associated with the Image Processing effects.
  29937. * @param uniforms The list of uniforms used in the effect
  29938. * @param defines the list of defines currently in use
  29939. */
  29940. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29941. /**
  29942. * Prepare the list of samplers associated with the Image Processing effects.
  29943. * @param samplersList The list of uniforms used in the effect
  29944. * @param defines the list of defines currently in use
  29945. */
  29946. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29947. /**
  29948. * Prepare the list of defines associated to the shader.
  29949. * @param defines the list of defines to complete
  29950. * @param forPostProcess Define if we are currently in post process mode or not
  29951. */
  29952. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29953. /**
  29954. * Returns true if all the image processing information are ready.
  29955. * @returns True if ready, otherwise, false
  29956. */
  29957. isReady(): boolean;
  29958. /**
  29959. * Binds the image processing to the shader.
  29960. * @param effect The effect to bind to
  29961. * @param aspectRatio Define the current aspect ratio of the effect
  29962. */
  29963. bind(effect: Effect, aspectRatio?: number): void;
  29964. /**
  29965. * Clones the current image processing instance.
  29966. * @return The cloned image processing
  29967. */
  29968. clone(): ImageProcessingConfiguration;
  29969. /**
  29970. * Serializes the current image processing instance to a json representation.
  29971. * @return a JSON representation
  29972. */
  29973. serialize(): any;
  29974. /**
  29975. * Parses the image processing from a json representation.
  29976. * @param source the JSON source to parse
  29977. * @return The parsed image processing
  29978. */
  29979. static Parse(source: any): ImageProcessingConfiguration;
  29980. private static _VIGNETTEMODE_MULTIPLY;
  29981. private static _VIGNETTEMODE_OPAQUE;
  29982. /**
  29983. * Used to apply the vignette as a mix with the pixel color.
  29984. */
  29985. static readonly VIGNETTEMODE_MULTIPLY: number;
  29986. /**
  29987. * Used to apply the vignette as a replacement of the pixel color.
  29988. */
  29989. static readonly VIGNETTEMODE_OPAQUE: number;
  29990. }
  29991. }
  29992. declare module BABYLON {
  29993. /**
  29994. * This represents all the required information to add a fresnel effect on a material:
  29995. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29996. */
  29997. export class FresnelParameters {
  29998. private _isEnabled;
  29999. /**
  30000. * Define if the fresnel effect is enable or not.
  30001. */
  30002. isEnabled: boolean;
  30003. /**
  30004. * Define the color used on edges (grazing angle)
  30005. */
  30006. leftColor: Color3;
  30007. /**
  30008. * Define the color used on center
  30009. */
  30010. rightColor: Color3;
  30011. /**
  30012. * Define bias applied to computed fresnel term
  30013. */
  30014. bias: number;
  30015. /**
  30016. * Defined the power exponent applied to fresnel term
  30017. */
  30018. power: number;
  30019. /**
  30020. * Clones the current fresnel and its valuues
  30021. * @returns a clone fresnel configuration
  30022. */
  30023. clone(): FresnelParameters;
  30024. /**
  30025. * Serializes the current fresnel parameters to a JSON representation.
  30026. * @return the JSON serialization
  30027. */
  30028. serialize(): any;
  30029. /**
  30030. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30031. * @param parsedFresnelParameters Define the JSON representation
  30032. * @returns the parsed parameters
  30033. */
  30034. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30035. }
  30036. }
  30037. declare module BABYLON {
  30038. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30039. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30040. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30041. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30042. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30043. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30044. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30045. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30046. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30047. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30048. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30049. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30050. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30051. /**
  30052. * Decorator used to define property that can be serialized as reference to a camera
  30053. * @param sourceName defines the name of the property to decorate
  30054. */
  30055. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30056. /**
  30057. * Class used to help serialization objects
  30058. */
  30059. export class SerializationHelper {
  30060. /** hidden */
  30061. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30062. /** hidden */
  30063. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30064. /** hidden */
  30065. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30066. /** hidden */
  30067. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30068. /**
  30069. * Appends the serialized animations from the source animations
  30070. * @param source Source containing the animations
  30071. * @param destination Target to store the animations
  30072. */
  30073. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30074. /**
  30075. * Static function used to serialized a specific entity
  30076. * @param entity defines the entity to serialize
  30077. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30078. * @returns a JSON compatible object representing the serialization of the entity
  30079. */
  30080. static Serialize<T>(entity: T, serializationObject?: any): any;
  30081. /**
  30082. * Creates a new entity from a serialization data object
  30083. * @param creationFunction defines a function used to instanciated the new entity
  30084. * @param source defines the source serialization data
  30085. * @param scene defines the hosting scene
  30086. * @param rootUrl defines the root url for resources
  30087. * @returns a new entity
  30088. */
  30089. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30090. /**
  30091. * Clones an object
  30092. * @param creationFunction defines the function used to instanciate the new object
  30093. * @param source defines the source object
  30094. * @returns the cloned object
  30095. */
  30096. static Clone<T>(creationFunction: () => T, source: T): T;
  30097. /**
  30098. * Instanciates a new object based on a source one (some data will be shared between both object)
  30099. * @param creationFunction defines the function used to instanciate the new object
  30100. * @param source defines the source object
  30101. * @returns the new object
  30102. */
  30103. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30104. }
  30105. }
  30106. declare module BABYLON {
  30107. /**
  30108. * This is the base class of all the camera used in the application.
  30109. * @see http://doc.babylonjs.com/features/cameras
  30110. */
  30111. export class Camera extends Node {
  30112. /** @hidden */
  30113. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30114. /**
  30115. * This is the default projection mode used by the cameras.
  30116. * It helps recreating a feeling of perspective and better appreciate depth.
  30117. * This is the best way to simulate real life cameras.
  30118. */
  30119. static readonly PERSPECTIVE_CAMERA: number;
  30120. /**
  30121. * This helps creating camera with an orthographic mode.
  30122. * 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.
  30123. */
  30124. static readonly ORTHOGRAPHIC_CAMERA: number;
  30125. /**
  30126. * This is the default FOV mode for perspective cameras.
  30127. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30128. */
  30129. static readonly FOVMODE_VERTICAL_FIXED: number;
  30130. /**
  30131. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30132. */
  30133. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30134. /**
  30135. * This specifies ther is no need for a camera rig.
  30136. * Basically only one eye is rendered corresponding to the camera.
  30137. */
  30138. static readonly RIG_MODE_NONE: number;
  30139. /**
  30140. * Simulates a camera Rig with one blue eye and one red eye.
  30141. * This can be use with 3d blue and red glasses.
  30142. */
  30143. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30144. /**
  30145. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30146. */
  30147. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30148. /**
  30149. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30150. */
  30151. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30152. /**
  30153. * Defines that both eyes of the camera will be rendered over under each other.
  30154. */
  30155. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30156. /**
  30157. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30158. */
  30159. static readonly RIG_MODE_VR: number;
  30160. /**
  30161. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30162. */
  30163. static readonly RIG_MODE_WEBVR: number;
  30164. /**
  30165. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30166. */
  30167. static readonly RIG_MODE_CUSTOM: number;
  30168. /**
  30169. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30170. */
  30171. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30172. /**
  30173. * Define the input manager associated with the camera.
  30174. */
  30175. inputs: CameraInputsManager<Camera>;
  30176. /** @hidden */
  30177. _position: Vector3;
  30178. /**
  30179. * Define the current local position of the camera in the scene
  30180. */
  30181. position: Vector3;
  30182. /**
  30183. * The vector the camera should consider as up.
  30184. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30185. */
  30186. upVector: Vector3;
  30187. /**
  30188. * Define the current limit on the left side for an orthographic camera
  30189. * In scene unit
  30190. */
  30191. orthoLeft: Nullable<number>;
  30192. /**
  30193. * Define the current limit on the right side for an orthographic camera
  30194. * In scene unit
  30195. */
  30196. orthoRight: Nullable<number>;
  30197. /**
  30198. * Define the current limit on the bottom side for an orthographic camera
  30199. * In scene unit
  30200. */
  30201. orthoBottom: Nullable<number>;
  30202. /**
  30203. * Define the current limit on the top side for an orthographic camera
  30204. * In scene unit
  30205. */
  30206. orthoTop: Nullable<number>;
  30207. /**
  30208. * Field Of View is set in Radians. (default is 0.8)
  30209. */
  30210. fov: number;
  30211. /**
  30212. * Define the minimum distance the camera can see from.
  30213. * This is important to note that the depth buffer are not infinite and the closer it starts
  30214. * the more your scene might encounter depth fighting issue.
  30215. */
  30216. minZ: number;
  30217. /**
  30218. * Define the maximum distance the camera can see to.
  30219. * This is important to note that the depth buffer are not infinite and the further it end
  30220. * the more your scene might encounter depth fighting issue.
  30221. */
  30222. maxZ: number;
  30223. /**
  30224. * Define the default inertia of the camera.
  30225. * This helps giving a smooth feeling to the camera movement.
  30226. */
  30227. inertia: number;
  30228. /**
  30229. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30230. */
  30231. mode: number;
  30232. /**
  30233. * Define wether the camera is intermediate.
  30234. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30235. */
  30236. isIntermediate: boolean;
  30237. /**
  30238. * Define the viewport of the camera.
  30239. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30240. */
  30241. viewport: Viewport;
  30242. /**
  30243. * Restricts the camera to viewing objects with the same layerMask.
  30244. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30245. */
  30246. layerMask: number;
  30247. /**
  30248. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30249. */
  30250. fovMode: number;
  30251. /**
  30252. * Rig mode of the camera.
  30253. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30254. * This is normally controlled byt the camera themselves as internal use.
  30255. */
  30256. cameraRigMode: number;
  30257. /**
  30258. * Defines the distance between both "eyes" in case of a RIG
  30259. */
  30260. interaxialDistance: number;
  30261. /**
  30262. * Defines if stereoscopic rendering is done side by side or over under.
  30263. */
  30264. isStereoscopicSideBySide: boolean;
  30265. /**
  30266. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  30267. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30268. * else in the scene.
  30269. */
  30270. customRenderTargets: RenderTargetTexture[];
  30271. /**
  30272. * When set, the camera will render to this render target instead of the default canvas
  30273. */
  30274. outputRenderTarget: Nullable<RenderTargetTexture>;
  30275. /**
  30276. * Observable triggered when the camera view matrix has changed.
  30277. */
  30278. onViewMatrixChangedObservable: Observable<Camera>;
  30279. /**
  30280. * Observable triggered when the camera Projection matrix has changed.
  30281. */
  30282. onProjectionMatrixChangedObservable: Observable<Camera>;
  30283. /**
  30284. * Observable triggered when the inputs have been processed.
  30285. */
  30286. onAfterCheckInputsObservable: Observable<Camera>;
  30287. /**
  30288. * Observable triggered when reset has been called and applied to the camera.
  30289. */
  30290. onRestoreStateObservable: Observable<Camera>;
  30291. /** @hidden */
  30292. _cameraRigParams: any;
  30293. /** @hidden */
  30294. _rigCameras: Camera[];
  30295. /** @hidden */
  30296. _rigPostProcess: Nullable<PostProcess>;
  30297. protected _webvrViewMatrix: Matrix;
  30298. /** @hidden */
  30299. _skipRendering: boolean;
  30300. /** @hidden */
  30301. _projectionMatrix: Matrix;
  30302. /** @hidden */
  30303. _postProcesses: Nullable<PostProcess>[];
  30304. /** @hidden */
  30305. _activeMeshes: SmartArray<AbstractMesh>;
  30306. protected _globalPosition: Vector3;
  30307. /** hidden */
  30308. _computedViewMatrix: Matrix;
  30309. private _doNotComputeProjectionMatrix;
  30310. private _transformMatrix;
  30311. private _frustumPlanes;
  30312. private _refreshFrustumPlanes;
  30313. private _storedFov;
  30314. private _stateStored;
  30315. /**
  30316. * Instantiates a new camera object.
  30317. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30318. * @see http://doc.babylonjs.com/features/cameras
  30319. * @param name Defines the name of the camera in the scene
  30320. * @param position Defines the position of the camera
  30321. * @param scene Defines the scene the camera belongs too
  30322. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30323. */
  30324. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30325. /**
  30326. * Store current camera state (fov, position, etc..)
  30327. * @returns the camera
  30328. */
  30329. storeState(): Camera;
  30330. /**
  30331. * Restores the camera state values if it has been stored. You must call storeState() first
  30332. */
  30333. protected _restoreStateValues(): boolean;
  30334. /**
  30335. * Restored camera state. You must call storeState() first.
  30336. * @returns true if restored and false otherwise
  30337. */
  30338. restoreState(): boolean;
  30339. /**
  30340. * Gets the class name of the camera.
  30341. * @returns the class name
  30342. */
  30343. getClassName(): string;
  30344. /** @hidden */
  30345. readonly _isCamera: boolean;
  30346. /**
  30347. * Gets a string representation of the camera useful for debug purpose.
  30348. * @param fullDetails Defines that a more verboe level of logging is required
  30349. * @returns the string representation
  30350. */
  30351. toString(fullDetails?: boolean): string;
  30352. /**
  30353. * Gets the current world space position of the camera.
  30354. */
  30355. readonly globalPosition: Vector3;
  30356. /**
  30357. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30358. * @returns the active meshe list
  30359. */
  30360. getActiveMeshes(): SmartArray<AbstractMesh>;
  30361. /**
  30362. * Check wether a mesh is part of the current active mesh list of the camera
  30363. * @param mesh Defines the mesh to check
  30364. * @returns true if active, false otherwise
  30365. */
  30366. isActiveMesh(mesh: Mesh): boolean;
  30367. /**
  30368. * Is this camera ready to be used/rendered
  30369. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30370. * @return true if the camera is ready
  30371. */
  30372. isReady(completeCheck?: boolean): boolean;
  30373. /** @hidden */
  30374. _initCache(): void;
  30375. /** @hidden */
  30376. _updateCache(ignoreParentClass?: boolean): void;
  30377. /** @hidden */
  30378. _isSynchronized(): boolean;
  30379. /** @hidden */
  30380. _isSynchronizedViewMatrix(): boolean;
  30381. /** @hidden */
  30382. _isSynchronizedProjectionMatrix(): boolean;
  30383. /**
  30384. * Attach the input controls to a specific dom element to get the input from.
  30385. * @param element Defines the element the controls should be listened from
  30386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30387. */
  30388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30389. /**
  30390. * Detach the current controls from the specified dom element.
  30391. * @param element Defines the element to stop listening the inputs from
  30392. */
  30393. detachControl(element: HTMLElement): void;
  30394. /**
  30395. * Update the camera state according to the different inputs gathered during the frame.
  30396. */
  30397. update(): void;
  30398. /** @hidden */
  30399. _checkInputs(): void;
  30400. /** @hidden */
  30401. readonly rigCameras: Camera[];
  30402. /**
  30403. * Gets the post process used by the rig cameras
  30404. */
  30405. readonly rigPostProcess: Nullable<PostProcess>;
  30406. /**
  30407. * Internal, gets the first post proces.
  30408. * @returns the first post process to be run on this camera.
  30409. */
  30410. _getFirstPostProcess(): Nullable<PostProcess>;
  30411. private _cascadePostProcessesToRigCams;
  30412. /**
  30413. * Attach a post process to the camera.
  30414. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30415. * @param postProcess The post process to attach to the camera
  30416. * @param insertAt The position of the post process in case several of them are in use in the scene
  30417. * @returns the position the post process has been inserted at
  30418. */
  30419. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30420. /**
  30421. * Detach a post process to the camera.
  30422. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30423. * @param postProcess The post process to detach from the camera
  30424. */
  30425. detachPostProcess(postProcess: PostProcess): void;
  30426. /**
  30427. * Gets the current world matrix of the camera
  30428. */
  30429. getWorldMatrix(): Matrix;
  30430. /** @hidden */
  30431. _getViewMatrix(): Matrix;
  30432. /**
  30433. * Gets the current view matrix of the camera.
  30434. * @param force forces the camera to recompute the matrix without looking at the cached state
  30435. * @returns the view matrix
  30436. */
  30437. getViewMatrix(force?: boolean): Matrix;
  30438. /**
  30439. * Freeze the projection matrix.
  30440. * It will prevent the cache check of the camera projection compute and can speed up perf
  30441. * if no parameter of the camera are meant to change
  30442. * @param projection Defines manually a projection if necessary
  30443. */
  30444. freezeProjectionMatrix(projection?: Matrix): void;
  30445. /**
  30446. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30447. */
  30448. unfreezeProjectionMatrix(): void;
  30449. /**
  30450. * Gets the current projection matrix of the camera.
  30451. * @param force forces the camera to recompute the matrix without looking at the cached state
  30452. * @returns the projection matrix
  30453. */
  30454. getProjectionMatrix(force?: boolean): Matrix;
  30455. /**
  30456. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30457. * @returns a Matrix
  30458. */
  30459. getTransformationMatrix(): Matrix;
  30460. private _updateFrustumPlanes;
  30461. /**
  30462. * Checks if a cullable object (mesh...) is in the camera frustum
  30463. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30464. * @param target The object to check
  30465. * @returns true if the object is in frustum otherwise false
  30466. */
  30467. isInFrustum(target: ICullable): boolean;
  30468. /**
  30469. * Checks if a cullable object (mesh...) is in the camera frustum
  30470. * Unlike isInFrustum this cheks the full bounding box
  30471. * @param target The object to check
  30472. * @returns true if the object is in frustum otherwise false
  30473. */
  30474. isCompletelyInFrustum(target: ICullable): boolean;
  30475. /**
  30476. * Gets a ray in the forward direction from the camera.
  30477. * @param length Defines the length of the ray to create
  30478. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30479. * @param origin Defines the start point of the ray which defaults to the camera position
  30480. * @returns the forward ray
  30481. */
  30482. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30483. /**
  30484. * Releases resources associated with this node.
  30485. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30486. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30487. */
  30488. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30489. /** @hidden */
  30490. _isLeftCamera: boolean;
  30491. /**
  30492. * Gets the left camera of a rig setup in case of Rigged Camera
  30493. */
  30494. readonly isLeftCamera: boolean;
  30495. /** @hidden */
  30496. _isRightCamera: boolean;
  30497. /**
  30498. * Gets the right camera of a rig setup in case of Rigged Camera
  30499. */
  30500. readonly isRightCamera: boolean;
  30501. /**
  30502. * Gets the left camera of a rig setup in case of Rigged Camera
  30503. */
  30504. readonly leftCamera: Nullable<FreeCamera>;
  30505. /**
  30506. * Gets the right camera of a rig setup in case of Rigged Camera
  30507. */
  30508. readonly rightCamera: Nullable<FreeCamera>;
  30509. /**
  30510. * Gets the left camera target of a rig setup in case of Rigged Camera
  30511. * @returns the target position
  30512. */
  30513. getLeftTarget(): Nullable<Vector3>;
  30514. /**
  30515. * Gets the right camera target of a rig setup in case of Rigged Camera
  30516. * @returns the target position
  30517. */
  30518. getRightTarget(): Nullable<Vector3>;
  30519. /**
  30520. * @hidden
  30521. */
  30522. setCameraRigMode(mode: number, rigParams: any): void;
  30523. /** @hidden */
  30524. static _setStereoscopicRigMode(camera: Camera): void;
  30525. /** @hidden */
  30526. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30527. /** @hidden */
  30528. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30529. /** @hidden */
  30530. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30531. /** @hidden */
  30532. _getVRProjectionMatrix(): Matrix;
  30533. protected _updateCameraRotationMatrix(): void;
  30534. protected _updateWebVRCameraRotationMatrix(): void;
  30535. /**
  30536. * This function MUST be overwritten by the different WebVR cameras available.
  30537. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30538. * @hidden
  30539. */
  30540. _getWebVRProjectionMatrix(): Matrix;
  30541. /**
  30542. * This function MUST be overwritten by the different WebVR cameras available.
  30543. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30544. * @hidden
  30545. */
  30546. _getWebVRViewMatrix(): Matrix;
  30547. /** @hidden */
  30548. setCameraRigParameter(name: string, value: any): void;
  30549. /**
  30550. * needs to be overridden by children so sub has required properties to be copied
  30551. * @hidden
  30552. */
  30553. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30554. /**
  30555. * May need to be overridden by children
  30556. * @hidden
  30557. */
  30558. _updateRigCameras(): void;
  30559. /** @hidden */
  30560. _setupInputs(): void;
  30561. /**
  30562. * Serialiaze the camera setup to a json represention
  30563. * @returns the JSON representation
  30564. */
  30565. serialize(): any;
  30566. /**
  30567. * Clones the current camera.
  30568. * @param name The cloned camera name
  30569. * @returns the cloned camera
  30570. */
  30571. clone(name: string): Camera;
  30572. /**
  30573. * Gets the direction of the camera relative to a given local axis.
  30574. * @param localAxis Defines the reference axis to provide a relative direction.
  30575. * @return the direction
  30576. */
  30577. getDirection(localAxis: Vector3): Vector3;
  30578. /**
  30579. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30580. * @param localAxis Defines the reference axis to provide a relative direction.
  30581. * @param result Defines the vector to store the result in
  30582. */
  30583. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30584. /**
  30585. * Gets a camera constructor for a given camera type
  30586. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30587. * @param name The name of the camera the result will be able to instantiate
  30588. * @param scene The scene the result will construct the camera in
  30589. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30590. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30591. * @returns a factory method to construc the camera
  30592. */
  30593. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30594. /**
  30595. * Compute the world matrix of the camera.
  30596. * @returns the camera workd matrix
  30597. */
  30598. computeWorldMatrix(): Matrix;
  30599. /**
  30600. * Parse a JSON and creates the camera from the parsed information
  30601. * @param parsedCamera The JSON to parse
  30602. * @param scene The scene to instantiate the camera in
  30603. * @returns the newly constructed camera
  30604. */
  30605. static Parse(parsedCamera: any, scene: Scene): Camera;
  30606. }
  30607. }
  30608. declare module BABYLON {
  30609. /**
  30610. * Interface for any object that can request an animation frame
  30611. */
  30612. export interface ICustomAnimationFrameRequester {
  30613. /**
  30614. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30615. */
  30616. renderFunction?: Function;
  30617. /**
  30618. * Called to request the next frame to render to
  30619. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30620. */
  30621. requestAnimationFrame: Function;
  30622. /**
  30623. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30624. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30625. */
  30626. requestID?: number;
  30627. }
  30628. /**
  30629. * Interface containing an array of animations
  30630. */
  30631. export interface IAnimatable {
  30632. /**
  30633. * Array of animations
  30634. */
  30635. animations: Nullable<Array<Animation>>;
  30636. }
  30637. /** Interface used by value gradients (color, factor, ...) */
  30638. export interface IValueGradient {
  30639. /**
  30640. * Gets or sets the gradient value (between 0 and 1)
  30641. */
  30642. gradient: number;
  30643. }
  30644. /** Class used to store color4 gradient */
  30645. export class ColorGradient implements IValueGradient {
  30646. /**
  30647. * Gets or sets the gradient value (between 0 and 1)
  30648. */
  30649. gradient: number;
  30650. /**
  30651. * Gets or sets first associated color
  30652. */
  30653. color1: Color4;
  30654. /**
  30655. * Gets or sets second associated color
  30656. */
  30657. color2?: Color4;
  30658. /**
  30659. * Will get a color picked randomly between color1 and color2.
  30660. * If color2 is undefined then color1 will be used
  30661. * @param result defines the target Color4 to store the result in
  30662. */
  30663. getColorToRef(result: Color4): void;
  30664. }
  30665. /** Class used to store color 3 gradient */
  30666. export class Color3Gradient implements IValueGradient {
  30667. /**
  30668. * Gets or sets the gradient value (between 0 and 1)
  30669. */
  30670. gradient: number;
  30671. /**
  30672. * Gets or sets the associated color
  30673. */
  30674. color: Color3;
  30675. }
  30676. /** Class used to store factor gradient */
  30677. export class FactorGradient implements IValueGradient {
  30678. /**
  30679. * Gets or sets the gradient value (between 0 and 1)
  30680. */
  30681. gradient: number;
  30682. /**
  30683. * Gets or sets first associated factor
  30684. */
  30685. factor1: number;
  30686. /**
  30687. * Gets or sets second associated factor
  30688. */
  30689. factor2?: number;
  30690. /**
  30691. * Will get a number picked randomly between factor1 and factor2.
  30692. * If factor2 is undefined then factor1 will be used
  30693. * @returns the picked number
  30694. */
  30695. getFactor(): number;
  30696. }
  30697. /**
  30698. * @ignore
  30699. * Application error to support additional information when loading a file
  30700. */
  30701. export class LoadFileError extends Error {
  30702. /** defines the optional web request */
  30703. request?: WebRequest | undefined;
  30704. private static _setPrototypeOf;
  30705. /**
  30706. * Creates a new LoadFileError
  30707. * @param message defines the message of the error
  30708. * @param request defines the optional web request
  30709. */
  30710. constructor(message: string,
  30711. /** defines the optional web request */
  30712. request?: WebRequest | undefined);
  30713. }
  30714. /**
  30715. * Class used to define a retry strategy when error happens while loading assets
  30716. */
  30717. export class RetryStrategy {
  30718. /**
  30719. * Function used to defines an exponential back off strategy
  30720. * @param maxRetries defines the maximum number of retries (3 by default)
  30721. * @param baseInterval defines the interval between retries
  30722. * @returns the strategy function to use
  30723. */
  30724. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30725. }
  30726. /**
  30727. * File request interface
  30728. */
  30729. export interface IFileRequest {
  30730. /**
  30731. * Raised when the request is complete (success or error).
  30732. */
  30733. onCompleteObservable: Observable<IFileRequest>;
  30734. /**
  30735. * Aborts the request for a file.
  30736. */
  30737. abort: () => void;
  30738. }
  30739. /**
  30740. * Class containing a set of static utilities functions
  30741. */
  30742. export class Tools {
  30743. /**
  30744. * Gets or sets the base URL to use to load assets
  30745. */
  30746. static BaseUrl: string;
  30747. /**
  30748. * Enable/Disable Custom HTTP Request Headers globally.
  30749. * default = false
  30750. * @see CustomRequestHeaders
  30751. */
  30752. static UseCustomRequestHeaders: boolean;
  30753. /**
  30754. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30755. * i.e. when loading files, where the server/service expects an Authorization header
  30756. */
  30757. static CustomRequestHeaders: {
  30758. [key: string]: string;
  30759. };
  30760. /**
  30761. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30762. */
  30763. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30764. /**
  30765. * Default behaviour for cors in the application.
  30766. * It can be a string if the expected behavior is identical in the entire app.
  30767. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30768. */
  30769. static CorsBehavior: string | ((url: string | string[]) => string);
  30770. /**
  30771. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30772. * @ignorenaming
  30773. */
  30774. static UseFallbackTexture: boolean;
  30775. /**
  30776. * Use this object to register external classes like custom textures or material
  30777. * to allow the laoders to instantiate them
  30778. */
  30779. static RegisteredExternalClasses: {
  30780. [key: string]: Object;
  30781. };
  30782. /**
  30783. * Texture content used if a texture cannot loaded
  30784. * @ignorenaming
  30785. */
  30786. static fallbackTexture: string;
  30787. /**
  30788. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30789. * @param u defines the coordinate on X axis
  30790. * @param v defines the coordinate on Y axis
  30791. * @param width defines the width of the source data
  30792. * @param height defines the height of the source data
  30793. * @param pixels defines the source byte array
  30794. * @param color defines the output color
  30795. */
  30796. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30797. /**
  30798. * Interpolates between a and b via alpha
  30799. * @param a The lower value (returned when alpha = 0)
  30800. * @param b The upper value (returned when alpha = 1)
  30801. * @param alpha The interpolation-factor
  30802. * @return The mixed value
  30803. */
  30804. static Mix(a: number, b: number, alpha: number): number;
  30805. /**
  30806. * Tries to instantiate a new object from a given class name
  30807. * @param className defines the class name to instantiate
  30808. * @returns the new object or null if the system was not able to do the instantiation
  30809. */
  30810. static Instantiate(className: string): any;
  30811. /**
  30812. * Provides a slice function that will work even on IE
  30813. * @param data defines the array to slice
  30814. * @param start defines the start of the data (optional)
  30815. * @param end defines the end of the data (optional)
  30816. * @returns the new sliced array
  30817. */
  30818. static Slice<T>(data: T, start?: number, end?: number): T;
  30819. /**
  30820. * Polyfill for setImmediate
  30821. * @param action defines the action to execute after the current execution block
  30822. */
  30823. static SetImmediate(action: () => void): void;
  30824. /**
  30825. * Function indicating if a number is an exponent of 2
  30826. * @param value defines the value to test
  30827. * @returns true if the value is an exponent of 2
  30828. */
  30829. static IsExponentOfTwo(value: number): boolean;
  30830. private static _tmpFloatArray;
  30831. /**
  30832. * Returns the nearest 32-bit single precision float representation of a Number
  30833. * @param value A Number. If the parameter is of a different type, it will get converted
  30834. * to a number or to NaN if it cannot be converted
  30835. * @returns number
  30836. */
  30837. static FloatRound(value: number): number;
  30838. /**
  30839. * Find the next highest power of two.
  30840. * @param x Number to start search from.
  30841. * @return Next highest power of two.
  30842. */
  30843. static CeilingPOT(x: number): number;
  30844. /**
  30845. * Find the next lowest power of two.
  30846. * @param x Number to start search from.
  30847. * @return Next lowest power of two.
  30848. */
  30849. static FloorPOT(x: number): number;
  30850. /**
  30851. * Find the nearest power of two.
  30852. * @param x Number to start search from.
  30853. * @return Next nearest power of two.
  30854. */
  30855. static NearestPOT(x: number): number;
  30856. /**
  30857. * Get the closest exponent of two
  30858. * @param value defines the value to approximate
  30859. * @param max defines the maximum value to return
  30860. * @param mode defines how to define the closest value
  30861. * @returns closest exponent of two of the given value
  30862. */
  30863. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30864. /**
  30865. * Extracts the filename from a path
  30866. * @param path defines the path to use
  30867. * @returns the filename
  30868. */
  30869. static GetFilename(path: string): string;
  30870. /**
  30871. * Extracts the "folder" part of a path (everything before the filename).
  30872. * @param uri The URI to extract the info from
  30873. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30874. * @returns The "folder" part of the path
  30875. */
  30876. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30877. /**
  30878. * Extracts text content from a DOM element hierarchy
  30879. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30880. */
  30881. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30882. /**
  30883. * Convert an angle in radians to degrees
  30884. * @param angle defines the angle to convert
  30885. * @returns the angle in degrees
  30886. */
  30887. static ToDegrees(angle: number): number;
  30888. /**
  30889. * Convert an angle in degrees to radians
  30890. * @param angle defines the angle to convert
  30891. * @returns the angle in radians
  30892. */
  30893. static ToRadians(angle: number): number;
  30894. /**
  30895. * Encode a buffer to a base64 string
  30896. * @param buffer defines the buffer to encode
  30897. * @returns the encoded string
  30898. */
  30899. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30900. /**
  30901. * Extracts minimum and maximum values from a list of indexed positions
  30902. * @param positions defines the positions to use
  30903. * @param indices defines the indices to the positions
  30904. * @param indexStart defines the start index
  30905. * @param indexCount defines the end index
  30906. * @param bias defines bias value to add to the result
  30907. * @return minimum and maximum values
  30908. */
  30909. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30910. minimum: Vector3;
  30911. maximum: Vector3;
  30912. };
  30913. /**
  30914. * Extracts minimum and maximum values from a list of positions
  30915. * @param positions defines the positions to use
  30916. * @param start defines the start index in the positions array
  30917. * @param count defines the number of positions to handle
  30918. * @param bias defines bias value to add to the result
  30919. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30920. * @return minimum and maximum values
  30921. */
  30922. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30923. minimum: Vector3;
  30924. maximum: Vector3;
  30925. };
  30926. /**
  30927. * Returns an array if obj is not an array
  30928. * @param obj defines the object to evaluate as an array
  30929. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30930. * @returns either obj directly if obj is an array or a new array containing obj
  30931. */
  30932. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30933. /**
  30934. * Gets the pointer prefix to use
  30935. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30936. */
  30937. static GetPointerPrefix(): string;
  30938. /**
  30939. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30940. * @param func - the function to be called
  30941. * @param requester - the object that will request the next frame. Falls back to window.
  30942. * @returns frame number
  30943. */
  30944. static QueueNewFrame(func: () => void, requester?: any): number;
  30945. /**
  30946. * Ask the browser to promote the current element to fullscreen rendering mode
  30947. * @param element defines the DOM element to promote
  30948. */
  30949. static RequestFullscreen(element: HTMLElement): void;
  30950. /**
  30951. * Asks the browser to exit fullscreen mode
  30952. */
  30953. static ExitFullscreen(): void;
  30954. /**
  30955. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30956. * @param url define the url we are trying
  30957. * @param element define the dom element where to configure the cors policy
  30958. */
  30959. static SetCorsBehavior(url: string | string[], element: {
  30960. crossOrigin: string | null;
  30961. }): void;
  30962. /**
  30963. * Removes unwanted characters from an url
  30964. * @param url defines the url to clean
  30965. * @returns the cleaned url
  30966. */
  30967. static CleanUrl(url: string): string;
  30968. /**
  30969. * Gets or sets a function used to pre-process url before using them to load assets
  30970. */
  30971. static PreprocessUrl: (url: string) => string;
  30972. /**
  30973. * Loads an image as an HTMLImageElement.
  30974. * @param input url string, ArrayBuffer, or Blob to load
  30975. * @param onLoad callback called when the image successfully loads
  30976. * @param onError callback called when the image fails to load
  30977. * @param offlineProvider offline provider for caching
  30978. * @returns the HTMLImageElement of the loaded image
  30979. */
  30980. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30981. /**
  30982. * Loads a file
  30983. * @param url url string, ArrayBuffer, or Blob to load
  30984. * @param onSuccess callback called when the file successfully loads
  30985. * @param onProgress callback called while file is loading (if the server supports this mode)
  30986. * @param offlineProvider defines the offline provider for caching
  30987. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30988. * @param onError callback called when the file fails to load
  30989. * @returns a file request object
  30990. */
  30991. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  30992. /**
  30993. * Load a script (identified by an url). When the url returns, the
  30994. * content of this file is added into a new script element, attached to the DOM (body element)
  30995. * @param scriptUrl defines the url of the script to laod
  30996. * @param onSuccess defines the callback called when the script is loaded
  30997. * @param onError defines the callback to call if an error occurs
  30998. * @param scriptId defines the id of the script element
  30999. */
  31000. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31001. /**
  31002. * Load an asynchronous script (identified by an url). When the url returns, the
  31003. * content of this file is added into a new script element, attached to the DOM (body element)
  31004. * @param scriptUrl defines the url of the script to laod
  31005. * @param scriptId defines the id of the script element
  31006. * @returns a promise request object
  31007. */
  31008. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31009. /**
  31010. * Loads a file from a blob
  31011. * @param fileToLoad defines the blob to use
  31012. * @param callback defines the callback to call when data is loaded
  31013. * @param progressCallback defines the callback to call during loading process
  31014. * @returns a file request object
  31015. */
  31016. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31017. /**
  31018. * Loads a file
  31019. * @param fileToLoad defines the file to load
  31020. * @param callback defines the callback to call when data is loaded
  31021. * @param progressCallBack defines the callback to call during loading process
  31022. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31023. * @returns a file request object
  31024. */
  31025. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31026. /**
  31027. * Creates a data url from a given string content
  31028. * @param content defines the content to convert
  31029. * @returns the new data url link
  31030. */
  31031. static FileAsURL(content: string): string;
  31032. /**
  31033. * Format the given number to a specific decimal format
  31034. * @param value defines the number to format
  31035. * @param decimals defines the number of decimals to use
  31036. * @returns the formatted string
  31037. */
  31038. static Format(value: number, decimals?: number): string;
  31039. /**
  31040. * Checks if a given vector is inside a specific range
  31041. * @param v defines the vector to test
  31042. * @param min defines the minimum range
  31043. * @param max defines the maximum range
  31044. */
  31045. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31046. /**
  31047. * Tries to copy an object by duplicating every property
  31048. * @param source defines the source object
  31049. * @param destination defines the target object
  31050. * @param doNotCopyList defines a list of properties to avoid
  31051. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31052. */
  31053. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31054. /**
  31055. * Gets a boolean indicating if the given object has no own property
  31056. * @param obj defines the object to test
  31057. * @returns true if object has no own property
  31058. */
  31059. static IsEmpty(obj: any): boolean;
  31060. /**
  31061. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31062. * @param str Source string
  31063. * @param suffix Suffix to search for in the source string
  31064. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31065. */
  31066. static EndsWith(str: string, suffix: string): boolean;
  31067. /**
  31068. * Function used to register events at window level
  31069. * @param events defines the events to register
  31070. */
  31071. static RegisterTopRootEvents(events: {
  31072. name: string;
  31073. handler: Nullable<(e: FocusEvent) => any>;
  31074. }[]): void;
  31075. /**
  31076. * Function used to unregister events from window level
  31077. * @param events defines the events to unregister
  31078. */
  31079. static UnregisterTopRootEvents(events: {
  31080. name: string;
  31081. handler: Nullable<(e: FocusEvent) => any>;
  31082. }[]): void;
  31083. /**
  31084. * @ignore
  31085. */
  31086. static _ScreenshotCanvas: HTMLCanvasElement;
  31087. /**
  31088. * Dumps the current bound framebuffer
  31089. * @param width defines the rendering width
  31090. * @param height defines the rendering height
  31091. * @param engine defines the hosting engine
  31092. * @param successCallback defines the callback triggered once the data are available
  31093. * @param mimeType defines the mime type of the result
  31094. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31095. */
  31096. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31097. /**
  31098. * Converts the canvas data to blob.
  31099. * This acts as a polyfill for browsers not supporting the to blob function.
  31100. * @param canvas Defines the canvas to extract the data from
  31101. * @param successCallback Defines the callback triggered once the data are available
  31102. * @param mimeType Defines the mime type of the result
  31103. */
  31104. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31105. /**
  31106. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31107. * @param successCallback defines the callback triggered once the data are available
  31108. * @param mimeType defines the mime type of the result
  31109. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31110. */
  31111. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31112. /**
  31113. * Downloads a blob in the browser
  31114. * @param blob defines the blob to download
  31115. * @param fileName defines the name of the downloaded file
  31116. */
  31117. static Download(blob: Blob, fileName: string): void;
  31118. /**
  31119. * Captures a screenshot of the current rendering
  31120. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31121. * @param engine defines the rendering engine
  31122. * @param camera defines the source camera
  31123. * @param size This parameter can be set to a single number or to an object with the
  31124. * following (optional) properties: precision, width, height. If a single number is passed,
  31125. * it will be used for both width and height. If an object is passed, the screenshot size
  31126. * will be derived from the parameters. The precision property is a multiplier allowing
  31127. * rendering at a higher or lower resolution
  31128. * @param successCallback defines the callback receives a single parameter which contains the
  31129. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31130. * src parameter of an <img> to display it
  31131. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31132. * Check your browser for supported MIME types
  31133. */
  31134. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31135. /**
  31136. * Generates an image screenshot from the specified camera.
  31137. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31138. * @param engine The engine to use for rendering
  31139. * @param camera The camera to use for rendering
  31140. * @param size This parameter can be set to a single number or to an object with the
  31141. * following (optional) properties: precision, width, height. If a single number is passed,
  31142. * it will be used for both width and height. If an object is passed, the screenshot size
  31143. * will be derived from the parameters. The precision property is a multiplier allowing
  31144. * rendering at a higher or lower resolution
  31145. * @param successCallback The callback receives a single parameter which contains the
  31146. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31147. * src parameter of an <img> to display it
  31148. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31149. * Check your browser for supported MIME types
  31150. * @param samples Texture samples (default: 1)
  31151. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31152. * @param fileName A name for for the downloaded file.
  31153. */
  31154. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31155. /**
  31156. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31157. * Be aware Math.random() could cause collisions, but:
  31158. * "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"
  31159. * @returns a pseudo random id
  31160. */
  31161. static RandomId(): string;
  31162. /**
  31163. * Test if the given uri is a base64 string
  31164. * @param uri The uri to test
  31165. * @return True if the uri is a base64 string or false otherwise
  31166. */
  31167. static IsBase64(uri: string): boolean;
  31168. /**
  31169. * Decode the given base64 uri.
  31170. * @param uri The uri to decode
  31171. * @return The decoded base64 data.
  31172. */
  31173. static DecodeBase64(uri: string): ArrayBuffer;
  31174. /**
  31175. * Gets the absolute url.
  31176. * @param url the input url
  31177. * @return the absolute url
  31178. */
  31179. static GetAbsoluteUrl(url: string): string;
  31180. /**
  31181. * No log
  31182. */
  31183. static readonly NoneLogLevel: number;
  31184. /**
  31185. * Only message logs
  31186. */
  31187. static readonly MessageLogLevel: number;
  31188. /**
  31189. * Only warning logs
  31190. */
  31191. static readonly WarningLogLevel: number;
  31192. /**
  31193. * Only error logs
  31194. */
  31195. static readonly ErrorLogLevel: number;
  31196. /**
  31197. * All logs
  31198. */
  31199. static readonly AllLogLevel: number;
  31200. /**
  31201. * Gets a value indicating the number of loading errors
  31202. * @ignorenaming
  31203. */
  31204. static readonly errorsCount: number;
  31205. /**
  31206. * Callback called when a new log is added
  31207. */
  31208. static OnNewCacheEntry: (entry: string) => void;
  31209. /**
  31210. * Log a message to the console
  31211. * @param message defines the message to log
  31212. */
  31213. static Log(message: string): void;
  31214. /**
  31215. * Write a warning message to the console
  31216. * @param message defines the message to log
  31217. */
  31218. static Warn(message: string): void;
  31219. /**
  31220. * Write an error message to the console
  31221. * @param message defines the message to log
  31222. */
  31223. static Error(message: string): void;
  31224. /**
  31225. * Gets current log cache (list of logs)
  31226. */
  31227. static readonly LogCache: string;
  31228. /**
  31229. * Clears the log cache
  31230. */
  31231. static ClearLogCache(): void;
  31232. /**
  31233. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31234. */
  31235. static LogLevels: number;
  31236. /**
  31237. * Checks if the loaded document was accessed via `file:`-Protocol.
  31238. * @returns boolean
  31239. */
  31240. static IsFileURL(): boolean;
  31241. /**
  31242. * Checks if the window object exists
  31243. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31244. */
  31245. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31246. /**
  31247. * No performance log
  31248. */
  31249. static readonly PerformanceNoneLogLevel: number;
  31250. /**
  31251. * Use user marks to log performance
  31252. */
  31253. static readonly PerformanceUserMarkLogLevel: number;
  31254. /**
  31255. * Log performance to the console
  31256. */
  31257. static readonly PerformanceConsoleLogLevel: number;
  31258. private static _performance;
  31259. /**
  31260. * Sets the current performance log level
  31261. */
  31262. static PerformanceLogLevel: number;
  31263. private static _StartPerformanceCounterDisabled;
  31264. private static _EndPerformanceCounterDisabled;
  31265. private static _StartUserMark;
  31266. private static _EndUserMark;
  31267. private static _StartPerformanceConsole;
  31268. private static _EndPerformanceConsole;
  31269. /**
  31270. * Starts a performance counter
  31271. */
  31272. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31273. /**
  31274. * Ends a specific performance coutner
  31275. */
  31276. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31277. /**
  31278. * Gets either window.performance.now() if supported or Date.now() else
  31279. */
  31280. static readonly Now: number;
  31281. /**
  31282. * This method will return the name of the class used to create the instance of the given object.
  31283. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31284. * @param object the object to get the class name from
  31285. * @param isType defines if the object is actually a type
  31286. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31287. */
  31288. static GetClassName(object: any, isType?: boolean): string;
  31289. /**
  31290. * Gets the first element of an array satisfying a given predicate
  31291. * @param array defines the array to browse
  31292. * @param predicate defines the predicate to use
  31293. * @returns null if not found or the element
  31294. */
  31295. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31296. /**
  31297. * This method will return the name of the full name of the class, including its owning module (if any).
  31298. * 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).
  31299. * @param object the object to get the class name from
  31300. * @param isType defines if the object is actually a type
  31301. * @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.
  31302. * @ignorenaming
  31303. */
  31304. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31305. /**
  31306. * Returns a promise that resolves after the given amount of time.
  31307. * @param delay Number of milliseconds to delay
  31308. * @returns Promise that resolves after the given amount of time
  31309. */
  31310. static DelayAsync(delay: number): Promise<void>;
  31311. /**
  31312. * Gets the current gradient from an array of IValueGradient
  31313. * @param ratio defines the current ratio to get
  31314. * @param gradients defines the array of IValueGradient
  31315. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31316. */
  31317. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31318. }
  31319. /**
  31320. * This class is used to track a performance counter which is number based.
  31321. * The user has access to many properties which give statistics of different nature.
  31322. *
  31323. * The implementer can track two kinds of Performance Counter: time and count.
  31324. * 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.
  31325. * 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.
  31326. */
  31327. export class PerfCounter {
  31328. /**
  31329. * Gets or sets a global boolean to turn on and off all the counters
  31330. */
  31331. static Enabled: boolean;
  31332. /**
  31333. * Returns the smallest value ever
  31334. */
  31335. readonly min: number;
  31336. /**
  31337. * Returns the biggest value ever
  31338. */
  31339. readonly max: number;
  31340. /**
  31341. * Returns the average value since the performance counter is running
  31342. */
  31343. readonly average: number;
  31344. /**
  31345. * Returns the average value of the last second the counter was monitored
  31346. */
  31347. readonly lastSecAverage: number;
  31348. /**
  31349. * Returns the current value
  31350. */
  31351. readonly current: number;
  31352. /**
  31353. * Gets the accumulated total
  31354. */
  31355. readonly total: number;
  31356. /**
  31357. * Gets the total value count
  31358. */
  31359. readonly count: number;
  31360. /**
  31361. * Creates a new counter
  31362. */
  31363. constructor();
  31364. /**
  31365. * Call this method to start monitoring a new frame.
  31366. * 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.
  31367. */
  31368. fetchNewFrame(): void;
  31369. /**
  31370. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31371. * @param newCount the count value to add to the monitored count
  31372. * @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.
  31373. */
  31374. addCount(newCount: number, fetchResult: boolean): void;
  31375. /**
  31376. * Start monitoring this performance counter
  31377. */
  31378. beginMonitoring(): void;
  31379. /**
  31380. * Compute the time lapsed since the previous beginMonitoring() call.
  31381. * @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
  31382. */
  31383. endMonitoring(newFrame?: boolean): void;
  31384. private _fetchResult;
  31385. private _startMonitoringTime;
  31386. private _min;
  31387. private _max;
  31388. private _average;
  31389. private _current;
  31390. private _totalValueCount;
  31391. private _totalAccumulated;
  31392. private _lastSecAverage;
  31393. private _lastSecAccumulated;
  31394. private _lastSecTime;
  31395. private _lastSecValueCount;
  31396. }
  31397. /**
  31398. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31399. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31400. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31401. * @param name The name of the class, case should be preserved
  31402. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31403. */
  31404. export function className(name: string, module?: string): (target: Object) => void;
  31405. /**
  31406. * An implementation of a loop for asynchronous functions.
  31407. */
  31408. export class AsyncLoop {
  31409. /**
  31410. * Defines the number of iterations for the loop
  31411. */
  31412. iterations: number;
  31413. /**
  31414. * Defines the current index of the loop.
  31415. */
  31416. index: number;
  31417. private _done;
  31418. private _fn;
  31419. private _successCallback;
  31420. /**
  31421. * Constructor.
  31422. * @param iterations the number of iterations.
  31423. * @param func the function to run each iteration
  31424. * @param successCallback the callback that will be called upon succesful execution
  31425. * @param offset starting offset.
  31426. */
  31427. constructor(
  31428. /**
  31429. * Defines the number of iterations for the loop
  31430. */
  31431. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31432. /**
  31433. * Execute the next iteration. Must be called after the last iteration was finished.
  31434. */
  31435. executeNext(): void;
  31436. /**
  31437. * Break the loop and run the success callback.
  31438. */
  31439. breakLoop(): void;
  31440. /**
  31441. * Create and run an async loop.
  31442. * @param iterations the number of iterations.
  31443. * @param fn the function to run each iteration
  31444. * @param successCallback the callback that will be called upon succesful execution
  31445. * @param offset starting offset.
  31446. * @returns the created async loop object
  31447. */
  31448. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31449. /**
  31450. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31451. * @param iterations total number of iterations
  31452. * @param syncedIterations number of synchronous iterations in each async iteration.
  31453. * @param fn the function to call each iteration.
  31454. * @param callback a success call back that will be called when iterating stops.
  31455. * @param breakFunction a break condition (optional)
  31456. * @param timeout timeout settings for the setTimeout function. default - 0.
  31457. * @returns the created async loop object
  31458. */
  31459. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31460. }
  31461. }
  31462. declare module BABYLON {
  31463. /** @hidden */
  31464. export interface ICollisionCoordinator {
  31465. createCollider(): Collider;
  31466. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31467. init(scene: Scene): void;
  31468. }
  31469. /** @hidden */
  31470. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31471. private _scene;
  31472. private _scaledPosition;
  31473. private _scaledVelocity;
  31474. private _finalPosition;
  31475. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31476. createCollider(): Collider;
  31477. init(scene: Scene): void;
  31478. private _collideWithWorld;
  31479. }
  31480. }
  31481. declare module BABYLON {
  31482. /**
  31483. * This class defines the direct association between an animation and a target
  31484. */
  31485. export class TargetedAnimation {
  31486. /**
  31487. * Animation to perform
  31488. */
  31489. animation: Animation;
  31490. /**
  31491. * Target to animate
  31492. */
  31493. target: any;
  31494. }
  31495. /**
  31496. * Use this class to create coordinated animations on multiple targets
  31497. */
  31498. export class AnimationGroup implements IDisposable {
  31499. /** The name of the animation group */
  31500. name: string;
  31501. private _scene;
  31502. private _targetedAnimations;
  31503. private _animatables;
  31504. private _from;
  31505. private _to;
  31506. private _isStarted;
  31507. private _isPaused;
  31508. private _speedRatio;
  31509. /**
  31510. * Gets or sets the unique id of the node
  31511. */
  31512. uniqueId: number;
  31513. /**
  31514. * This observable will notify when one animation have ended
  31515. */
  31516. onAnimationEndObservable: Observable<TargetedAnimation>;
  31517. /**
  31518. * Observer raised when one animation loops
  31519. */
  31520. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31521. /**
  31522. * This observable will notify when all animations have ended.
  31523. */
  31524. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31525. /**
  31526. * This observable will notify when all animations have paused.
  31527. */
  31528. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31529. /**
  31530. * This observable will notify when all animations are playing.
  31531. */
  31532. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31533. /**
  31534. * Gets the first frame
  31535. */
  31536. readonly from: number;
  31537. /**
  31538. * Gets the last frame
  31539. */
  31540. readonly to: number;
  31541. /**
  31542. * Define if the animations are started
  31543. */
  31544. readonly isStarted: boolean;
  31545. /**
  31546. * Gets a value indicating that the current group is playing
  31547. */
  31548. readonly isPlaying: boolean;
  31549. /**
  31550. * Gets or sets the speed ratio to use for all animations
  31551. */
  31552. /**
  31553. * Gets or sets the speed ratio to use for all animations
  31554. */
  31555. speedRatio: number;
  31556. /**
  31557. * Gets the targeted animations for this animation group
  31558. */
  31559. readonly targetedAnimations: Array<TargetedAnimation>;
  31560. /**
  31561. * returning the list of animatables controlled by this animation group.
  31562. */
  31563. readonly animatables: Array<Animatable>;
  31564. /**
  31565. * Instantiates a new Animation Group.
  31566. * This helps managing several animations at once.
  31567. * @see http://doc.babylonjs.com/how_to/group
  31568. * @param name Defines the name of the group
  31569. * @param scene Defines the scene the group belongs to
  31570. */
  31571. constructor(
  31572. /** The name of the animation group */
  31573. name: string, scene?: Nullable<Scene>);
  31574. /**
  31575. * Add an animation (with its target) in the group
  31576. * @param animation defines the animation we want to add
  31577. * @param target defines the target of the animation
  31578. * @returns the TargetedAnimation object
  31579. */
  31580. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31581. /**
  31582. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31583. * It can add constant keys at begin or end
  31584. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31585. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31586. * @returns the animation group
  31587. */
  31588. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31589. /**
  31590. * Start all animations on given targets
  31591. * @param loop defines if animations must loop
  31592. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31593. * @param from defines the from key (optional)
  31594. * @param to defines the to key (optional)
  31595. * @returns the current animation group
  31596. */
  31597. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31598. /**
  31599. * Pause all animations
  31600. * @returns the animation group
  31601. */
  31602. pause(): AnimationGroup;
  31603. /**
  31604. * Play all animations to initial state
  31605. * This function will start() the animations if they were not started or will restart() them if they were paused
  31606. * @param loop defines if animations must loop
  31607. * @returns the animation group
  31608. */
  31609. play(loop?: boolean): AnimationGroup;
  31610. /**
  31611. * Reset all animations to initial state
  31612. * @returns the animation group
  31613. */
  31614. reset(): AnimationGroup;
  31615. /**
  31616. * Restart animations from key 0
  31617. * @returns the animation group
  31618. */
  31619. restart(): AnimationGroup;
  31620. /**
  31621. * Stop all animations
  31622. * @returns the animation group
  31623. */
  31624. stop(): AnimationGroup;
  31625. /**
  31626. * Set animation weight for all animatables
  31627. * @param weight defines the weight to use
  31628. * @return the animationGroup
  31629. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31630. */
  31631. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31632. /**
  31633. * Synchronize and normalize all animatables with a source animatable
  31634. * @param root defines the root animatable to synchronize with
  31635. * @return the animationGroup
  31636. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31637. */
  31638. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31639. /**
  31640. * Goes to a specific frame in this animation group
  31641. * @param frame the frame number to go to
  31642. * @return the animationGroup
  31643. */
  31644. goToFrame(frame: number): AnimationGroup;
  31645. /**
  31646. * Dispose all associated resources
  31647. */
  31648. dispose(): void;
  31649. private _checkAnimationGroupEnded;
  31650. /**
  31651. * Clone the current animation group and returns a copy
  31652. * @param newName defines the name of the new group
  31653. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31654. * @returns the new aniamtion group
  31655. */
  31656. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31657. /**
  31658. * Returns a new AnimationGroup object parsed from the source provided.
  31659. * @param parsedAnimationGroup defines the source
  31660. * @param scene defines the scene that will receive the animationGroup
  31661. * @returns a new AnimationGroup
  31662. */
  31663. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31664. /**
  31665. * Returns the string "AnimationGroup"
  31666. * @returns "AnimationGroup"
  31667. */
  31668. getClassName(): string;
  31669. /**
  31670. * Creates a detailled string about the object
  31671. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31672. * @returns a string representing the object
  31673. */
  31674. toString(fullDetails?: boolean): string;
  31675. }
  31676. }
  31677. declare module BABYLON {
  31678. /**
  31679. * Define an interface for all classes that will hold resources
  31680. */
  31681. export interface IDisposable {
  31682. /**
  31683. * Releases all held resources
  31684. */
  31685. dispose(): void;
  31686. }
  31687. /** Interface defining initialization parameters for Scene class */
  31688. export interface SceneOptions {
  31689. /**
  31690. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31691. * It will improve performance when the number of geometries becomes important.
  31692. */
  31693. useGeometryUniqueIdsMap?: boolean;
  31694. /**
  31695. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31696. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31697. */
  31698. useMaterialMeshMap?: boolean;
  31699. /**
  31700. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31701. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31702. */
  31703. useClonedMeshhMap?: boolean;
  31704. }
  31705. /**
  31706. * Represents a scene to be rendered by the engine.
  31707. * @see http://doc.babylonjs.com/features/scene
  31708. */
  31709. export class Scene extends AbstractScene implements IAnimatable {
  31710. private static _uniqueIdCounter;
  31711. /** The fog is deactivated */
  31712. static readonly FOGMODE_NONE: number;
  31713. /** The fog density is following an exponential function */
  31714. static readonly FOGMODE_EXP: number;
  31715. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31716. static readonly FOGMODE_EXP2: number;
  31717. /** The fog density is following a linear function. */
  31718. static readonly FOGMODE_LINEAR: number;
  31719. /**
  31720. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31721. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31722. */
  31723. static MinDeltaTime: number;
  31724. /**
  31725. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31726. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31727. */
  31728. static MaxDeltaTime: number;
  31729. /**
  31730. * Factory used to create the default material.
  31731. * @param name The name of the material to create
  31732. * @param scene The scene to create the material for
  31733. * @returns The default material
  31734. */
  31735. static DefaultMaterialFactory(scene: Scene): Material;
  31736. /**
  31737. * Factory used to create the a collision coordinator.
  31738. * @returns The collision coordinator
  31739. */
  31740. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31741. /** @hidden */
  31742. readonly _isScene: boolean;
  31743. /**
  31744. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31745. */
  31746. autoClear: boolean;
  31747. /**
  31748. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31749. */
  31750. autoClearDepthAndStencil: boolean;
  31751. /**
  31752. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31753. */
  31754. clearColor: Color4;
  31755. /**
  31756. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31757. */
  31758. ambientColor: Color3;
  31759. /**
  31760. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31761. * It should only be one of the following (if not the default embedded one):
  31762. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31763. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31764. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31765. * The material properties need to be setup according to the type of texture in use.
  31766. */
  31767. environmentBRDFTexture: BaseTexture;
  31768. /** @hidden */
  31769. protected _environmentTexture: Nullable<BaseTexture>;
  31770. /**
  31771. * Texture used in all pbr material as the reflection texture.
  31772. * As in the majority of the scene they are the same (exception for multi room and so on),
  31773. * this is easier to reference from here than from all the materials.
  31774. */
  31775. /**
  31776. * Texture used in all pbr material as the reflection texture.
  31777. * As in the majority of the scene they are the same (exception for multi room and so on),
  31778. * this is easier to set here than in all the materials.
  31779. */
  31780. environmentTexture: Nullable<BaseTexture>;
  31781. /** @hidden */
  31782. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31783. /**
  31784. * Default image processing configuration used either in the rendering
  31785. * Forward main pass or through the imageProcessingPostProcess if present.
  31786. * As in the majority of the scene they are the same (exception for multi camera),
  31787. * this is easier to reference from here than from all the materials and post process.
  31788. *
  31789. * No setter as we it is a shared configuration, you can set the values instead.
  31790. */
  31791. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31792. private _forceWireframe;
  31793. /**
  31794. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31795. */
  31796. forceWireframe: boolean;
  31797. private _forcePointsCloud;
  31798. /**
  31799. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31800. */
  31801. forcePointsCloud: boolean;
  31802. /**
  31803. * Gets or sets the active clipplane 1
  31804. */
  31805. clipPlane: Nullable<Plane>;
  31806. /**
  31807. * Gets or sets the active clipplane 2
  31808. */
  31809. clipPlane2: Nullable<Plane>;
  31810. /**
  31811. * Gets or sets the active clipplane 3
  31812. */
  31813. clipPlane3: Nullable<Plane>;
  31814. /**
  31815. * Gets or sets the active clipplane 4
  31816. */
  31817. clipPlane4: Nullable<Plane>;
  31818. /**
  31819. * Gets or sets a boolean indicating if animations are enabled
  31820. */
  31821. animationsEnabled: boolean;
  31822. private _animationPropertiesOverride;
  31823. /**
  31824. * Gets or sets the animation properties override
  31825. */
  31826. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31827. /**
  31828. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31829. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31830. */
  31831. useConstantAnimationDeltaTime: boolean;
  31832. /**
  31833. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31834. * Please note that it requires to run a ray cast through the scene on every frame
  31835. */
  31836. constantlyUpdateMeshUnderPointer: boolean;
  31837. /**
  31838. * Defines the HTML cursor to use when hovering over interactive elements
  31839. */
  31840. hoverCursor: string;
  31841. /**
  31842. * Defines the HTML default cursor to use (empty by default)
  31843. */
  31844. defaultCursor: string;
  31845. /**
  31846. * This is used to call preventDefault() on pointer down
  31847. * in order to block unwanted artifacts like system double clicks
  31848. */
  31849. preventDefaultOnPointerDown: boolean;
  31850. /**
  31851. * This is used to call preventDefault() on pointer up
  31852. * in order to block unwanted artifacts like system double clicks
  31853. */
  31854. preventDefaultOnPointerUp: boolean;
  31855. /**
  31856. * Gets or sets user defined metadata
  31857. */
  31858. metadata: any;
  31859. /**
  31860. * For internal use only. Please do not use.
  31861. */
  31862. reservedDataStore: any;
  31863. /**
  31864. * Gets the name of the plugin used to load this scene (null by default)
  31865. */
  31866. loadingPluginName: string;
  31867. /**
  31868. * Use this array to add regular expressions used to disable offline support for specific urls
  31869. */
  31870. disableOfflineSupportExceptionRules: RegExp[];
  31871. /**
  31872. * An event triggered when the scene is disposed.
  31873. */
  31874. onDisposeObservable: Observable<Scene>;
  31875. private _onDisposeObserver;
  31876. /** Sets a function to be executed when this scene is disposed. */
  31877. onDispose: () => void;
  31878. /**
  31879. * An event triggered before rendering the scene (right after animations and physics)
  31880. */
  31881. onBeforeRenderObservable: Observable<Scene>;
  31882. private _onBeforeRenderObserver;
  31883. /** Sets a function to be executed before rendering this scene */
  31884. beforeRender: Nullable<() => void>;
  31885. /**
  31886. * An event triggered after rendering the scene
  31887. */
  31888. onAfterRenderObservable: Observable<Scene>;
  31889. private _onAfterRenderObserver;
  31890. /** Sets a function to be executed after rendering this scene */
  31891. afterRender: Nullable<() => void>;
  31892. /**
  31893. * An event triggered before animating the scene
  31894. */
  31895. onBeforeAnimationsObservable: Observable<Scene>;
  31896. /**
  31897. * An event triggered after animations processing
  31898. */
  31899. onAfterAnimationsObservable: Observable<Scene>;
  31900. /**
  31901. * An event triggered before draw calls are ready to be sent
  31902. */
  31903. onBeforeDrawPhaseObservable: Observable<Scene>;
  31904. /**
  31905. * An event triggered after draw calls have been sent
  31906. */
  31907. onAfterDrawPhaseObservable: Observable<Scene>;
  31908. /**
  31909. * An event triggered when the scene is ready
  31910. */
  31911. onReadyObservable: Observable<Scene>;
  31912. /**
  31913. * An event triggered before rendering a camera
  31914. */
  31915. onBeforeCameraRenderObservable: Observable<Camera>;
  31916. private _onBeforeCameraRenderObserver;
  31917. /** Sets a function to be executed before rendering a camera*/
  31918. beforeCameraRender: () => void;
  31919. /**
  31920. * An event triggered after rendering a camera
  31921. */
  31922. onAfterCameraRenderObservable: Observable<Camera>;
  31923. private _onAfterCameraRenderObserver;
  31924. /** Sets a function to be executed after rendering a camera*/
  31925. afterCameraRender: () => void;
  31926. /**
  31927. * An event triggered when active meshes evaluation is about to start
  31928. */
  31929. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31930. /**
  31931. * An event triggered when active meshes evaluation is done
  31932. */
  31933. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31934. /**
  31935. * An event triggered when particles rendering is about to start
  31936. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31937. */
  31938. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31939. /**
  31940. * An event triggered when particles rendering is done
  31941. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31942. */
  31943. onAfterParticlesRenderingObservable: Observable<Scene>;
  31944. /**
  31945. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31946. */
  31947. onDataLoadedObservable: Observable<Scene>;
  31948. /**
  31949. * An event triggered when a camera is created
  31950. */
  31951. onNewCameraAddedObservable: Observable<Camera>;
  31952. /**
  31953. * An event triggered when a camera is removed
  31954. */
  31955. onCameraRemovedObservable: Observable<Camera>;
  31956. /**
  31957. * An event triggered when a light is created
  31958. */
  31959. onNewLightAddedObservable: Observable<Light>;
  31960. /**
  31961. * An event triggered when a light is removed
  31962. */
  31963. onLightRemovedObservable: Observable<Light>;
  31964. /**
  31965. * An event triggered when a geometry is created
  31966. */
  31967. onNewGeometryAddedObservable: Observable<Geometry>;
  31968. /**
  31969. * An event triggered when a geometry is removed
  31970. */
  31971. onGeometryRemovedObservable: Observable<Geometry>;
  31972. /**
  31973. * An event triggered when a transform node is created
  31974. */
  31975. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31976. /**
  31977. * An event triggered when a transform node is removed
  31978. */
  31979. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31980. /**
  31981. * An event triggered when a mesh is created
  31982. */
  31983. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31984. /**
  31985. * An event triggered when a mesh is removed
  31986. */
  31987. onMeshRemovedObservable: Observable<AbstractMesh>;
  31988. /**
  31989. * An event triggered when a skeleton is created
  31990. */
  31991. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31992. /**
  31993. * An event triggered when a skeleton is removed
  31994. */
  31995. onSkeletonRemovedObservable: Observable<Skeleton>;
  31996. /**
  31997. * An event triggered when a material is created
  31998. */
  31999. onNewMaterialAddedObservable: Observable<Material>;
  32000. /**
  32001. * An event triggered when a material is removed
  32002. */
  32003. onMaterialRemovedObservable: Observable<Material>;
  32004. /**
  32005. * An event triggered when a texture is created
  32006. */
  32007. onNewTextureAddedObservable: Observable<BaseTexture>;
  32008. /**
  32009. * An event triggered when a texture is removed
  32010. */
  32011. onTextureRemovedObservable: Observable<BaseTexture>;
  32012. /**
  32013. * An event triggered when render targets are about to be rendered
  32014. * Can happen multiple times per frame.
  32015. */
  32016. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32017. /**
  32018. * An event triggered when render targets were rendered.
  32019. * Can happen multiple times per frame.
  32020. */
  32021. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32022. /**
  32023. * An event triggered before calculating deterministic simulation step
  32024. */
  32025. onBeforeStepObservable: Observable<Scene>;
  32026. /**
  32027. * An event triggered after calculating deterministic simulation step
  32028. */
  32029. onAfterStepObservable: Observable<Scene>;
  32030. /**
  32031. * An event triggered when the activeCamera property is updated
  32032. */
  32033. onActiveCameraChanged: Observable<Scene>;
  32034. /**
  32035. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32036. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32037. * 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)
  32038. */
  32039. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32040. /**
  32041. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32042. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32043. * 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)
  32044. */
  32045. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32046. /**
  32047. * This Observable will when a mesh has been imported into the scene.
  32048. */
  32049. onMeshImportedObservable: Observable<AbstractMesh>;
  32050. /**
  32051. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32052. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32053. */
  32054. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32055. /** @hidden */
  32056. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32057. /**
  32058. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32059. */
  32060. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32061. /**
  32062. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32063. */
  32064. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32065. /**
  32066. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32067. */
  32068. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32069. private _onPointerMove;
  32070. private _onPointerDown;
  32071. private _onPointerUp;
  32072. /** Callback called when a pointer move is detected */
  32073. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32074. /** Callback called when a pointer down is detected */
  32075. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32076. /** Callback called when a pointer up is detected */
  32077. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32078. /** Callback called when a pointer pick is detected */
  32079. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32080. /**
  32081. * 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).
  32082. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32083. */
  32084. onPrePointerObservable: Observable<PointerInfoPre>;
  32085. /**
  32086. * Observable event triggered each time an input event is received from the rendering canvas
  32087. */
  32088. onPointerObservable: Observable<PointerInfo>;
  32089. /**
  32090. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32091. */
  32092. readonly unTranslatedPointer: Vector2;
  32093. /** The distance in pixel that you have to move to prevent some events */
  32094. static DragMovementThreshold: number;
  32095. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32096. static LongPressDelay: number;
  32097. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32098. static DoubleClickDelay: number;
  32099. /** If you need to check double click without raising a single click at first click, enable this flag */
  32100. static ExclusiveDoubleClickMode: boolean;
  32101. private _initClickEvent;
  32102. private _initActionManager;
  32103. private _delayedSimpleClick;
  32104. private _delayedSimpleClickTimeout;
  32105. private _previousDelayedSimpleClickTimeout;
  32106. private _meshPickProceed;
  32107. private _previousButtonPressed;
  32108. private _currentPickResult;
  32109. private _previousPickResult;
  32110. private _totalPointersPressed;
  32111. private _doubleClickOccured;
  32112. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32113. cameraToUseForPointers: Nullable<Camera>;
  32114. private _pointerX;
  32115. private _pointerY;
  32116. private _unTranslatedPointerX;
  32117. private _unTranslatedPointerY;
  32118. private _startingPointerPosition;
  32119. private _previousStartingPointerPosition;
  32120. private _startingPointerTime;
  32121. private _previousStartingPointerTime;
  32122. private _pointerCaptures;
  32123. private _timeAccumulator;
  32124. private _currentStepId;
  32125. private _currentInternalStep;
  32126. /** @hidden */
  32127. _mirroredCameraPosition: Nullable<Vector3>;
  32128. /**
  32129. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32130. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32131. */
  32132. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32133. /**
  32134. * Observable event triggered each time an keyboard event is received from the hosting window
  32135. */
  32136. onKeyboardObservable: Observable<KeyboardInfo>;
  32137. private _onKeyDown;
  32138. private _onKeyUp;
  32139. private _onCanvasFocusObserver;
  32140. private _onCanvasBlurObserver;
  32141. private _useRightHandedSystem;
  32142. /**
  32143. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32144. */
  32145. useRightHandedSystem: boolean;
  32146. /**
  32147. * Sets the step Id used by deterministic lock step
  32148. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32149. * @param newStepId defines the step Id
  32150. */
  32151. setStepId(newStepId: number): void;
  32152. /**
  32153. * Gets the step Id used by deterministic lock step
  32154. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32155. * @returns the step Id
  32156. */
  32157. getStepId(): number;
  32158. /**
  32159. * Gets the internal step used by deterministic lock step
  32160. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32161. * @returns the internal step
  32162. */
  32163. getInternalStep(): number;
  32164. private _fogEnabled;
  32165. /**
  32166. * Gets or sets a boolean indicating if fog is enabled on this scene
  32167. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32168. * (Default is true)
  32169. */
  32170. fogEnabled: boolean;
  32171. private _fogMode;
  32172. /**
  32173. * Gets or sets the fog mode to use
  32174. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32175. * | mode | value |
  32176. * | --- | --- |
  32177. * | FOGMODE_NONE | 0 |
  32178. * | FOGMODE_EXP | 1 |
  32179. * | FOGMODE_EXP2 | 2 |
  32180. * | FOGMODE_LINEAR | 3 |
  32181. */
  32182. fogMode: number;
  32183. /**
  32184. * Gets or sets the fog color to use
  32185. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32186. * (Default is Color3(0.2, 0.2, 0.3))
  32187. */
  32188. fogColor: Color3;
  32189. /**
  32190. * Gets or sets the fog density to use
  32191. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32192. * (Default is 0.1)
  32193. */
  32194. fogDensity: number;
  32195. /**
  32196. * Gets or sets the fog start distance to use
  32197. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32198. * (Default is 0)
  32199. */
  32200. fogStart: number;
  32201. /**
  32202. * Gets or sets the fog end distance to use
  32203. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32204. * (Default is 1000)
  32205. */
  32206. fogEnd: number;
  32207. private _shadowsEnabled;
  32208. /**
  32209. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32210. */
  32211. shadowsEnabled: boolean;
  32212. private _lightsEnabled;
  32213. /**
  32214. * Gets or sets a boolean indicating if lights are enabled on this scene
  32215. */
  32216. lightsEnabled: boolean;
  32217. /** All of the active cameras added to this scene. */
  32218. activeCameras: Camera[];
  32219. /** @hidden */
  32220. _activeCamera: Nullable<Camera>;
  32221. /** Gets or sets the current active camera */
  32222. activeCamera: Nullable<Camera>;
  32223. private _defaultMaterial;
  32224. /** The default material used on meshes when no material is affected */
  32225. /** The default material used on meshes when no material is affected */
  32226. defaultMaterial: Material;
  32227. private _texturesEnabled;
  32228. /**
  32229. * Gets or sets a boolean indicating if textures are enabled on this scene
  32230. */
  32231. texturesEnabled: boolean;
  32232. /**
  32233. * Gets or sets a boolean indicating if particles are enabled on this scene
  32234. */
  32235. particlesEnabled: boolean;
  32236. /**
  32237. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32238. */
  32239. spritesEnabled: boolean;
  32240. private _skeletonsEnabled;
  32241. /**
  32242. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32243. */
  32244. skeletonsEnabled: boolean;
  32245. /**
  32246. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32247. */
  32248. lensFlaresEnabled: boolean;
  32249. /**
  32250. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32251. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32252. */
  32253. collisionsEnabled: boolean;
  32254. private _collisionCoordinator;
  32255. /** @hidden */
  32256. readonly collisionCoordinator: ICollisionCoordinator;
  32257. /**
  32258. * Defines the gravity applied to this scene (used only for collisions)
  32259. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32260. */
  32261. gravity: Vector3;
  32262. /**
  32263. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32264. */
  32265. postProcessesEnabled: boolean;
  32266. /**
  32267. * The list of postprocesses added to the scene
  32268. */
  32269. postProcesses: PostProcess[];
  32270. /**
  32271. * Gets the current postprocess manager
  32272. */
  32273. postProcessManager: PostProcessManager;
  32274. /**
  32275. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32276. */
  32277. renderTargetsEnabled: boolean;
  32278. /**
  32279. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32280. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32281. */
  32282. dumpNextRenderTargets: boolean;
  32283. /**
  32284. * The list of user defined render targets added to the scene
  32285. */
  32286. customRenderTargets: RenderTargetTexture[];
  32287. /**
  32288. * Defines if texture loading must be delayed
  32289. * If true, textures will only be loaded when they need to be rendered
  32290. */
  32291. useDelayedTextureLoading: boolean;
  32292. /**
  32293. * Gets the list of meshes imported to the scene through SceneLoader
  32294. */
  32295. importedMeshesFiles: String[];
  32296. /**
  32297. * Gets or sets a boolean indicating if probes are enabled on this scene
  32298. */
  32299. probesEnabled: boolean;
  32300. /**
  32301. * Gets or sets the current offline provider to use to store scene data
  32302. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32303. */
  32304. offlineProvider: IOfflineProvider;
  32305. /**
  32306. * Gets or sets the action manager associated with the scene
  32307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32308. */
  32309. actionManager: AbstractActionManager;
  32310. private _meshesForIntersections;
  32311. /**
  32312. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32313. */
  32314. proceduralTexturesEnabled: boolean;
  32315. private _engine;
  32316. private _totalVertices;
  32317. /** @hidden */
  32318. _activeIndices: PerfCounter;
  32319. /** @hidden */
  32320. _activeParticles: PerfCounter;
  32321. /** @hidden */
  32322. _activeBones: PerfCounter;
  32323. private _animationRatio;
  32324. /** @hidden */
  32325. _animationTimeLast: number;
  32326. /** @hidden */
  32327. _animationTime: number;
  32328. /**
  32329. * Gets or sets a general scale for animation speed
  32330. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32331. */
  32332. animationTimeScale: number;
  32333. /** @hidden */
  32334. _cachedMaterial: Nullable<Material>;
  32335. /** @hidden */
  32336. _cachedEffect: Nullable<Effect>;
  32337. /** @hidden */
  32338. _cachedVisibility: Nullable<number>;
  32339. private _renderId;
  32340. private _frameId;
  32341. private _executeWhenReadyTimeoutId;
  32342. private _intermediateRendering;
  32343. private _viewUpdateFlag;
  32344. private _projectionUpdateFlag;
  32345. /** @hidden */
  32346. _toBeDisposed: Nullable<IDisposable>[];
  32347. private _activeRequests;
  32348. /** @hidden */
  32349. _pendingData: any[];
  32350. private _isDisposed;
  32351. /**
  32352. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32353. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32354. */
  32355. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32356. private _activeMeshes;
  32357. private _processedMaterials;
  32358. private _renderTargets;
  32359. /** @hidden */
  32360. _activeParticleSystems: SmartArray<IParticleSystem>;
  32361. private _activeSkeletons;
  32362. private _softwareSkinnedMeshes;
  32363. private _renderingManager;
  32364. /** @hidden */
  32365. _activeAnimatables: Animatable[];
  32366. private _transformMatrix;
  32367. private _sceneUbo;
  32368. /** @hidden */
  32369. _viewMatrix: Matrix;
  32370. private _projectionMatrix;
  32371. private _wheelEventName;
  32372. /** @hidden */
  32373. _forcedViewPosition: Nullable<Vector3>;
  32374. /** @hidden */
  32375. _frustumPlanes: Plane[];
  32376. /**
  32377. * Gets the list of frustum planes (built from the active camera)
  32378. */
  32379. readonly frustumPlanes: Plane[];
  32380. /**
  32381. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32382. * This is useful if there are more lights that the maximum simulteanous authorized
  32383. */
  32384. requireLightSorting: boolean;
  32385. /** @hidden */
  32386. readonly useMaterialMeshMap: boolean;
  32387. /** @hidden */
  32388. readonly useClonedMeshhMap: boolean;
  32389. private _pointerOverMesh;
  32390. private _pickedDownMesh;
  32391. private _pickedUpMesh;
  32392. private _externalData;
  32393. private _uid;
  32394. /**
  32395. * @hidden
  32396. * Backing store of defined scene components.
  32397. */
  32398. _components: ISceneComponent[];
  32399. /**
  32400. * @hidden
  32401. * Backing store of defined scene components.
  32402. */
  32403. _serializableComponents: ISceneSerializableComponent[];
  32404. /**
  32405. * List of components to register on the next registration step.
  32406. */
  32407. private _transientComponents;
  32408. /**
  32409. * Registers the transient components if needed.
  32410. */
  32411. private _registerTransientComponents;
  32412. /**
  32413. * @hidden
  32414. * Add a component to the scene.
  32415. * Note that the ccomponent could be registered on th next frame if this is called after
  32416. * the register component stage.
  32417. * @param component Defines the component to add to the scene
  32418. */
  32419. _addComponent(component: ISceneComponent): void;
  32420. /**
  32421. * @hidden
  32422. * Gets a component from the scene.
  32423. * @param name defines the name of the component to retrieve
  32424. * @returns the component or null if not present
  32425. */
  32426. _getComponent(name: string): Nullable<ISceneComponent>;
  32427. /**
  32428. * @hidden
  32429. * Defines the actions happening before camera updates.
  32430. */
  32431. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32432. /**
  32433. * @hidden
  32434. * Defines the actions happening before clear the canvas.
  32435. */
  32436. _beforeClearStage: Stage<SimpleStageAction>;
  32437. /**
  32438. * @hidden
  32439. * Defines the actions when collecting render targets for the frame.
  32440. */
  32441. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32442. /**
  32443. * @hidden
  32444. * Defines the actions happening for one camera in the frame.
  32445. */
  32446. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32447. /**
  32448. * @hidden
  32449. * Defines the actions happening during the per mesh ready checks.
  32450. */
  32451. _isReadyForMeshStage: Stage<MeshStageAction>;
  32452. /**
  32453. * @hidden
  32454. * Defines the actions happening before evaluate active mesh checks.
  32455. */
  32456. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32457. /**
  32458. * @hidden
  32459. * Defines the actions happening during the evaluate sub mesh checks.
  32460. */
  32461. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32462. /**
  32463. * @hidden
  32464. * Defines the actions happening during the active mesh stage.
  32465. */
  32466. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32467. /**
  32468. * @hidden
  32469. * Defines the actions happening during the per camera render target step.
  32470. */
  32471. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32472. /**
  32473. * @hidden
  32474. * Defines the actions happening just before the active camera is drawing.
  32475. */
  32476. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32477. /**
  32478. * @hidden
  32479. * Defines the actions happening just before a render target is drawing.
  32480. */
  32481. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32482. /**
  32483. * @hidden
  32484. * Defines the actions happening just before a rendering group is drawing.
  32485. */
  32486. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32487. /**
  32488. * @hidden
  32489. * Defines the actions happening just before a mesh is drawing.
  32490. */
  32491. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32492. /**
  32493. * @hidden
  32494. * Defines the actions happening just after a mesh has been drawn.
  32495. */
  32496. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32497. /**
  32498. * @hidden
  32499. * Defines the actions happening just after a rendering group has been drawn.
  32500. */
  32501. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32502. /**
  32503. * @hidden
  32504. * Defines the actions happening just after the active camera has been drawn.
  32505. */
  32506. _afterCameraDrawStage: Stage<CameraStageAction>;
  32507. /**
  32508. * @hidden
  32509. * Defines the actions happening just after a render target has been drawn.
  32510. */
  32511. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32512. /**
  32513. * @hidden
  32514. * Defines the actions happening just after rendering all cameras and computing intersections.
  32515. */
  32516. _afterRenderStage: Stage<SimpleStageAction>;
  32517. /**
  32518. * @hidden
  32519. * Defines the actions happening when a pointer move event happens.
  32520. */
  32521. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32522. /**
  32523. * @hidden
  32524. * Defines the actions happening when a pointer down event happens.
  32525. */
  32526. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32527. /**
  32528. * @hidden
  32529. * Defines the actions happening when a pointer up event happens.
  32530. */
  32531. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32532. /**
  32533. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32534. */
  32535. private geometriesByUniqueId;
  32536. /**
  32537. * Creates a new Scene
  32538. * @param engine defines the engine to use to render this scene
  32539. * @param options defines the scene options
  32540. */
  32541. constructor(engine: Engine, options?: SceneOptions);
  32542. /**
  32543. * Gets a string idenfifying the name of the class
  32544. * @returns "Scene" string
  32545. */
  32546. getClassName(): string;
  32547. private _defaultMeshCandidates;
  32548. /**
  32549. * @hidden
  32550. */
  32551. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32552. private _defaultSubMeshCandidates;
  32553. /**
  32554. * @hidden
  32555. */
  32556. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32557. /**
  32558. * Sets the default candidate providers for the scene.
  32559. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32560. * and getCollidingSubMeshCandidates to their default function
  32561. */
  32562. setDefaultCandidateProviders(): void;
  32563. /**
  32564. * Gets the mesh that is currently under the pointer
  32565. */
  32566. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32567. /**
  32568. * Gets or sets the current on-screen X position of the pointer
  32569. */
  32570. pointerX: number;
  32571. /**
  32572. * Gets or sets the current on-screen Y position of the pointer
  32573. */
  32574. pointerY: number;
  32575. /**
  32576. * Gets the cached material (ie. the latest rendered one)
  32577. * @returns the cached material
  32578. */
  32579. getCachedMaterial(): Nullable<Material>;
  32580. /**
  32581. * Gets the cached effect (ie. the latest rendered one)
  32582. * @returns the cached effect
  32583. */
  32584. getCachedEffect(): Nullable<Effect>;
  32585. /**
  32586. * Gets the cached visibility state (ie. the latest rendered one)
  32587. * @returns the cached visibility state
  32588. */
  32589. getCachedVisibility(): Nullable<number>;
  32590. /**
  32591. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32592. * @param material defines the current material
  32593. * @param effect defines the current effect
  32594. * @param visibility defines the current visibility state
  32595. * @returns true if one parameter is not cached
  32596. */
  32597. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32598. /**
  32599. * Gets the engine associated with the scene
  32600. * @returns an Engine
  32601. */
  32602. getEngine(): Engine;
  32603. /**
  32604. * Gets the total number of vertices rendered per frame
  32605. * @returns the total number of vertices rendered per frame
  32606. */
  32607. getTotalVertices(): number;
  32608. /**
  32609. * Gets the performance counter for total vertices
  32610. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32611. */
  32612. readonly totalVerticesPerfCounter: PerfCounter;
  32613. /**
  32614. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32615. * @returns the total number of active indices rendered per frame
  32616. */
  32617. getActiveIndices(): number;
  32618. /**
  32619. * Gets the performance counter for active indices
  32620. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32621. */
  32622. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32623. /**
  32624. * Gets the total number of active particles rendered per frame
  32625. * @returns the total number of active particles rendered per frame
  32626. */
  32627. getActiveParticles(): number;
  32628. /**
  32629. * Gets the performance counter for active particles
  32630. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32631. */
  32632. readonly activeParticlesPerfCounter: PerfCounter;
  32633. /**
  32634. * Gets the total number of active bones rendered per frame
  32635. * @returns the total number of active bones rendered per frame
  32636. */
  32637. getActiveBones(): number;
  32638. /**
  32639. * Gets the performance counter for active bones
  32640. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32641. */
  32642. readonly activeBonesPerfCounter: PerfCounter;
  32643. /**
  32644. * Gets the array of active meshes
  32645. * @returns an array of AbstractMesh
  32646. */
  32647. getActiveMeshes(): SmartArray<AbstractMesh>;
  32648. /**
  32649. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32650. * @returns a number
  32651. */
  32652. getAnimationRatio(): number;
  32653. /**
  32654. * Gets an unique Id for the current render phase
  32655. * @returns a number
  32656. */
  32657. getRenderId(): number;
  32658. /**
  32659. * Gets an unique Id for the current frame
  32660. * @returns a number
  32661. */
  32662. getFrameId(): number;
  32663. /** Call this function if you want to manually increment the render Id*/
  32664. incrementRenderId(): void;
  32665. private _updatePointerPosition;
  32666. private _createUbo;
  32667. private _setRayOnPointerInfo;
  32668. /**
  32669. * Use this method to simulate a pointer move on a mesh
  32670. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32671. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32672. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32673. * @returns the current scene
  32674. */
  32675. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32676. private _processPointerMove;
  32677. private _checkPrePointerObservable;
  32678. /**
  32679. * Use this method to simulate a pointer down on a mesh
  32680. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32681. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32682. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32683. * @returns the current scene
  32684. */
  32685. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32686. private _processPointerDown;
  32687. /**
  32688. * Use this method to simulate a pointer up on a mesh
  32689. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32690. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32691. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32692. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32693. * @returns the current scene
  32694. */
  32695. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32696. private _processPointerUp;
  32697. /**
  32698. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32699. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32700. * @returns true if the pointer was captured
  32701. */
  32702. isPointerCaptured(pointerId?: number): boolean;
  32703. /** @hidden */
  32704. _isPointerSwiping(): boolean;
  32705. /**
  32706. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32707. * @param attachUp defines if you want to attach events to pointerup
  32708. * @param attachDown defines if you want to attach events to pointerdown
  32709. * @param attachMove defines if you want to attach events to pointermove
  32710. */
  32711. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32712. /** Detaches all event handlers*/
  32713. detachControl(): void;
  32714. /**
  32715. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32716. * Delay loaded resources are not taking in account
  32717. * @return true if all required resources are ready
  32718. */
  32719. isReady(): boolean;
  32720. /** Resets all cached information relative to material (including effect and visibility) */
  32721. resetCachedMaterial(): void;
  32722. /**
  32723. * Registers a function to be called before every frame render
  32724. * @param func defines the function to register
  32725. */
  32726. registerBeforeRender(func: () => void): void;
  32727. /**
  32728. * Unregisters a function called before every frame render
  32729. * @param func defines the function to unregister
  32730. */
  32731. unregisterBeforeRender(func: () => void): void;
  32732. /**
  32733. * Registers a function to be called after every frame render
  32734. * @param func defines the function to register
  32735. */
  32736. registerAfterRender(func: () => void): void;
  32737. /**
  32738. * Unregisters a function called after every frame render
  32739. * @param func defines the function to unregister
  32740. */
  32741. unregisterAfterRender(func: () => void): void;
  32742. private _executeOnceBeforeRender;
  32743. /**
  32744. * The provided function will run before render once and will be disposed afterwards.
  32745. * A timeout delay can be provided so that the function will be executed in N ms.
  32746. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32747. * @param func The function to be executed.
  32748. * @param timeout optional delay in ms
  32749. */
  32750. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32751. /** @hidden */
  32752. _addPendingData(data: any): void;
  32753. /** @hidden */
  32754. _removePendingData(data: any): void;
  32755. /**
  32756. * Returns the number of items waiting to be loaded
  32757. * @returns the number of items waiting to be loaded
  32758. */
  32759. getWaitingItemsCount(): number;
  32760. /**
  32761. * Returns a boolean indicating if the scene is still loading data
  32762. */
  32763. readonly isLoading: boolean;
  32764. /**
  32765. * Registers a function to be executed when the scene is ready
  32766. * @param {Function} func - the function to be executed
  32767. */
  32768. executeWhenReady(func: () => void): void;
  32769. /**
  32770. * Returns a promise that resolves when the scene is ready
  32771. * @returns A promise that resolves when the scene is ready
  32772. */
  32773. whenReadyAsync(): Promise<void>;
  32774. /** @hidden */
  32775. _checkIsReady(): void;
  32776. /**
  32777. * Gets all animatable attached to the scene
  32778. */
  32779. readonly animatables: Animatable[];
  32780. /**
  32781. * Resets the last animation time frame.
  32782. * Useful to override when animations start running when loading a scene for the first time.
  32783. */
  32784. resetLastAnimationTimeFrame(): void;
  32785. /**
  32786. * Gets the current view matrix
  32787. * @returns a Matrix
  32788. */
  32789. getViewMatrix(): Matrix;
  32790. /**
  32791. * Gets the current projection matrix
  32792. * @returns a Matrix
  32793. */
  32794. getProjectionMatrix(): Matrix;
  32795. /**
  32796. * Gets the current transform matrix
  32797. * @returns a Matrix made of View * Projection
  32798. */
  32799. getTransformMatrix(): Matrix;
  32800. /**
  32801. * Sets the current transform matrix
  32802. * @param viewL defines the View matrix to use
  32803. * @param projectionL defines the Projection matrix to use
  32804. * @param viewR defines the right View matrix to use (if provided)
  32805. * @param projectionR defines the right Projection matrix to use (if provided)
  32806. */
  32807. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32808. /**
  32809. * Gets the uniform buffer used to store scene data
  32810. * @returns a UniformBuffer
  32811. */
  32812. getSceneUniformBuffer(): UniformBuffer;
  32813. /**
  32814. * Gets an unique (relatively to the current scene) Id
  32815. * @returns an unique number for the scene
  32816. */
  32817. getUniqueId(): number;
  32818. /**
  32819. * Add a mesh to the list of scene's meshes
  32820. * @param newMesh defines the mesh to add
  32821. * @param recursive if all child meshes should also be added to the scene
  32822. */
  32823. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32824. /**
  32825. * Remove a mesh for the list of scene's meshes
  32826. * @param toRemove defines the mesh to remove
  32827. * @param recursive if all child meshes should also be removed from the scene
  32828. * @returns the index where the mesh was in the mesh list
  32829. */
  32830. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32831. /**
  32832. * Add a transform node to the list of scene's transform nodes
  32833. * @param newTransformNode defines the transform node to add
  32834. */
  32835. addTransformNode(newTransformNode: TransformNode): void;
  32836. /**
  32837. * Remove a transform node for the list of scene's transform nodes
  32838. * @param toRemove defines the transform node to remove
  32839. * @returns the index where the transform node was in the transform node list
  32840. */
  32841. removeTransformNode(toRemove: TransformNode): number;
  32842. /**
  32843. * Remove a skeleton for the list of scene's skeletons
  32844. * @param toRemove defines the skeleton to remove
  32845. * @returns the index where the skeleton was in the skeleton list
  32846. */
  32847. removeSkeleton(toRemove: Skeleton): number;
  32848. /**
  32849. * Remove a morph target for the list of scene's morph targets
  32850. * @param toRemove defines the morph target to remove
  32851. * @returns the index where the morph target was in the morph target list
  32852. */
  32853. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32854. /**
  32855. * Remove a light for the list of scene's lights
  32856. * @param toRemove defines the light to remove
  32857. * @returns the index where the light was in the light list
  32858. */
  32859. removeLight(toRemove: Light): number;
  32860. /**
  32861. * Remove a camera for the list of scene's cameras
  32862. * @param toRemove defines the camera to remove
  32863. * @returns the index where the camera was in the camera list
  32864. */
  32865. removeCamera(toRemove: Camera): number;
  32866. /**
  32867. * Remove a particle system for the list of scene's particle systems
  32868. * @param toRemove defines the particle system to remove
  32869. * @returns the index where the particle system was in the particle system list
  32870. */
  32871. removeParticleSystem(toRemove: IParticleSystem): number;
  32872. /**
  32873. * Remove a animation for the list of scene's animations
  32874. * @param toRemove defines the animation to remove
  32875. * @returns the index where the animation was in the animation list
  32876. */
  32877. removeAnimation(toRemove: Animation): number;
  32878. /**
  32879. * Removes the given animation group from this scene.
  32880. * @param toRemove The animation group to remove
  32881. * @returns The index of the removed animation group
  32882. */
  32883. removeAnimationGroup(toRemove: AnimationGroup): number;
  32884. /**
  32885. * Removes the given multi-material from this scene.
  32886. * @param toRemove The multi-material to remove
  32887. * @returns The index of the removed multi-material
  32888. */
  32889. removeMultiMaterial(toRemove: MultiMaterial): number;
  32890. /**
  32891. * Removes the given material from this scene.
  32892. * @param toRemove The material to remove
  32893. * @returns The index of the removed material
  32894. */
  32895. removeMaterial(toRemove: Material): number;
  32896. /**
  32897. * Removes the given action manager from this scene.
  32898. * @param toRemove The action manager to remove
  32899. * @returns The index of the removed action manager
  32900. */
  32901. removeActionManager(toRemove: AbstractActionManager): number;
  32902. /**
  32903. * Removes the given texture from this scene.
  32904. * @param toRemove The texture to remove
  32905. * @returns The index of the removed texture
  32906. */
  32907. removeTexture(toRemove: BaseTexture): number;
  32908. /**
  32909. * Adds the given light to this scene
  32910. * @param newLight The light to add
  32911. */
  32912. addLight(newLight: Light): void;
  32913. /**
  32914. * Sorts the list list based on light priorities
  32915. */
  32916. sortLightsByPriority(): void;
  32917. /**
  32918. * Adds the given camera to this scene
  32919. * @param newCamera The camera to add
  32920. */
  32921. addCamera(newCamera: Camera): void;
  32922. /**
  32923. * Adds the given skeleton to this scene
  32924. * @param newSkeleton The skeleton to add
  32925. */
  32926. addSkeleton(newSkeleton: Skeleton): void;
  32927. /**
  32928. * Adds the given particle system to this scene
  32929. * @param newParticleSystem The particle system to add
  32930. */
  32931. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32932. /**
  32933. * Adds the given animation to this scene
  32934. * @param newAnimation The animation to add
  32935. */
  32936. addAnimation(newAnimation: Animation): void;
  32937. /**
  32938. * Adds the given animation group to this scene.
  32939. * @param newAnimationGroup The animation group to add
  32940. */
  32941. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32942. /**
  32943. * Adds the given multi-material to this scene
  32944. * @param newMultiMaterial The multi-material to add
  32945. */
  32946. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32947. /**
  32948. * Adds the given material to this scene
  32949. * @param newMaterial The material to add
  32950. */
  32951. addMaterial(newMaterial: Material): void;
  32952. /**
  32953. * Adds the given morph target to this scene
  32954. * @param newMorphTargetManager The morph target to add
  32955. */
  32956. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32957. /**
  32958. * Adds the given geometry to this scene
  32959. * @param newGeometry The geometry to add
  32960. */
  32961. addGeometry(newGeometry: Geometry): void;
  32962. /**
  32963. * Adds the given action manager to this scene
  32964. * @param newActionManager The action manager to add
  32965. */
  32966. addActionManager(newActionManager: AbstractActionManager): void;
  32967. /**
  32968. * Adds the given texture to this scene.
  32969. * @param newTexture The texture to add
  32970. */
  32971. addTexture(newTexture: BaseTexture): void;
  32972. /**
  32973. * Switch active camera
  32974. * @param newCamera defines the new active camera
  32975. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32976. */
  32977. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32978. /**
  32979. * sets the active camera of the scene using its ID
  32980. * @param id defines the camera's ID
  32981. * @return the new active camera or null if none found.
  32982. */
  32983. setActiveCameraByID(id: string): Nullable<Camera>;
  32984. /**
  32985. * sets the active camera of the scene using its name
  32986. * @param name defines the camera's name
  32987. * @returns the new active camera or null if none found.
  32988. */
  32989. setActiveCameraByName(name: string): Nullable<Camera>;
  32990. /**
  32991. * get an animation group using its name
  32992. * @param name defines the material's name
  32993. * @return the animation group or null if none found.
  32994. */
  32995. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32996. /**
  32997. * Get a material using its unique id
  32998. * @param uniqueId defines the material's unique id
  32999. * @return the material or null if none found.
  33000. */
  33001. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33002. /**
  33003. * get a material using its id
  33004. * @param id defines the material's ID
  33005. * @return the material or null if none found.
  33006. */
  33007. getMaterialByID(id: string): Nullable<Material>;
  33008. /**
  33009. * Gets a material using its name
  33010. * @param name defines the material's name
  33011. * @return the material or null if none found.
  33012. */
  33013. getMaterialByName(name: string): Nullable<Material>;
  33014. /**
  33015. * Gets a camera using its id
  33016. * @param id defines the id to look for
  33017. * @returns the camera or null if not found
  33018. */
  33019. getCameraByID(id: string): Nullable<Camera>;
  33020. /**
  33021. * Gets a camera using its unique id
  33022. * @param uniqueId defines the unique id to look for
  33023. * @returns the camera or null if not found
  33024. */
  33025. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33026. /**
  33027. * Gets a camera using its name
  33028. * @param name defines the camera's name
  33029. * @return the camera or null if none found.
  33030. */
  33031. getCameraByName(name: string): Nullable<Camera>;
  33032. /**
  33033. * Gets a bone using its id
  33034. * @param id defines the bone's id
  33035. * @return the bone or null if not found
  33036. */
  33037. getBoneByID(id: string): Nullable<Bone>;
  33038. /**
  33039. * Gets a bone using its id
  33040. * @param name defines the bone's name
  33041. * @return the bone or null if not found
  33042. */
  33043. getBoneByName(name: string): Nullable<Bone>;
  33044. /**
  33045. * Gets a light node using its name
  33046. * @param name defines the the light's name
  33047. * @return the light or null if none found.
  33048. */
  33049. getLightByName(name: string): Nullable<Light>;
  33050. /**
  33051. * Gets a light node using its id
  33052. * @param id defines the light's id
  33053. * @return the light or null if none found.
  33054. */
  33055. getLightByID(id: string): Nullable<Light>;
  33056. /**
  33057. * Gets a light node using its scene-generated unique ID
  33058. * @param uniqueId defines the light's unique id
  33059. * @return the light or null if none found.
  33060. */
  33061. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33062. /**
  33063. * Gets a particle system by id
  33064. * @param id defines the particle system id
  33065. * @return the corresponding system or null if none found
  33066. */
  33067. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33068. /**
  33069. * Gets a geometry using its ID
  33070. * @param id defines the geometry's id
  33071. * @return the geometry or null if none found.
  33072. */
  33073. getGeometryByID(id: string): Nullable<Geometry>;
  33074. private _getGeometryByUniqueID;
  33075. /**
  33076. * Add a new geometry to this scene
  33077. * @param geometry defines the geometry to be added to the scene.
  33078. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33079. * @return a boolean defining if the geometry was added or not
  33080. */
  33081. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33082. /**
  33083. * Removes an existing geometry
  33084. * @param geometry defines the geometry to be removed from the scene
  33085. * @return a boolean defining if the geometry was removed or not
  33086. */
  33087. removeGeometry(geometry: Geometry): boolean;
  33088. /**
  33089. * Gets the list of geometries attached to the scene
  33090. * @returns an array of Geometry
  33091. */
  33092. getGeometries(): Geometry[];
  33093. /**
  33094. * Gets the first added mesh found of a given ID
  33095. * @param id defines the id to search for
  33096. * @return the mesh found or null if not found at all
  33097. */
  33098. getMeshByID(id: string): Nullable<AbstractMesh>;
  33099. /**
  33100. * Gets a list of meshes using their id
  33101. * @param id defines the id to search for
  33102. * @returns a list of meshes
  33103. */
  33104. getMeshesByID(id: string): Array<AbstractMesh>;
  33105. /**
  33106. * Gets the first added transform node found of a given ID
  33107. * @param id defines the id to search for
  33108. * @return the found transform node or null if not found at all.
  33109. */
  33110. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33111. /**
  33112. * Gets a transform node with its auto-generated unique id
  33113. * @param uniqueId efines the unique id to search for
  33114. * @return the found transform node or null if not found at all.
  33115. */
  33116. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33117. /**
  33118. * Gets a list of transform nodes using their id
  33119. * @param id defines the id to search for
  33120. * @returns a list of transform nodes
  33121. */
  33122. getTransformNodesByID(id: string): Array<TransformNode>;
  33123. /**
  33124. * Gets a mesh with its auto-generated unique id
  33125. * @param uniqueId defines the unique id to search for
  33126. * @return the found mesh or null if not found at all.
  33127. */
  33128. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33129. /**
  33130. * Gets a the last added mesh using a given id
  33131. * @param id defines the id to search for
  33132. * @return the found mesh or null if not found at all.
  33133. */
  33134. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33135. /**
  33136. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33137. * @param id defines the id to search for
  33138. * @return the found node or null if not found at all
  33139. */
  33140. getLastEntryByID(id: string): Nullable<Node>;
  33141. /**
  33142. * Gets a node (Mesh, Camera, Light) using a given id
  33143. * @param id defines the id to search for
  33144. * @return the found node or null if not found at all
  33145. */
  33146. getNodeByID(id: string): Nullable<Node>;
  33147. /**
  33148. * Gets a node (Mesh, Camera, Light) using a given name
  33149. * @param name defines the name to search for
  33150. * @return the found node or null if not found at all.
  33151. */
  33152. getNodeByName(name: string): Nullable<Node>;
  33153. /**
  33154. * Gets a mesh using a given name
  33155. * @param name defines the name to search for
  33156. * @return the found mesh or null if not found at all.
  33157. */
  33158. getMeshByName(name: string): Nullable<AbstractMesh>;
  33159. /**
  33160. * Gets a transform node using a given name
  33161. * @param name defines the name to search for
  33162. * @return the found transform node or null if not found at all.
  33163. */
  33164. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33165. /**
  33166. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33167. * @param id defines the id to search for
  33168. * @return the found skeleton or null if not found at all.
  33169. */
  33170. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33171. /**
  33172. * Gets a skeleton using a given auto generated unique id
  33173. * @param uniqueId defines the unique id to search for
  33174. * @return the found skeleton or null if not found at all.
  33175. */
  33176. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33177. /**
  33178. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33179. * @param id defines the id to search for
  33180. * @return the found skeleton or null if not found at all.
  33181. */
  33182. getSkeletonById(id: string): Nullable<Skeleton>;
  33183. /**
  33184. * Gets a skeleton using a given name
  33185. * @param name defines the name to search for
  33186. * @return the found skeleton or null if not found at all.
  33187. */
  33188. getSkeletonByName(name: string): Nullable<Skeleton>;
  33189. /**
  33190. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33191. * @param id defines the id to search for
  33192. * @return the found morph target manager or null if not found at all.
  33193. */
  33194. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33195. /**
  33196. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33197. * @param id defines the id to search for
  33198. * @return the found morph target or null if not found at all.
  33199. */
  33200. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33201. /**
  33202. * Gets a boolean indicating if the given mesh is active
  33203. * @param mesh defines the mesh to look for
  33204. * @returns true if the mesh is in the active list
  33205. */
  33206. isActiveMesh(mesh: AbstractMesh): boolean;
  33207. /**
  33208. * Return a unique id as a string which can serve as an identifier for the scene
  33209. */
  33210. readonly uid: string;
  33211. /**
  33212. * Add an externaly attached data from its key.
  33213. * This method call will fail and return false, if such key already exists.
  33214. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33215. * @param key the unique key that identifies the data
  33216. * @param data the data object to associate to the key for this Engine instance
  33217. * @return true if no such key were already present and the data was added successfully, false otherwise
  33218. */
  33219. addExternalData<T>(key: string, data: T): boolean;
  33220. /**
  33221. * Get an externaly attached data from its key
  33222. * @param key the unique key that identifies the data
  33223. * @return the associated data, if present (can be null), or undefined if not present
  33224. */
  33225. getExternalData<T>(key: string): Nullable<T>;
  33226. /**
  33227. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33228. * @param key the unique key that identifies the data
  33229. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33230. * @return the associated data, can be null if the factory returned null.
  33231. */
  33232. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33233. /**
  33234. * Remove an externaly attached data from the Engine instance
  33235. * @param key the unique key that identifies the data
  33236. * @return true if the data was successfully removed, false if it doesn't exist
  33237. */
  33238. removeExternalData(key: string): boolean;
  33239. private _evaluateSubMesh;
  33240. /**
  33241. * Clear the processed materials smart array preventing retention point in material dispose.
  33242. */
  33243. freeProcessedMaterials(): void;
  33244. private _preventFreeActiveMeshesAndRenderingGroups;
  33245. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33246. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33247. * when disposing several meshes in a row or a hierarchy of meshes.
  33248. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33249. */
  33250. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33251. /**
  33252. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33253. */
  33254. freeActiveMeshes(): void;
  33255. /**
  33256. * Clear the info related to rendering groups preventing retention points during dispose.
  33257. */
  33258. freeRenderingGroups(): void;
  33259. /** @hidden */
  33260. _isInIntermediateRendering(): boolean;
  33261. /**
  33262. * Lambda returning the list of potentially active meshes.
  33263. */
  33264. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33265. /**
  33266. * Lambda returning the list of potentially active sub meshes.
  33267. */
  33268. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33269. /**
  33270. * Lambda returning the list of potentially intersecting sub meshes.
  33271. */
  33272. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33273. /**
  33274. * Lambda returning the list of potentially colliding sub meshes.
  33275. */
  33276. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33277. private _activeMeshesFrozen;
  33278. /**
  33279. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33280. * @returns the current scene
  33281. */
  33282. freezeActiveMeshes(): Scene;
  33283. /**
  33284. * Use this function to restart evaluating active meshes on every frame
  33285. * @returns the current scene
  33286. */
  33287. unfreezeActiveMeshes(): Scene;
  33288. private _evaluateActiveMeshes;
  33289. private _activeMesh;
  33290. /**
  33291. * Update the transform matrix to update from the current active camera
  33292. * @param force defines a boolean used to force the update even if cache is up to date
  33293. */
  33294. updateTransformMatrix(force?: boolean): void;
  33295. private _bindFrameBuffer;
  33296. /** @hidden */
  33297. _allowPostProcessClearColor: boolean;
  33298. /** @hidden */
  33299. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33300. private _processSubCameras;
  33301. private _checkIntersections;
  33302. /** @hidden */
  33303. _advancePhysicsEngineStep(step: number): void;
  33304. /**
  33305. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33306. */
  33307. getDeterministicFrameTime: () => number;
  33308. /** @hidden */
  33309. _animate(): void;
  33310. /** Execute all animations (for a frame) */
  33311. animate(): void;
  33312. /**
  33313. * Render the scene
  33314. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33315. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33316. */
  33317. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33318. /**
  33319. * Freeze all materials
  33320. * A frozen material will not be updatable but should be faster to render
  33321. */
  33322. freezeMaterials(): void;
  33323. /**
  33324. * Unfreeze all materials
  33325. * A frozen material will not be updatable but should be faster to render
  33326. */
  33327. unfreezeMaterials(): void;
  33328. /**
  33329. * Releases all held ressources
  33330. */
  33331. dispose(): void;
  33332. /**
  33333. * Gets if the scene is already disposed
  33334. */
  33335. readonly isDisposed: boolean;
  33336. /**
  33337. * Call this function to reduce memory footprint of the scene.
  33338. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33339. */
  33340. clearCachedVertexData(): void;
  33341. /**
  33342. * This function will remove the local cached buffer data from texture.
  33343. * It will save memory but will prevent the texture from being rebuilt
  33344. */
  33345. cleanCachedTextureBuffer(): void;
  33346. /**
  33347. * Get the world extend vectors with an optional filter
  33348. *
  33349. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33350. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33351. */
  33352. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33353. min: Vector3;
  33354. max: Vector3;
  33355. };
  33356. /**
  33357. * Creates a ray that can be used to pick in the scene
  33358. * @param x defines the x coordinate of the origin (on-screen)
  33359. * @param y defines the y coordinate of the origin (on-screen)
  33360. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33361. * @param camera defines the camera to use for the picking
  33362. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33363. * @returns a Ray
  33364. */
  33365. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33366. /**
  33367. * Creates a ray that can be used to pick in the scene
  33368. * @param x defines the x coordinate of the origin (on-screen)
  33369. * @param y defines the y coordinate of the origin (on-screen)
  33370. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33371. * @param result defines the ray where to store the picking ray
  33372. * @param camera defines the camera to use for the picking
  33373. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33374. * @returns the current scene
  33375. */
  33376. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33377. /**
  33378. * Creates a ray that can be used to pick in the scene
  33379. * @param x defines the x coordinate of the origin (on-screen)
  33380. * @param y defines the y coordinate of the origin (on-screen)
  33381. * @param camera defines the camera to use for the picking
  33382. * @returns a Ray
  33383. */
  33384. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33385. /**
  33386. * Creates a ray that can be used to pick in the scene
  33387. * @param x defines the x coordinate of the origin (on-screen)
  33388. * @param y defines the y coordinate of the origin (on-screen)
  33389. * @param result defines the ray where to store the picking ray
  33390. * @param camera defines the camera to use for the picking
  33391. * @returns the current scene
  33392. */
  33393. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33394. /** Launch a ray to try to pick a mesh in the scene
  33395. * @param x position on screen
  33396. * @param y position on screen
  33397. * @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
  33398. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33399. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33400. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33401. * @returns a PickingInfo
  33402. */
  33403. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33404. /** Use the given ray to pick a mesh in the scene
  33405. * @param ray The ray to use to pick meshes
  33406. * @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
  33407. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33408. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33409. * @returns a PickingInfo
  33410. */
  33411. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33412. /**
  33413. * Launch a ray to try to pick a mesh in the scene
  33414. * @param x X position on screen
  33415. * @param y Y position on screen
  33416. * @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
  33417. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33418. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33419. * @returns an array of PickingInfo
  33420. */
  33421. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33422. /**
  33423. * Launch a ray to try to pick a mesh in the scene
  33424. * @param ray Ray to use
  33425. * @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
  33426. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33427. * @returns an array of PickingInfo
  33428. */
  33429. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33430. /**
  33431. * Force the value of meshUnderPointer
  33432. * @param mesh defines the mesh to use
  33433. */
  33434. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33435. /**
  33436. * Gets the mesh under the pointer
  33437. * @returns a Mesh or null if no mesh is under the pointer
  33438. */
  33439. getPointerOverMesh(): Nullable<AbstractMesh>;
  33440. /** @hidden */
  33441. _rebuildGeometries(): void;
  33442. /** @hidden */
  33443. _rebuildTextures(): void;
  33444. private _getByTags;
  33445. /**
  33446. * Get a list of meshes by tags
  33447. * @param tagsQuery defines the tags query to use
  33448. * @param forEach defines a predicate used to filter results
  33449. * @returns an array of Mesh
  33450. */
  33451. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33452. /**
  33453. * Get a list of cameras by tags
  33454. * @param tagsQuery defines the tags query to use
  33455. * @param forEach defines a predicate used to filter results
  33456. * @returns an array of Camera
  33457. */
  33458. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33459. /**
  33460. * Get a list of lights by tags
  33461. * @param tagsQuery defines the tags query to use
  33462. * @param forEach defines a predicate used to filter results
  33463. * @returns an array of Light
  33464. */
  33465. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33466. /**
  33467. * Get a list of materials by tags
  33468. * @param tagsQuery defines the tags query to use
  33469. * @param forEach defines a predicate used to filter results
  33470. * @returns an array of Material
  33471. */
  33472. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33473. /**
  33474. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33475. * This allowed control for front to back rendering or reversly depending of the special needs.
  33476. *
  33477. * @param renderingGroupId The rendering group id corresponding to its index
  33478. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33479. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33480. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33481. */
  33482. 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;
  33483. /**
  33484. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33485. *
  33486. * @param renderingGroupId The rendering group id corresponding to its index
  33487. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33488. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33489. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33490. */
  33491. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33492. /**
  33493. * Gets the current auto clear configuration for one rendering group of the rendering
  33494. * manager.
  33495. * @param index the rendering group index to get the information for
  33496. * @returns The auto clear setup for the requested rendering group
  33497. */
  33498. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33499. private _blockMaterialDirtyMechanism;
  33500. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33501. blockMaterialDirtyMechanism: boolean;
  33502. /**
  33503. * Will flag all materials as dirty to trigger new shader compilation
  33504. * @param flag defines the flag used to specify which material part must be marked as dirty
  33505. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33506. */
  33507. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33508. /** @hidden */
  33509. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33510. /** @hidden */
  33511. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33512. }
  33513. }
  33514. declare module BABYLON {
  33515. /**
  33516. * Set of assets to keep when moving a scene into an asset container.
  33517. */
  33518. export class KeepAssets extends AbstractScene {
  33519. }
  33520. /**
  33521. * Container with a set of assets that can be added or removed from a scene.
  33522. */
  33523. export class AssetContainer extends AbstractScene {
  33524. /**
  33525. * The scene the AssetContainer belongs to.
  33526. */
  33527. scene: Scene;
  33528. /**
  33529. * Instantiates an AssetContainer.
  33530. * @param scene The scene the AssetContainer belongs to.
  33531. */
  33532. constructor(scene: Scene);
  33533. /**
  33534. * Adds all the assets from the container to the scene.
  33535. */
  33536. addAllToScene(): void;
  33537. /**
  33538. * Removes all the assets in the container from the scene
  33539. */
  33540. removeAllFromScene(): void;
  33541. /**
  33542. * Disposes all the assets in the container
  33543. */
  33544. dispose(): void;
  33545. private _moveAssets;
  33546. /**
  33547. * Removes all the assets contained in the scene and adds them to the container.
  33548. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33549. */
  33550. moveAllFromScene(keepAssets?: KeepAssets): void;
  33551. /**
  33552. * 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.
  33553. * @returns the root mesh
  33554. */
  33555. createRootMesh(): Mesh;
  33556. }
  33557. }
  33558. declare module BABYLON {
  33559. /**
  33560. * Defines how the parser contract is defined.
  33561. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33562. */
  33563. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33564. /**
  33565. * Defines how the individual parser contract is defined.
  33566. * These parser can parse an individual asset
  33567. */
  33568. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33569. /**
  33570. * Base class of the scene acting as a container for the different elements composing a scene.
  33571. * This class is dynamically extended by the different components of the scene increasing
  33572. * flexibility and reducing coupling
  33573. */
  33574. export abstract class AbstractScene {
  33575. /**
  33576. * Stores the list of available parsers in the application.
  33577. */
  33578. private static _BabylonFileParsers;
  33579. /**
  33580. * Stores the list of available individual parsers in the application.
  33581. */
  33582. private static _IndividualBabylonFileParsers;
  33583. /**
  33584. * Adds a parser in the list of available ones
  33585. * @param name Defines the name of the parser
  33586. * @param parser Defines the parser to add
  33587. */
  33588. static AddParser(name: string, parser: BabylonFileParser): void;
  33589. /**
  33590. * Gets a general parser from the list of avaialble ones
  33591. * @param name Defines the name of the parser
  33592. * @returns the requested parser or null
  33593. */
  33594. static GetParser(name: string): Nullable<BabylonFileParser>;
  33595. /**
  33596. * Adds n individual parser in the list of available ones
  33597. * @param name Defines the name of the parser
  33598. * @param parser Defines the parser to add
  33599. */
  33600. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33601. /**
  33602. * Gets an individual parser from the list of avaialble ones
  33603. * @param name Defines the name of the parser
  33604. * @returns the requested parser or null
  33605. */
  33606. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33607. /**
  33608. * Parser json data and populate both a scene and its associated container object
  33609. * @param jsonData Defines the data to parse
  33610. * @param scene Defines the scene to parse the data for
  33611. * @param container Defines the container attached to the parsing sequence
  33612. * @param rootUrl Defines the root url of the data
  33613. */
  33614. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33615. /**
  33616. * Gets the list of root nodes (ie. nodes with no parent)
  33617. */
  33618. rootNodes: Node[];
  33619. /** All of the cameras added to this scene
  33620. * @see http://doc.babylonjs.com/babylon101/cameras
  33621. */
  33622. cameras: Camera[];
  33623. /**
  33624. * All of the lights added to this scene
  33625. * @see http://doc.babylonjs.com/babylon101/lights
  33626. */
  33627. lights: Light[];
  33628. /**
  33629. * All of the (abstract) meshes added to this scene
  33630. */
  33631. meshes: AbstractMesh[];
  33632. /**
  33633. * The list of skeletons added to the scene
  33634. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33635. */
  33636. skeletons: Skeleton[];
  33637. /**
  33638. * All of the particle systems added to this scene
  33639. * @see http://doc.babylonjs.com/babylon101/particles
  33640. */
  33641. particleSystems: IParticleSystem[];
  33642. /**
  33643. * Gets a list of Animations associated with the scene
  33644. */
  33645. animations: Animation[];
  33646. /**
  33647. * All of the animation groups added to this scene
  33648. * @see http://doc.babylonjs.com/how_to/group
  33649. */
  33650. animationGroups: AnimationGroup[];
  33651. /**
  33652. * All of the multi-materials added to this scene
  33653. * @see http://doc.babylonjs.com/how_to/multi_materials
  33654. */
  33655. multiMaterials: MultiMaterial[];
  33656. /**
  33657. * All of the materials added to this scene
  33658. * In the context of a Scene, it is not supposed to be modified manually.
  33659. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33660. * Note also that the order of the Material wihin the array is not significant and might change.
  33661. * @see http://doc.babylonjs.com/babylon101/materials
  33662. */
  33663. materials: Material[];
  33664. /**
  33665. * The list of morph target managers added to the scene
  33666. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33667. */
  33668. morphTargetManagers: MorphTargetManager[];
  33669. /**
  33670. * The list of geometries used in the scene.
  33671. */
  33672. geometries: Geometry[];
  33673. /**
  33674. * All of the tranform nodes added to this scene
  33675. * In the context of a Scene, it is not supposed to be modified manually.
  33676. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33677. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33678. * @see http://doc.babylonjs.com/how_to/transformnode
  33679. */
  33680. transformNodes: TransformNode[];
  33681. /**
  33682. * ActionManagers available on the scene.
  33683. */
  33684. actionManagers: AbstractActionManager[];
  33685. /**
  33686. * Textures to keep.
  33687. */
  33688. textures: BaseTexture[];
  33689. /**
  33690. * Environment texture for the scene
  33691. */
  33692. environmentTexture: Nullable<BaseTexture>;
  33693. }
  33694. }
  33695. declare module BABYLON {
  33696. /**
  33697. * Defines a sound that can be played in the application.
  33698. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33700. */
  33701. export class Sound {
  33702. /**
  33703. * The name of the sound in the scene.
  33704. */
  33705. name: string;
  33706. /**
  33707. * Does the sound autoplay once loaded.
  33708. */
  33709. autoplay: boolean;
  33710. /**
  33711. * Does the sound loop after it finishes playing once.
  33712. */
  33713. loop: boolean;
  33714. /**
  33715. * Does the sound use a custom attenuation curve to simulate the falloff
  33716. * happening when the source gets further away from the camera.
  33717. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33718. */
  33719. useCustomAttenuation: boolean;
  33720. /**
  33721. * The sound track id this sound belongs to.
  33722. */
  33723. soundTrackId: number;
  33724. /**
  33725. * Is this sound currently played.
  33726. */
  33727. isPlaying: boolean;
  33728. /**
  33729. * Is this sound currently paused.
  33730. */
  33731. isPaused: boolean;
  33732. /**
  33733. * Does this sound enables spatial sound.
  33734. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33735. */
  33736. spatialSound: boolean;
  33737. /**
  33738. * Define the reference distance the sound should be heard perfectly.
  33739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33740. */
  33741. refDistance: number;
  33742. /**
  33743. * Define the roll off factor of spatial sounds.
  33744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33745. */
  33746. rolloffFactor: number;
  33747. /**
  33748. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33749. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33750. */
  33751. maxDistance: number;
  33752. /**
  33753. * Define the distance attenuation model the sound will follow.
  33754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33755. */
  33756. distanceModel: string;
  33757. /**
  33758. * @hidden
  33759. * Back Compat
  33760. **/
  33761. onended: () => any;
  33762. /**
  33763. * Observable event when the current playing sound finishes.
  33764. */
  33765. onEndedObservable: Observable<Sound>;
  33766. private _panningModel;
  33767. private _playbackRate;
  33768. private _streaming;
  33769. private _startTime;
  33770. private _startOffset;
  33771. private _position;
  33772. /** @hidden */
  33773. _positionInEmitterSpace: boolean;
  33774. private _localDirection;
  33775. private _volume;
  33776. private _isReadyToPlay;
  33777. private _isDirectional;
  33778. private _readyToPlayCallback;
  33779. private _audioBuffer;
  33780. private _soundSource;
  33781. private _streamingSource;
  33782. private _soundPanner;
  33783. private _soundGain;
  33784. private _inputAudioNode;
  33785. private _outputAudioNode;
  33786. private _coneInnerAngle;
  33787. private _coneOuterAngle;
  33788. private _coneOuterGain;
  33789. private _scene;
  33790. private _connectedTransformNode;
  33791. private _customAttenuationFunction;
  33792. private _registerFunc;
  33793. private _isOutputConnected;
  33794. private _htmlAudioElement;
  33795. private _urlType;
  33796. /** @hidden */
  33797. static _SceneComponentInitialization: (scene: Scene) => void;
  33798. /**
  33799. * Create a sound and attach it to a scene
  33800. * @param name Name of your sound
  33801. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33802. * @param scene defines the scene the sound belongs to
  33803. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33804. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33805. */
  33806. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33807. /**
  33808. * Release the sound and its associated resources
  33809. */
  33810. dispose(): void;
  33811. /**
  33812. * Gets if the sounds is ready to be played or not.
  33813. * @returns true if ready, otherwise false
  33814. */
  33815. isReady(): boolean;
  33816. private _soundLoaded;
  33817. /**
  33818. * Sets the data of the sound from an audiobuffer
  33819. * @param audioBuffer The audioBuffer containing the data
  33820. */
  33821. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33822. /**
  33823. * Updates the current sounds options such as maxdistance, loop...
  33824. * @param options A JSON object containing values named as the object properties
  33825. */
  33826. updateOptions(options: any): void;
  33827. private _createSpatialParameters;
  33828. private _updateSpatialParameters;
  33829. /**
  33830. * Switch the panning model to HRTF:
  33831. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33833. */
  33834. switchPanningModelToHRTF(): void;
  33835. /**
  33836. * Switch the panning model to Equal Power:
  33837. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33839. */
  33840. switchPanningModelToEqualPower(): void;
  33841. private _switchPanningModel;
  33842. /**
  33843. * Connect this sound to a sound track audio node like gain...
  33844. * @param soundTrackAudioNode the sound track audio node to connect to
  33845. */
  33846. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33847. /**
  33848. * Transform this sound into a directional source
  33849. * @param coneInnerAngle Size of the inner cone in degree
  33850. * @param coneOuterAngle Size of the outer cone in degree
  33851. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33852. */
  33853. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33854. /**
  33855. * Gets or sets the inner angle for the directional cone.
  33856. */
  33857. /**
  33858. * Gets or sets the inner angle for the directional cone.
  33859. */
  33860. directionalConeInnerAngle: number;
  33861. /**
  33862. * Gets or sets the outer angle for the directional cone.
  33863. */
  33864. /**
  33865. * Gets or sets the outer angle for the directional cone.
  33866. */
  33867. directionalConeOuterAngle: number;
  33868. /**
  33869. * Sets the position of the emitter if spatial sound is enabled
  33870. * @param newPosition Defines the new posisiton
  33871. */
  33872. setPosition(newPosition: Vector3): void;
  33873. /**
  33874. * Sets the local direction of the emitter if spatial sound is enabled
  33875. * @param newLocalDirection Defines the new local direction
  33876. */
  33877. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33878. private _updateDirection;
  33879. /** @hidden */
  33880. updateDistanceFromListener(): void;
  33881. /**
  33882. * Sets a new custom attenuation function for the sound.
  33883. * @param callback Defines the function used for the attenuation
  33884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33885. */
  33886. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33887. /**
  33888. * Play the sound
  33889. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33890. * @param offset (optional) Start the sound setting it at a specific time
  33891. */
  33892. play(time?: number, offset?: number): void;
  33893. private _onended;
  33894. /**
  33895. * Stop the sound
  33896. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33897. */
  33898. stop(time?: number): void;
  33899. /**
  33900. * Put the sound in pause
  33901. */
  33902. pause(): void;
  33903. /**
  33904. * Sets a dedicated volume for this sounds
  33905. * @param newVolume Define the new volume of the sound
  33906. * @param time Define in how long the sound should be at this value
  33907. */
  33908. setVolume(newVolume: number, time?: number): void;
  33909. /**
  33910. * Set the sound play back rate
  33911. * @param newPlaybackRate Define the playback rate the sound should be played at
  33912. */
  33913. setPlaybackRate(newPlaybackRate: number): void;
  33914. /**
  33915. * Gets the volume of the sound.
  33916. * @returns the volume of the sound
  33917. */
  33918. getVolume(): number;
  33919. /**
  33920. * Attach the sound to a dedicated mesh
  33921. * @param transformNode The transform node to connect the sound with
  33922. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33923. */
  33924. attachToMesh(transformNode: TransformNode): void;
  33925. /**
  33926. * Detach the sound from the previously attached mesh
  33927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33928. */
  33929. detachFromMesh(): void;
  33930. private _onRegisterAfterWorldMatrixUpdate;
  33931. /**
  33932. * Clone the current sound in the scene.
  33933. * @returns the new sound clone
  33934. */
  33935. clone(): Nullable<Sound>;
  33936. /**
  33937. * Gets the current underlying audio buffer containing the data
  33938. * @returns the audio buffer
  33939. */
  33940. getAudioBuffer(): Nullable<AudioBuffer>;
  33941. /**
  33942. * Serializes the Sound in a JSON representation
  33943. * @returns the JSON representation of the sound
  33944. */
  33945. serialize(): any;
  33946. /**
  33947. * Parse a JSON representation of a sound to innstantiate in a given scene
  33948. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33949. * @param scene Define the scene the new parsed sound should be created in
  33950. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33951. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33952. * @returns the newly parsed sound
  33953. */
  33954. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33955. }
  33956. }
  33957. declare module BABYLON {
  33958. /**
  33959. * This defines an action helpful to play a defined sound on a triggered action.
  33960. */
  33961. export class PlaySoundAction extends Action {
  33962. private _sound;
  33963. /**
  33964. * Instantiate the action
  33965. * @param triggerOptions defines the trigger options
  33966. * @param sound defines the sound to play
  33967. * @param condition defines the trigger related conditions
  33968. */
  33969. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33970. /** @hidden */
  33971. _prepare(): void;
  33972. /**
  33973. * Execute the action and play the sound.
  33974. */
  33975. execute(): void;
  33976. /**
  33977. * Serializes the actions and its related information.
  33978. * @param parent defines the object to serialize in
  33979. * @returns the serialized object
  33980. */
  33981. serialize(parent: any): any;
  33982. }
  33983. /**
  33984. * This defines an action helpful to stop a defined sound on a triggered action.
  33985. */
  33986. export class StopSoundAction extends Action {
  33987. private _sound;
  33988. /**
  33989. * Instantiate the action
  33990. * @param triggerOptions defines the trigger options
  33991. * @param sound defines the sound to stop
  33992. * @param condition defines the trigger related conditions
  33993. */
  33994. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33995. /** @hidden */
  33996. _prepare(): void;
  33997. /**
  33998. * Execute the action and stop the sound.
  33999. */
  34000. execute(): void;
  34001. /**
  34002. * Serializes the actions and its related information.
  34003. * @param parent defines the object to serialize in
  34004. * @returns the serialized object
  34005. */
  34006. serialize(parent: any): any;
  34007. }
  34008. }
  34009. declare module BABYLON {
  34010. /**
  34011. * This defines an action responsible to change the value of a property
  34012. * by interpolating between its current value and the newly set one once triggered.
  34013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34014. */
  34015. export class InterpolateValueAction extends Action {
  34016. /**
  34017. * Defines the path of the property where the value should be interpolated
  34018. */
  34019. propertyPath: string;
  34020. /**
  34021. * Defines the target value at the end of the interpolation.
  34022. */
  34023. value: any;
  34024. /**
  34025. * Defines the time it will take for the property to interpolate to the value.
  34026. */
  34027. duration: number;
  34028. /**
  34029. * Defines if the other scene animations should be stopped when the action has been triggered
  34030. */
  34031. stopOtherAnimations?: boolean;
  34032. /**
  34033. * Defines a callback raised once the interpolation animation has been done.
  34034. */
  34035. onInterpolationDone?: () => void;
  34036. /**
  34037. * Observable triggered once the interpolation animation has been done.
  34038. */
  34039. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34040. private _target;
  34041. private _effectiveTarget;
  34042. private _property;
  34043. /**
  34044. * Instantiate the action
  34045. * @param triggerOptions defines the trigger options
  34046. * @param target defines the object containing the value to interpolate
  34047. * @param propertyPath defines the path to the property in the target object
  34048. * @param value defines the target value at the end of the interpolation
  34049. * @param duration deines the time it will take for the property to interpolate to the value.
  34050. * @param condition defines the trigger related conditions
  34051. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34052. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34053. */
  34054. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34055. /** @hidden */
  34056. _prepare(): void;
  34057. /**
  34058. * Execute the action starts the value interpolation.
  34059. */
  34060. execute(): void;
  34061. /**
  34062. * Serializes the actions and its related information.
  34063. * @param parent defines the object to serialize in
  34064. * @returns the serialized object
  34065. */
  34066. serialize(parent: any): any;
  34067. }
  34068. }
  34069. declare module BABYLON {
  34070. /**
  34071. * Options allowed during the creation of a sound track.
  34072. */
  34073. export interface ISoundTrackOptions {
  34074. /**
  34075. * The volume the sound track should take during creation
  34076. */
  34077. volume?: number;
  34078. /**
  34079. * Define if the sound track is the main sound track of the scene
  34080. */
  34081. mainTrack?: boolean;
  34082. }
  34083. /**
  34084. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34085. * It will be also used in a future release to apply effects on a specific track.
  34086. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34087. */
  34088. export class SoundTrack {
  34089. /**
  34090. * The unique identifier of the sound track in the scene.
  34091. */
  34092. id: number;
  34093. /**
  34094. * The list of sounds included in the sound track.
  34095. */
  34096. soundCollection: Array<Sound>;
  34097. private _outputAudioNode;
  34098. private _scene;
  34099. private _isMainTrack;
  34100. private _connectedAnalyser;
  34101. private _options;
  34102. private _isInitialized;
  34103. /**
  34104. * Creates a new sound track.
  34105. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34106. * @param scene Define the scene the sound track belongs to
  34107. * @param options
  34108. */
  34109. constructor(scene: Scene, options?: ISoundTrackOptions);
  34110. private _initializeSoundTrackAudioGraph;
  34111. /**
  34112. * Release the sound track and its associated resources
  34113. */
  34114. dispose(): void;
  34115. /**
  34116. * Adds a sound to this sound track
  34117. * @param sound define the cound to add
  34118. * @ignoreNaming
  34119. */
  34120. AddSound(sound: Sound): void;
  34121. /**
  34122. * Removes a sound to this sound track
  34123. * @param sound define the cound to remove
  34124. * @ignoreNaming
  34125. */
  34126. RemoveSound(sound: Sound): void;
  34127. /**
  34128. * Set a global volume for the full sound track.
  34129. * @param newVolume Define the new volume of the sound track
  34130. */
  34131. setVolume(newVolume: number): void;
  34132. /**
  34133. * Switch the panning model to HRTF:
  34134. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34136. */
  34137. switchPanningModelToHRTF(): void;
  34138. /**
  34139. * Switch the panning model to Equal Power:
  34140. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34142. */
  34143. switchPanningModelToEqualPower(): void;
  34144. /**
  34145. * Connect the sound track to an audio analyser allowing some amazing
  34146. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34148. * @param analyser The analyser to connect to the engine
  34149. */
  34150. connectToAnalyser(analyser: Analyser): void;
  34151. }
  34152. }
  34153. declare module BABYLON {
  34154. interface AbstractScene {
  34155. /**
  34156. * The list of sounds used in the scene.
  34157. */
  34158. sounds: Nullable<Array<Sound>>;
  34159. }
  34160. interface Scene {
  34161. /**
  34162. * @hidden
  34163. * Backing field
  34164. */
  34165. _mainSoundTrack: SoundTrack;
  34166. /**
  34167. * The main sound track played by the scene.
  34168. * It cotains your primary collection of sounds.
  34169. */
  34170. mainSoundTrack: SoundTrack;
  34171. /**
  34172. * The list of sound tracks added to the scene
  34173. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34174. */
  34175. soundTracks: Nullable<Array<SoundTrack>>;
  34176. /**
  34177. * Gets a sound using a given name
  34178. * @param name defines the name to search for
  34179. * @return the found sound or null if not found at all.
  34180. */
  34181. getSoundByName(name: string): Nullable<Sound>;
  34182. /**
  34183. * Gets or sets if audio support is enabled
  34184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34185. */
  34186. audioEnabled: boolean;
  34187. /**
  34188. * Gets or sets if audio will be output to headphones
  34189. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34190. */
  34191. headphone: boolean;
  34192. }
  34193. /**
  34194. * Defines the sound scene component responsible to manage any sounds
  34195. * in a given scene.
  34196. */
  34197. export class AudioSceneComponent implements ISceneSerializableComponent {
  34198. /**
  34199. * The component name helpfull to identify the component in the list of scene components.
  34200. */
  34201. readonly name: string;
  34202. /**
  34203. * The scene the component belongs to.
  34204. */
  34205. scene: Scene;
  34206. private _audioEnabled;
  34207. /**
  34208. * Gets whether audio is enabled or not.
  34209. * Please use related enable/disable method to switch state.
  34210. */
  34211. readonly audioEnabled: boolean;
  34212. private _headphone;
  34213. /**
  34214. * Gets whether audio is outputing to headphone or not.
  34215. * Please use the according Switch methods to change output.
  34216. */
  34217. readonly headphone: boolean;
  34218. /**
  34219. * Creates a new instance of the component for the given scene
  34220. * @param scene Defines the scene to register the component in
  34221. */
  34222. constructor(scene: Scene);
  34223. /**
  34224. * Registers the component in a given scene
  34225. */
  34226. register(): void;
  34227. /**
  34228. * Rebuilds the elements related to this component in case of
  34229. * context lost for instance.
  34230. */
  34231. rebuild(): void;
  34232. /**
  34233. * Serializes the component data to the specified json object
  34234. * @param serializationObject The object to serialize to
  34235. */
  34236. serialize(serializationObject: any): void;
  34237. /**
  34238. * Adds all the element from the container to the scene
  34239. * @param container the container holding the elements
  34240. */
  34241. addFromContainer(container: AbstractScene): void;
  34242. /**
  34243. * Removes all the elements in the container from the scene
  34244. * @param container contains the elements to remove
  34245. * @param dispose if the removed element should be disposed (default: false)
  34246. */
  34247. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34248. /**
  34249. * Disposes the component and the associated ressources.
  34250. */
  34251. dispose(): void;
  34252. /**
  34253. * Disables audio in the associated scene.
  34254. */
  34255. disableAudio(): void;
  34256. /**
  34257. * Enables audio in the associated scene.
  34258. */
  34259. enableAudio(): void;
  34260. /**
  34261. * Switch audio to headphone output.
  34262. */
  34263. switchAudioModeForHeadphones(): void;
  34264. /**
  34265. * Switch audio to normal speakers.
  34266. */
  34267. switchAudioModeForNormalSpeakers(): void;
  34268. private _afterRender;
  34269. }
  34270. }
  34271. declare module BABYLON {
  34272. /**
  34273. * Wraps one or more Sound objects and selects one with random weight for playback.
  34274. */
  34275. export class WeightedSound {
  34276. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34277. loop: boolean;
  34278. private _coneInnerAngle;
  34279. private _coneOuterAngle;
  34280. private _volume;
  34281. /** A Sound is currently playing. */
  34282. isPlaying: boolean;
  34283. /** A Sound is currently paused. */
  34284. isPaused: boolean;
  34285. private _sounds;
  34286. private _weights;
  34287. private _currentIndex?;
  34288. /**
  34289. * Creates a new WeightedSound from the list of sounds given.
  34290. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34291. * @param sounds Array of Sounds that will be selected from.
  34292. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34293. */
  34294. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34295. /**
  34296. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34297. */
  34298. /**
  34299. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34300. */
  34301. directionalConeInnerAngle: number;
  34302. /**
  34303. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34304. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34305. */
  34306. /**
  34307. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34308. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34309. */
  34310. directionalConeOuterAngle: number;
  34311. /**
  34312. * Playback volume.
  34313. */
  34314. /**
  34315. * Playback volume.
  34316. */
  34317. volume: number;
  34318. private _onended;
  34319. /**
  34320. * Suspend playback
  34321. */
  34322. pause(): void;
  34323. /**
  34324. * Stop playback
  34325. */
  34326. stop(): void;
  34327. /**
  34328. * Start playback.
  34329. * @param startOffset Position the clip head at a specific time in seconds.
  34330. */
  34331. play(startOffset?: number): void;
  34332. }
  34333. }
  34334. declare module BABYLON {
  34335. /**
  34336. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34337. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34338. */
  34339. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34340. /**
  34341. * Gets the name of the behavior.
  34342. */
  34343. readonly name: string;
  34344. /**
  34345. * The easing function used by animations
  34346. */
  34347. static EasingFunction: BackEase;
  34348. /**
  34349. * The easing mode used by animations
  34350. */
  34351. static EasingMode: number;
  34352. /**
  34353. * The duration of the animation, in milliseconds
  34354. */
  34355. transitionDuration: number;
  34356. /**
  34357. * Length of the distance animated by the transition when lower radius is reached
  34358. */
  34359. lowerRadiusTransitionRange: number;
  34360. /**
  34361. * Length of the distance animated by the transition when upper radius is reached
  34362. */
  34363. upperRadiusTransitionRange: number;
  34364. private _autoTransitionRange;
  34365. /**
  34366. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34367. */
  34368. /**
  34369. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34370. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34371. */
  34372. autoTransitionRange: boolean;
  34373. private _attachedCamera;
  34374. private _onAfterCheckInputsObserver;
  34375. private _onMeshTargetChangedObserver;
  34376. /**
  34377. * Initializes the behavior.
  34378. */
  34379. init(): void;
  34380. /**
  34381. * Attaches the behavior to its arc rotate camera.
  34382. * @param camera Defines the camera to attach the behavior to
  34383. */
  34384. attach(camera: ArcRotateCamera): void;
  34385. /**
  34386. * Detaches the behavior from its current arc rotate camera.
  34387. */
  34388. detach(): void;
  34389. private _radiusIsAnimating;
  34390. private _radiusBounceTransition;
  34391. private _animatables;
  34392. private _cachedWheelPrecision;
  34393. /**
  34394. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34395. * @param radiusLimit The limit to check against.
  34396. * @return Bool to indicate if at limit.
  34397. */
  34398. private _isRadiusAtLimit;
  34399. /**
  34400. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34401. * @param radiusDelta The delta by which to animate to. Can be negative.
  34402. */
  34403. private _applyBoundRadiusAnimation;
  34404. /**
  34405. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34406. */
  34407. protected _clearAnimationLocks(): void;
  34408. /**
  34409. * Stops and removes all animations that have been applied to the camera
  34410. */
  34411. stopAllAnimations(): void;
  34412. }
  34413. }
  34414. declare module BABYLON {
  34415. /**
  34416. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  34417. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34418. */
  34419. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34420. /**
  34421. * Gets the name of the behavior.
  34422. */
  34423. readonly name: string;
  34424. private _mode;
  34425. private _radiusScale;
  34426. private _positionScale;
  34427. private _defaultElevation;
  34428. private _elevationReturnTime;
  34429. private _elevationReturnWaitTime;
  34430. private _zoomStopsAnimation;
  34431. private _framingTime;
  34432. /**
  34433. * The easing function used by animations
  34434. */
  34435. static EasingFunction: ExponentialEase;
  34436. /**
  34437. * The easing mode used by animations
  34438. */
  34439. static EasingMode: number;
  34440. /**
  34441. * Sets the current mode used by the behavior
  34442. */
  34443. /**
  34444. * Gets current mode used by the behavior.
  34445. */
  34446. mode: number;
  34447. /**
  34448. * Sets the scale applied to the radius (1 by default)
  34449. */
  34450. /**
  34451. * Gets the scale applied to the radius
  34452. */
  34453. radiusScale: number;
  34454. /**
  34455. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34456. */
  34457. /**
  34458. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34459. */
  34460. positionScale: number;
  34461. /**
  34462. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34463. * behaviour is triggered, in radians.
  34464. */
  34465. /**
  34466. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34467. * behaviour is triggered, in radians.
  34468. */
  34469. defaultElevation: number;
  34470. /**
  34471. * Sets the time (in milliseconds) taken to return to the default beta position.
  34472. * Negative value indicates camera should not return to default.
  34473. */
  34474. /**
  34475. * Gets the time (in milliseconds) taken to return to the default beta position.
  34476. * Negative value indicates camera should not return to default.
  34477. */
  34478. elevationReturnTime: number;
  34479. /**
  34480. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34481. */
  34482. /**
  34483. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34484. */
  34485. elevationReturnWaitTime: number;
  34486. /**
  34487. * Sets the flag that indicates if user zooming should stop animation.
  34488. */
  34489. /**
  34490. * Gets the flag that indicates if user zooming should stop animation.
  34491. */
  34492. zoomStopsAnimation: boolean;
  34493. /**
  34494. * Sets the transition time when framing the mesh, in milliseconds
  34495. */
  34496. /**
  34497. * Gets the transition time when framing the mesh, in milliseconds
  34498. */
  34499. framingTime: number;
  34500. /**
  34501. * Define if the behavior should automatically change the configured
  34502. * camera limits and sensibilities.
  34503. */
  34504. autoCorrectCameraLimitsAndSensibility: boolean;
  34505. private _onPrePointerObservableObserver;
  34506. private _onAfterCheckInputsObserver;
  34507. private _onMeshTargetChangedObserver;
  34508. private _attachedCamera;
  34509. private _isPointerDown;
  34510. private _lastInteractionTime;
  34511. /**
  34512. * Initializes the behavior.
  34513. */
  34514. init(): void;
  34515. /**
  34516. * Attaches the behavior to its arc rotate camera.
  34517. * @param camera Defines the camera to attach the behavior to
  34518. */
  34519. attach(camera: ArcRotateCamera): void;
  34520. /**
  34521. * Detaches the behavior from its current arc rotate camera.
  34522. */
  34523. detach(): void;
  34524. private _animatables;
  34525. private _betaIsAnimating;
  34526. private _betaTransition;
  34527. private _radiusTransition;
  34528. private _vectorTransition;
  34529. /**
  34530. * Targets the given mesh and updates zoom level accordingly.
  34531. * @param mesh The mesh to target.
  34532. * @param radius Optional. If a cached radius position already exists, overrides default.
  34533. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34534. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34535. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34536. */
  34537. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34538. /**
  34539. * Targets the given mesh with its children and updates zoom level accordingly.
  34540. * @param mesh The mesh to target.
  34541. * @param radius Optional. If a cached radius position already exists, overrides default.
  34542. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34543. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34544. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34545. */
  34546. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34547. /**
  34548. * Targets the given meshes with their children and updates zoom level accordingly.
  34549. * @param meshes The mesh to target.
  34550. * @param radius Optional. If a cached radius position already exists, overrides default.
  34551. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34552. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34553. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34554. */
  34555. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34556. /**
  34557. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34558. * @param minimumWorld Determines the smaller position of the bounding box extend
  34559. * @param maximumWorld Determines the bigger position of the bounding box extend
  34560. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34561. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34562. */
  34563. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34564. /**
  34565. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34566. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34567. * frustum width.
  34568. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34569. * to fully enclose the mesh in the viewing frustum.
  34570. */
  34571. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34572. /**
  34573. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34574. * is automatically returned to its default position (expected to be above ground plane).
  34575. */
  34576. private _maintainCameraAboveGround;
  34577. /**
  34578. * Returns the frustum slope based on the canvas ratio and camera FOV
  34579. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34580. */
  34581. private _getFrustumSlope;
  34582. /**
  34583. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34584. */
  34585. private _clearAnimationLocks;
  34586. /**
  34587. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34588. */
  34589. private _applyUserInteraction;
  34590. /**
  34591. * Stops and removes all animations that have been applied to the camera
  34592. */
  34593. stopAllAnimations(): void;
  34594. /**
  34595. * Gets a value indicating if the user is moving the camera
  34596. */
  34597. readonly isUserIsMoving: boolean;
  34598. /**
  34599. * The camera can move all the way towards the mesh.
  34600. */
  34601. static IgnoreBoundsSizeMode: number;
  34602. /**
  34603. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34604. */
  34605. static FitFrustumSidesMode: number;
  34606. }
  34607. }
  34608. declare module BABYLON {
  34609. /**
  34610. * Base class for Camera Pointer Inputs.
  34611. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34612. * for example usage.
  34613. */
  34614. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34615. /**
  34616. * Defines the camera the input is attached to.
  34617. */
  34618. abstract camera: Camera;
  34619. /**
  34620. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34621. */
  34622. protected _altKey: boolean;
  34623. protected _ctrlKey: boolean;
  34624. protected _metaKey: boolean;
  34625. protected _shiftKey: boolean;
  34626. /**
  34627. * Which mouse buttons were pressed at time of last mouse event.
  34628. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34629. */
  34630. protected _buttonsPressed: number;
  34631. /**
  34632. * Defines the buttons associated with the input to handle camera move.
  34633. */
  34634. buttons: number[];
  34635. /**
  34636. * Attach the input controls to a specific dom element to get the input from.
  34637. * @param element Defines the element the controls should be listened from
  34638. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34639. */
  34640. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34641. /**
  34642. * Detach the current controls from the specified dom element.
  34643. * @param element Defines the element to stop listening the inputs from
  34644. */
  34645. detachControl(element: Nullable<HTMLElement>): void;
  34646. /**
  34647. * Gets the class name of the current input.
  34648. * @returns the class name
  34649. */
  34650. getClassName(): string;
  34651. /**
  34652. * Get the friendly name associated with the input class.
  34653. * @returns the input friendly name
  34654. */
  34655. getSimpleName(): string;
  34656. /**
  34657. * Called on pointer POINTERDOUBLETAP event.
  34658. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34659. */
  34660. protected onDoubleTap(type: string): void;
  34661. /**
  34662. * Called on pointer POINTERMOVE event if only a single touch is active.
  34663. * Override this method to provide functionality.
  34664. */
  34665. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34666. /**
  34667. * Called on pointer POINTERMOVE event if multiple touches are active.
  34668. * Override this method to provide functionality.
  34669. */
  34670. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34671. /**
  34672. * Called on JS contextmenu event.
  34673. * Override this method to provide functionality.
  34674. */
  34675. protected onContextMenu(evt: PointerEvent): void;
  34676. /**
  34677. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34678. * press.
  34679. * Override this method to provide functionality.
  34680. */
  34681. protected onButtonDown(evt: PointerEvent): void;
  34682. /**
  34683. * Called each time a new POINTERUP event occurs. Ie, for each button
  34684. * release.
  34685. * Override this method to provide functionality.
  34686. */
  34687. protected onButtonUp(evt: PointerEvent): void;
  34688. /**
  34689. * Called when window becomes inactive.
  34690. * Override this method to provide functionality.
  34691. */
  34692. protected onLostFocus(): void;
  34693. private _pointerInput;
  34694. private _observer;
  34695. private _onLostFocus;
  34696. private pointA;
  34697. private pointB;
  34698. }
  34699. }
  34700. declare module BABYLON {
  34701. /**
  34702. * Manage the pointers inputs to control an arc rotate camera.
  34703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34704. */
  34705. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34706. /**
  34707. * Defines the camera the input is attached to.
  34708. */
  34709. camera: ArcRotateCamera;
  34710. /**
  34711. * Gets the class name of the current input.
  34712. * @returns the class name
  34713. */
  34714. getClassName(): string;
  34715. /**
  34716. * Defines the buttons associated with the input to handle camera move.
  34717. */
  34718. buttons: number[];
  34719. /**
  34720. * Defines the pointer angular sensibility along the X axis or how fast is
  34721. * the camera rotating.
  34722. */
  34723. angularSensibilityX: number;
  34724. /**
  34725. * Defines the pointer angular sensibility along the Y axis or how fast is
  34726. * the camera rotating.
  34727. */
  34728. angularSensibilityY: number;
  34729. /**
  34730. * Defines the pointer pinch precision or how fast is the camera zooming.
  34731. */
  34732. pinchPrecision: number;
  34733. /**
  34734. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34735. * from 0.
  34736. * It defines the percentage of current camera.radius to use as delta when
  34737. * pinch zoom is used.
  34738. */
  34739. pinchDeltaPercentage: number;
  34740. /**
  34741. * Defines the pointer panning sensibility or how fast is the camera moving.
  34742. */
  34743. panningSensibility: number;
  34744. /**
  34745. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34746. */
  34747. multiTouchPanning: boolean;
  34748. /**
  34749. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34750. * zoom (pinch) through multitouch.
  34751. */
  34752. multiTouchPanAndZoom: boolean;
  34753. /**
  34754. * Revers pinch action direction.
  34755. */
  34756. pinchInwards: boolean;
  34757. private _isPanClick;
  34758. private _twoFingerActivityCount;
  34759. private _isPinching;
  34760. /**
  34761. * Called on pointer POINTERMOVE event if only a single touch is active.
  34762. */
  34763. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34764. /**
  34765. * Called on pointer POINTERDOUBLETAP event.
  34766. */
  34767. protected onDoubleTap(type: string): void;
  34768. /**
  34769. * Called on pointer POINTERMOVE event if multiple touches are active.
  34770. */
  34771. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34772. /**
  34773. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34774. * press.
  34775. */
  34776. protected onButtonDown(evt: PointerEvent): void;
  34777. /**
  34778. * Called each time a new POINTERUP event occurs. Ie, for each button
  34779. * release.
  34780. */
  34781. protected onButtonUp(evt: PointerEvent): void;
  34782. /**
  34783. * Called when window becomes inactive.
  34784. */
  34785. protected onLostFocus(): void;
  34786. }
  34787. }
  34788. declare module BABYLON {
  34789. /**
  34790. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34791. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34792. */
  34793. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34794. /**
  34795. * Defines the camera the input is attached to.
  34796. */
  34797. camera: ArcRotateCamera;
  34798. /**
  34799. * Defines the list of key codes associated with the up action (increase alpha)
  34800. */
  34801. keysUp: number[];
  34802. /**
  34803. * Defines the list of key codes associated with the down action (decrease alpha)
  34804. */
  34805. keysDown: number[];
  34806. /**
  34807. * Defines the list of key codes associated with the left action (increase beta)
  34808. */
  34809. keysLeft: number[];
  34810. /**
  34811. * Defines the list of key codes associated with the right action (decrease beta)
  34812. */
  34813. keysRight: number[];
  34814. /**
  34815. * Defines the list of key codes associated with the reset action.
  34816. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34817. */
  34818. keysReset: number[];
  34819. /**
  34820. * Defines the panning sensibility of the inputs.
  34821. * (How fast is the camera paning)
  34822. */
  34823. panningSensibility: number;
  34824. /**
  34825. * Defines the zooming sensibility of the inputs.
  34826. * (How fast is the camera zooming)
  34827. */
  34828. zoomingSensibility: number;
  34829. /**
  34830. * Defines wether maintaining the alt key down switch the movement mode from
  34831. * orientation to zoom.
  34832. */
  34833. useAltToZoom: boolean;
  34834. /**
  34835. * Rotation speed of the camera
  34836. */
  34837. angularSpeed: number;
  34838. private _keys;
  34839. private _ctrlPressed;
  34840. private _altPressed;
  34841. private _onCanvasBlurObserver;
  34842. private _onKeyboardObserver;
  34843. private _engine;
  34844. private _scene;
  34845. /**
  34846. * Attach the input controls to a specific dom element to get the input from.
  34847. * @param element Defines the element the controls should be listened from
  34848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34849. */
  34850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34851. /**
  34852. * Detach the current controls from the specified dom element.
  34853. * @param element Defines the element to stop listening the inputs from
  34854. */
  34855. detachControl(element: Nullable<HTMLElement>): void;
  34856. /**
  34857. * Update the current camera state depending on the inputs that have been used this frame.
  34858. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34859. */
  34860. checkInputs(): void;
  34861. /**
  34862. * Gets the class name of the current intput.
  34863. * @returns the class name
  34864. */
  34865. getClassName(): string;
  34866. /**
  34867. * Get the friendly name associated with the input class.
  34868. * @returns the input friendly name
  34869. */
  34870. getSimpleName(): string;
  34871. }
  34872. }
  34873. declare module BABYLON {
  34874. /**
  34875. * Manage the mouse wheel inputs to control an arc rotate camera.
  34876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34877. */
  34878. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34879. /**
  34880. * Defines the camera the input is attached to.
  34881. */
  34882. camera: ArcRotateCamera;
  34883. /**
  34884. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34885. */
  34886. wheelPrecision: number;
  34887. /**
  34888. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34889. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34890. */
  34891. wheelDeltaPercentage: number;
  34892. private _wheel;
  34893. private _observer;
  34894. /**
  34895. * Attach the input controls to a specific dom element to get the input from.
  34896. * @param element Defines the element the controls should be listened from
  34897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34898. */
  34899. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34900. /**
  34901. * Detach the current controls from the specified dom element.
  34902. * @param element Defines the element to stop listening the inputs from
  34903. */
  34904. detachControl(element: Nullable<HTMLElement>): void;
  34905. /**
  34906. * Gets the class name of the current intput.
  34907. * @returns the class name
  34908. */
  34909. getClassName(): string;
  34910. /**
  34911. * Get the friendly name associated with the input class.
  34912. * @returns the input friendly name
  34913. */
  34914. getSimpleName(): string;
  34915. }
  34916. }
  34917. declare module BABYLON {
  34918. /**
  34919. * Default Inputs manager for the ArcRotateCamera.
  34920. * It groups all the default supported inputs for ease of use.
  34921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34922. */
  34923. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34924. /**
  34925. * Instantiates a new ArcRotateCameraInputsManager.
  34926. * @param camera Defines the camera the inputs belong to
  34927. */
  34928. constructor(camera: ArcRotateCamera);
  34929. /**
  34930. * Add mouse wheel input support to the input manager.
  34931. * @returns the current input manager
  34932. */
  34933. addMouseWheel(): ArcRotateCameraInputsManager;
  34934. /**
  34935. * Add pointers input support to the input manager.
  34936. * @returns the current input manager
  34937. */
  34938. addPointers(): ArcRotateCameraInputsManager;
  34939. /**
  34940. * Add keyboard input support to the input manager.
  34941. * @returns the current input manager
  34942. */
  34943. addKeyboard(): ArcRotateCameraInputsManager;
  34944. }
  34945. }
  34946. declare module BABYLON {
  34947. /**
  34948. * This represents an orbital type of camera.
  34949. *
  34950. * 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.
  34951. * 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.
  34952. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34953. */
  34954. export class ArcRotateCamera extends TargetCamera {
  34955. /**
  34956. * Defines the rotation angle of the camera along the longitudinal axis.
  34957. */
  34958. alpha: number;
  34959. /**
  34960. * Defines the rotation angle of the camera along the latitudinal axis.
  34961. */
  34962. beta: number;
  34963. /**
  34964. * Defines the radius of the camera from it s target point.
  34965. */
  34966. radius: number;
  34967. protected _target: Vector3;
  34968. protected _targetHost: Nullable<AbstractMesh>;
  34969. /**
  34970. * Defines the target point of the camera.
  34971. * The camera looks towards it form the radius distance.
  34972. */
  34973. target: Vector3;
  34974. /**
  34975. * Define the current local position of the camera in the scene
  34976. */
  34977. position: Vector3;
  34978. protected _upVector: Vector3;
  34979. protected _upToYMatrix: Matrix;
  34980. protected _YToUpMatrix: Matrix;
  34981. /**
  34982. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  34983. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  34984. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  34985. */
  34986. upVector: Vector3;
  34987. /**
  34988. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  34989. */
  34990. setMatUp(): void;
  34991. /**
  34992. * Current inertia value on the longitudinal axis.
  34993. * The bigger this number the longer it will take for the camera to stop.
  34994. */
  34995. inertialAlphaOffset: number;
  34996. /**
  34997. * Current inertia value on the latitudinal axis.
  34998. * The bigger this number the longer it will take for the camera to stop.
  34999. */
  35000. inertialBetaOffset: number;
  35001. /**
  35002. * Current inertia value on the radius axis.
  35003. * The bigger this number the longer it will take for the camera to stop.
  35004. */
  35005. inertialRadiusOffset: number;
  35006. /**
  35007. * Minimum allowed angle on the longitudinal axis.
  35008. * This can help limiting how the Camera is able to move in the scene.
  35009. */
  35010. lowerAlphaLimit: Nullable<number>;
  35011. /**
  35012. * Maximum allowed angle on the longitudinal axis.
  35013. * This can help limiting how the Camera is able to move in the scene.
  35014. */
  35015. upperAlphaLimit: Nullable<number>;
  35016. /**
  35017. * Minimum allowed angle on the latitudinal axis.
  35018. * This can help limiting how the Camera is able to move in the scene.
  35019. */
  35020. lowerBetaLimit: number;
  35021. /**
  35022. * Maximum allowed angle on the latitudinal axis.
  35023. * This can help limiting how the Camera is able to move in the scene.
  35024. */
  35025. upperBetaLimit: number;
  35026. /**
  35027. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35028. * This can help limiting how the Camera is able to move in the scene.
  35029. */
  35030. lowerRadiusLimit: Nullable<number>;
  35031. /**
  35032. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35033. * This can help limiting how the Camera is able to move in the scene.
  35034. */
  35035. upperRadiusLimit: Nullable<number>;
  35036. /**
  35037. * Defines the current inertia value used during panning of the camera along the X axis.
  35038. */
  35039. inertialPanningX: number;
  35040. /**
  35041. * Defines the current inertia value used during panning of the camera along the Y axis.
  35042. */
  35043. inertialPanningY: number;
  35044. /**
  35045. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35046. * Basically if your fingers moves away from more than this distance you will be considered
  35047. * in pinch mode.
  35048. */
  35049. pinchToPanMaxDistance: number;
  35050. /**
  35051. * Defines the maximum distance the camera can pan.
  35052. * This could help keeping the cammera always in your scene.
  35053. */
  35054. panningDistanceLimit: Nullable<number>;
  35055. /**
  35056. * Defines the target of the camera before paning.
  35057. */
  35058. panningOriginTarget: Vector3;
  35059. /**
  35060. * Defines the value of the inertia used during panning.
  35061. * 0 would mean stop inertia and one would mean no decelleration at all.
  35062. */
  35063. panningInertia: number;
  35064. /**
  35065. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35066. */
  35067. angularSensibilityX: number;
  35068. /**
  35069. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35070. */
  35071. angularSensibilityY: number;
  35072. /**
  35073. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35074. */
  35075. pinchPrecision: number;
  35076. /**
  35077. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35078. * It will be used instead of pinchDeltaPrecision if different from 0.
  35079. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35080. */
  35081. pinchDeltaPercentage: number;
  35082. /**
  35083. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35084. */
  35085. panningSensibility: number;
  35086. /**
  35087. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35088. */
  35089. keysUp: number[];
  35090. /**
  35091. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35092. */
  35093. keysDown: number[];
  35094. /**
  35095. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35096. */
  35097. keysLeft: number[];
  35098. /**
  35099. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35100. */
  35101. keysRight: number[];
  35102. /**
  35103. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35104. */
  35105. wheelPrecision: number;
  35106. /**
  35107. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35108. * It will be used instead of pinchDeltaPrecision if different from 0.
  35109. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35110. */
  35111. wheelDeltaPercentage: number;
  35112. /**
  35113. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35114. */
  35115. zoomOnFactor: number;
  35116. /**
  35117. * Defines a screen offset for the camera position.
  35118. */
  35119. targetScreenOffset: Vector2;
  35120. /**
  35121. * Allows the camera to be completely reversed.
  35122. * If false the camera can not arrive upside down.
  35123. */
  35124. allowUpsideDown: boolean;
  35125. /**
  35126. * Define if double tap/click is used to restore the previously saved state of the camera.
  35127. */
  35128. useInputToRestoreState: boolean;
  35129. /** @hidden */
  35130. _viewMatrix: Matrix;
  35131. /** @hidden */
  35132. _useCtrlForPanning: boolean;
  35133. /** @hidden */
  35134. _panningMouseButton: number;
  35135. /**
  35136. * Defines the input associated to the camera.
  35137. */
  35138. inputs: ArcRotateCameraInputsManager;
  35139. /** @hidden */
  35140. _reset: () => void;
  35141. /**
  35142. * Defines the allowed panning axis.
  35143. */
  35144. panningAxis: Vector3;
  35145. protected _localDirection: Vector3;
  35146. protected _transformedDirection: Vector3;
  35147. private _bouncingBehavior;
  35148. /**
  35149. * Gets the bouncing behavior of the camera if it has been enabled.
  35150. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35151. */
  35152. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35153. /**
  35154. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35155. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35156. */
  35157. useBouncingBehavior: boolean;
  35158. private _framingBehavior;
  35159. /**
  35160. * Gets the framing behavior of the camera if it has been enabled.
  35161. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35162. */
  35163. readonly framingBehavior: Nullable<FramingBehavior>;
  35164. /**
  35165. * Defines if the framing behavior of the camera is enabled on the camera.
  35166. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35167. */
  35168. useFramingBehavior: boolean;
  35169. private _autoRotationBehavior;
  35170. /**
  35171. * Gets the auto rotation behavior of the camera if it has been enabled.
  35172. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35173. */
  35174. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35175. /**
  35176. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35177. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35178. */
  35179. useAutoRotationBehavior: boolean;
  35180. /**
  35181. * Observable triggered when the mesh target has been changed on the camera.
  35182. */
  35183. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35184. /**
  35185. * Event raised when the camera is colliding with a mesh.
  35186. */
  35187. onCollide: (collidedMesh: AbstractMesh) => void;
  35188. /**
  35189. * Defines whether the camera should check collision with the objects oh the scene.
  35190. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35191. */
  35192. checkCollisions: boolean;
  35193. /**
  35194. * Defines the collision radius of the camera.
  35195. * This simulates a sphere around the camera.
  35196. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35197. */
  35198. collisionRadius: Vector3;
  35199. protected _collider: Collider;
  35200. protected _previousPosition: Vector3;
  35201. protected _collisionVelocity: Vector3;
  35202. protected _newPosition: Vector3;
  35203. protected _previousAlpha: number;
  35204. protected _previousBeta: number;
  35205. protected _previousRadius: number;
  35206. protected _collisionTriggered: boolean;
  35207. protected _targetBoundingCenter: Nullable<Vector3>;
  35208. private _computationVector;
  35209. /**
  35210. * Instantiates a new ArcRotateCamera in a given scene
  35211. * @param name Defines the name of the camera
  35212. * @param alpha Defines the camera rotation along the logitudinal axis
  35213. * @param beta Defines the camera rotation along the latitudinal axis
  35214. * @param radius Defines the camera distance from its target
  35215. * @param target Defines the camera target
  35216. * @param scene Defines the scene the camera belongs to
  35217. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35218. */
  35219. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35220. /** @hidden */
  35221. _initCache(): void;
  35222. /** @hidden */
  35223. _updateCache(ignoreParentClass?: boolean): void;
  35224. protected _getTargetPosition(): Vector3;
  35225. private _storedAlpha;
  35226. private _storedBeta;
  35227. private _storedRadius;
  35228. private _storedTarget;
  35229. /**
  35230. * Stores the current state of the camera (alpha, beta, radius and target)
  35231. * @returns the camera itself
  35232. */
  35233. storeState(): Camera;
  35234. /**
  35235. * @hidden
  35236. * Restored camera state. You must call storeState() first
  35237. */
  35238. _restoreStateValues(): boolean;
  35239. /** @hidden */
  35240. _isSynchronizedViewMatrix(): boolean;
  35241. /**
  35242. * Attached controls to the current camera.
  35243. * @param element Defines the element the controls should be listened from
  35244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35245. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35246. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35247. */
  35248. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35249. /**
  35250. * Detach the current controls from the camera.
  35251. * The camera will stop reacting to inputs.
  35252. * @param element Defines the element to stop listening the inputs from
  35253. */
  35254. detachControl(element: HTMLElement): void;
  35255. /** @hidden */
  35256. _checkInputs(): void;
  35257. protected _checkLimits(): void;
  35258. /**
  35259. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35260. */
  35261. rebuildAnglesAndRadius(): void;
  35262. /**
  35263. * Use a position to define the current camera related information like aplha, beta and radius
  35264. * @param position Defines the position to set the camera at
  35265. */
  35266. setPosition(position: Vector3): void;
  35267. /**
  35268. * Defines the target the camera should look at.
  35269. * This will automatically adapt alpha beta and radius to fit within the new target.
  35270. * @param target Defines the new target as a Vector or a mesh
  35271. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35272. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35273. */
  35274. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35275. /** @hidden */
  35276. _getViewMatrix(): Matrix;
  35277. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35278. /**
  35279. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35280. * @param meshes Defines the mesh to zoom on
  35281. * @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)
  35282. */
  35283. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35284. /**
  35285. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35286. * The target will be changed but the radius
  35287. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35288. * @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)
  35289. */
  35290. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35291. min: Vector3;
  35292. max: Vector3;
  35293. distance: number;
  35294. }, doNotUpdateMaxZ?: boolean): void;
  35295. /**
  35296. * @override
  35297. * Override Camera.createRigCamera
  35298. */
  35299. createRigCamera(name: string, cameraIndex: number): Camera;
  35300. /**
  35301. * @hidden
  35302. * @override
  35303. * Override Camera._updateRigCameras
  35304. */
  35305. _updateRigCameras(): void;
  35306. /**
  35307. * Destroy the camera and release the current resources hold by it.
  35308. */
  35309. dispose(): void;
  35310. /**
  35311. * Gets the current object class name.
  35312. * @return the class name
  35313. */
  35314. getClassName(): string;
  35315. }
  35316. }
  35317. declare module BABYLON {
  35318. /**
  35319. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35320. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35321. */
  35322. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35323. /**
  35324. * Gets the name of the behavior.
  35325. */
  35326. readonly name: string;
  35327. private _zoomStopsAnimation;
  35328. private _idleRotationSpeed;
  35329. private _idleRotationWaitTime;
  35330. private _idleRotationSpinupTime;
  35331. /**
  35332. * Sets the flag that indicates if user zooming should stop animation.
  35333. */
  35334. /**
  35335. * Gets the flag that indicates if user zooming should stop animation.
  35336. */
  35337. zoomStopsAnimation: boolean;
  35338. /**
  35339. * Sets the default speed at which the camera rotates around the model.
  35340. */
  35341. /**
  35342. * Gets the default speed at which the camera rotates around the model.
  35343. */
  35344. idleRotationSpeed: number;
  35345. /**
  35346. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35347. */
  35348. /**
  35349. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35350. */
  35351. idleRotationWaitTime: number;
  35352. /**
  35353. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35354. */
  35355. /**
  35356. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35357. */
  35358. idleRotationSpinupTime: number;
  35359. /**
  35360. * Gets a value indicating if the camera is currently rotating because of this behavior
  35361. */
  35362. readonly rotationInProgress: boolean;
  35363. private _onPrePointerObservableObserver;
  35364. private _onAfterCheckInputsObserver;
  35365. private _attachedCamera;
  35366. private _isPointerDown;
  35367. private _lastFrameTime;
  35368. private _lastInteractionTime;
  35369. private _cameraRotationSpeed;
  35370. /**
  35371. * Initializes the behavior.
  35372. */
  35373. init(): void;
  35374. /**
  35375. * Attaches the behavior to its arc rotate camera.
  35376. * @param camera Defines the camera to attach the behavior to
  35377. */
  35378. attach(camera: ArcRotateCamera): void;
  35379. /**
  35380. * Detaches the behavior from its current arc rotate camera.
  35381. */
  35382. detach(): void;
  35383. /**
  35384. * Returns true if user is scrolling.
  35385. * @return true if user is scrolling.
  35386. */
  35387. private _userIsZooming;
  35388. private _lastFrameRadius;
  35389. private _shouldAnimationStopForInteraction;
  35390. /**
  35391. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35392. */
  35393. private _applyUserInteraction;
  35394. private _userIsMoving;
  35395. }
  35396. }
  35397. declare module BABYLON {
  35398. /**
  35399. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35400. */
  35401. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35402. private ui;
  35403. /**
  35404. * The name of the behavior
  35405. */
  35406. name: string;
  35407. /**
  35408. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35409. */
  35410. distanceAwayFromFace: number;
  35411. /**
  35412. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35413. */
  35414. distanceAwayFromBottomOfFace: number;
  35415. private _faceVectors;
  35416. private _target;
  35417. private _scene;
  35418. private _onRenderObserver;
  35419. private _tmpMatrix;
  35420. private _tmpVector;
  35421. /**
  35422. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35423. * @param ui The transform node that should be attched to the mesh
  35424. */
  35425. constructor(ui: TransformNode);
  35426. /**
  35427. * Initializes the behavior
  35428. */
  35429. init(): void;
  35430. private _closestFace;
  35431. private _zeroVector;
  35432. private _lookAtTmpMatrix;
  35433. private _lookAtToRef;
  35434. /**
  35435. * Attaches the AttachToBoxBehavior to the passed in mesh
  35436. * @param target The mesh that the specified node will be attached to
  35437. */
  35438. attach(target: Mesh): void;
  35439. /**
  35440. * Detaches the behavior from the mesh
  35441. */
  35442. detach(): void;
  35443. }
  35444. }
  35445. declare module BABYLON {
  35446. /**
  35447. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35448. */
  35449. export class FadeInOutBehavior implements Behavior<Mesh> {
  35450. /**
  35451. * Time in milliseconds to delay before fading in (Default: 0)
  35452. */
  35453. delay: number;
  35454. /**
  35455. * Time in milliseconds for the mesh to fade in (Default: 300)
  35456. */
  35457. fadeInTime: number;
  35458. private _millisecondsPerFrame;
  35459. private _hovered;
  35460. private _hoverValue;
  35461. private _ownerNode;
  35462. /**
  35463. * Instatiates the FadeInOutBehavior
  35464. */
  35465. constructor();
  35466. /**
  35467. * The name of the behavior
  35468. */
  35469. readonly name: string;
  35470. /**
  35471. * Initializes the behavior
  35472. */
  35473. init(): void;
  35474. /**
  35475. * Attaches the fade behavior on the passed in mesh
  35476. * @param ownerNode The mesh that will be faded in/out once attached
  35477. */
  35478. attach(ownerNode: Mesh): void;
  35479. /**
  35480. * Detaches the behavior from the mesh
  35481. */
  35482. detach(): void;
  35483. /**
  35484. * Triggers the mesh to begin fading in or out
  35485. * @param value if the object should fade in or out (true to fade in)
  35486. */
  35487. fadeIn(value: boolean): void;
  35488. private _update;
  35489. private _setAllVisibility;
  35490. }
  35491. }
  35492. declare module BABYLON {
  35493. /**
  35494. * Class containing a set of static utilities functions for managing Pivots
  35495. * @hidden
  35496. */
  35497. export class PivotTools {
  35498. private static _PivotCached;
  35499. private static _OldPivotPoint;
  35500. private static _PivotTranslation;
  35501. private static _PivotTmpVector;
  35502. /** @hidden */
  35503. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35504. /** @hidden */
  35505. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35506. }
  35507. }
  35508. declare module BABYLON {
  35509. /**
  35510. * Class containing static functions to help procedurally build meshes
  35511. */
  35512. export class PlaneBuilder {
  35513. /**
  35514. * Creates a plane mesh
  35515. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35516. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35517. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35521. * @param name defines the name of the mesh
  35522. * @param options defines the options used to create the mesh
  35523. * @param scene defines the hosting scene
  35524. * @returns the plane mesh
  35525. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35526. */
  35527. static CreatePlane(name: string, options: {
  35528. size?: number;
  35529. width?: number;
  35530. height?: number;
  35531. sideOrientation?: number;
  35532. frontUVs?: Vector4;
  35533. backUVs?: Vector4;
  35534. updatable?: boolean;
  35535. sourcePlane?: Plane;
  35536. }, scene?: Nullable<Scene>): Mesh;
  35537. }
  35538. }
  35539. declare module BABYLON {
  35540. /**
  35541. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35542. */
  35543. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35544. private static _AnyMouseID;
  35545. private _attachedNode;
  35546. private _dragPlane;
  35547. private _scene;
  35548. private _pointerObserver;
  35549. private _beforeRenderObserver;
  35550. private static _planeScene;
  35551. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35552. /**
  35553. * 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)
  35554. */
  35555. maxDragAngle: number;
  35556. /**
  35557. * @hidden
  35558. */
  35559. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35560. /**
  35561. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35562. */
  35563. currentDraggingPointerID: number;
  35564. /**
  35565. * The last position where the pointer hit the drag plane in world space
  35566. */
  35567. lastDragPosition: Vector3;
  35568. /**
  35569. * If the behavior is currently in a dragging state
  35570. */
  35571. dragging: boolean;
  35572. /**
  35573. * 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)
  35574. */
  35575. dragDeltaRatio: number;
  35576. /**
  35577. * If the drag plane orientation should be updated during the dragging (Default: true)
  35578. */
  35579. updateDragPlane: boolean;
  35580. private _debugMode;
  35581. private _moving;
  35582. /**
  35583. * Fires each time the attached mesh is dragged with the pointer
  35584. * * delta between last drag position and current drag position in world space
  35585. * * dragDistance along the drag axis
  35586. * * dragPlaneNormal normal of the current drag plane used during the drag
  35587. * * dragPlanePoint in world space where the drag intersects the drag plane
  35588. */
  35589. onDragObservable: Observable<{
  35590. delta: Vector3;
  35591. dragPlanePoint: Vector3;
  35592. dragPlaneNormal: Vector3;
  35593. dragDistance: number;
  35594. pointerId: number;
  35595. }>;
  35596. /**
  35597. * Fires each time a drag begins (eg. mouse down on mesh)
  35598. */
  35599. onDragStartObservable: Observable<{
  35600. dragPlanePoint: Vector3;
  35601. pointerId: number;
  35602. }>;
  35603. /**
  35604. * Fires each time a drag ends (eg. mouse release after drag)
  35605. */
  35606. onDragEndObservable: Observable<{
  35607. dragPlanePoint: Vector3;
  35608. pointerId: number;
  35609. }>;
  35610. /**
  35611. * If the attached mesh should be moved when dragged
  35612. */
  35613. moveAttached: boolean;
  35614. /**
  35615. * If the drag behavior will react to drag events (Default: true)
  35616. */
  35617. enabled: boolean;
  35618. /**
  35619. * If camera controls should be detached during the drag
  35620. */
  35621. detachCameraControls: boolean;
  35622. /**
  35623. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35624. */
  35625. useObjectOrienationForDragging: boolean;
  35626. private _options;
  35627. /**
  35628. * Creates a pointer drag behavior that can be attached to a mesh
  35629. * @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)
  35630. */
  35631. constructor(options?: {
  35632. dragAxis?: Vector3;
  35633. dragPlaneNormal?: Vector3;
  35634. });
  35635. /**
  35636. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35637. */
  35638. validateDrag: (targetPosition: Vector3) => boolean;
  35639. /**
  35640. * The name of the behavior
  35641. */
  35642. readonly name: string;
  35643. /**
  35644. * Initializes the behavior
  35645. */
  35646. init(): void;
  35647. private _tmpVector;
  35648. private _alternatePickedPoint;
  35649. private _worldDragAxis;
  35650. private _targetPosition;
  35651. private _attachedElement;
  35652. /**
  35653. * Attaches the drag behavior the passed in mesh
  35654. * @param ownerNode The mesh that will be dragged around once attached
  35655. */
  35656. attach(ownerNode: AbstractMesh): void;
  35657. /**
  35658. * Force relase the drag action by code.
  35659. */
  35660. releaseDrag(): void;
  35661. private _startDragRay;
  35662. private _lastPointerRay;
  35663. /**
  35664. * Simulates the start of a pointer drag event on the behavior
  35665. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35666. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35667. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35668. */
  35669. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35670. private _startDrag;
  35671. private _dragDelta;
  35672. private _moveDrag;
  35673. private _pickWithRayOnDragPlane;
  35674. private _pointA;
  35675. private _pointB;
  35676. private _pointC;
  35677. private _lineA;
  35678. private _lineB;
  35679. private _localAxis;
  35680. private _lookAt;
  35681. private _updateDragPlanePosition;
  35682. /**
  35683. * Detaches the behavior from the mesh
  35684. */
  35685. detach(): void;
  35686. }
  35687. }
  35688. declare module BABYLON {
  35689. /**
  35690. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35691. */
  35692. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35693. private _dragBehaviorA;
  35694. private _dragBehaviorB;
  35695. private _startDistance;
  35696. private _initialScale;
  35697. private _targetScale;
  35698. private _ownerNode;
  35699. private _sceneRenderObserver;
  35700. /**
  35701. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35702. */
  35703. constructor();
  35704. /**
  35705. * The name of the behavior
  35706. */
  35707. readonly name: string;
  35708. /**
  35709. * Initializes the behavior
  35710. */
  35711. init(): void;
  35712. private _getCurrentDistance;
  35713. /**
  35714. * Attaches the scale behavior the passed in mesh
  35715. * @param ownerNode The mesh that will be scaled around once attached
  35716. */
  35717. attach(ownerNode: Mesh): void;
  35718. /**
  35719. * Detaches the behavior from the mesh
  35720. */
  35721. detach(): void;
  35722. }
  35723. }
  35724. declare module BABYLON {
  35725. /**
  35726. * 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
  35727. */
  35728. export class SixDofDragBehavior implements Behavior<Mesh> {
  35729. private static _virtualScene;
  35730. private _ownerNode;
  35731. private _sceneRenderObserver;
  35732. private _scene;
  35733. private _targetPosition;
  35734. private _virtualOriginMesh;
  35735. private _virtualDragMesh;
  35736. private _pointerObserver;
  35737. private _moving;
  35738. private _startingOrientation;
  35739. /**
  35740. * 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)
  35741. */
  35742. private zDragFactor;
  35743. /**
  35744. * If the object should rotate to face the drag origin
  35745. */
  35746. rotateDraggedObject: boolean;
  35747. /**
  35748. * If the behavior is currently in a dragging state
  35749. */
  35750. dragging: boolean;
  35751. /**
  35752. * 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)
  35753. */
  35754. dragDeltaRatio: number;
  35755. /**
  35756. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35757. */
  35758. currentDraggingPointerID: number;
  35759. /**
  35760. * If camera controls should be detached during the drag
  35761. */
  35762. detachCameraControls: boolean;
  35763. /**
  35764. * Fires each time a drag starts
  35765. */
  35766. onDragStartObservable: Observable<{}>;
  35767. /**
  35768. * Fires each time a drag ends (eg. mouse release after drag)
  35769. */
  35770. onDragEndObservable: Observable<{}>;
  35771. /**
  35772. * 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
  35773. */
  35774. constructor();
  35775. /**
  35776. * The name of the behavior
  35777. */
  35778. readonly name: string;
  35779. /**
  35780. * Initializes the behavior
  35781. */
  35782. init(): void;
  35783. /**
  35784. * Attaches the scale behavior the passed in mesh
  35785. * @param ownerNode The mesh that will be scaled around once attached
  35786. */
  35787. attach(ownerNode: Mesh): void;
  35788. /**
  35789. * Detaches the behavior from the mesh
  35790. */
  35791. detach(): void;
  35792. }
  35793. }
  35794. declare module BABYLON {
  35795. /**
  35796. * Class used to apply inverse kinematics to bones
  35797. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35798. */
  35799. export class BoneIKController {
  35800. private static _tmpVecs;
  35801. private static _tmpQuat;
  35802. private static _tmpMats;
  35803. /**
  35804. * Gets or sets the target mesh
  35805. */
  35806. targetMesh: AbstractMesh;
  35807. /** Gets or sets the mesh used as pole */
  35808. poleTargetMesh: AbstractMesh;
  35809. /**
  35810. * Gets or sets the bone used as pole
  35811. */
  35812. poleTargetBone: Nullable<Bone>;
  35813. /**
  35814. * Gets or sets the target position
  35815. */
  35816. targetPosition: Vector3;
  35817. /**
  35818. * Gets or sets the pole target position
  35819. */
  35820. poleTargetPosition: Vector3;
  35821. /**
  35822. * Gets or sets the pole target local offset
  35823. */
  35824. poleTargetLocalOffset: Vector3;
  35825. /**
  35826. * Gets or sets the pole angle
  35827. */
  35828. poleAngle: number;
  35829. /**
  35830. * Gets or sets the mesh associated with the controller
  35831. */
  35832. mesh: AbstractMesh;
  35833. /**
  35834. * 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)
  35835. */
  35836. slerpAmount: number;
  35837. private _bone1Quat;
  35838. private _bone1Mat;
  35839. private _bone2Ang;
  35840. private _bone1;
  35841. private _bone2;
  35842. private _bone1Length;
  35843. private _bone2Length;
  35844. private _maxAngle;
  35845. private _maxReach;
  35846. private _rightHandedSystem;
  35847. private _bendAxis;
  35848. private _slerping;
  35849. private _adjustRoll;
  35850. /**
  35851. * Gets or sets maximum allowed angle
  35852. */
  35853. maxAngle: number;
  35854. /**
  35855. * Creates a new BoneIKController
  35856. * @param mesh defines the mesh to control
  35857. * @param bone defines the bone to control
  35858. * @param options defines options to set up the controller
  35859. */
  35860. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35861. targetMesh?: AbstractMesh;
  35862. poleTargetMesh?: AbstractMesh;
  35863. poleTargetBone?: Bone;
  35864. poleTargetLocalOffset?: Vector3;
  35865. poleAngle?: number;
  35866. bendAxis?: Vector3;
  35867. maxAngle?: number;
  35868. slerpAmount?: number;
  35869. });
  35870. private _setMaxAngle;
  35871. /**
  35872. * Force the controller to update the bones
  35873. */
  35874. update(): void;
  35875. }
  35876. }
  35877. declare module BABYLON {
  35878. /**
  35879. * Class used to make a bone look toward a point in space
  35880. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35881. */
  35882. export class BoneLookController {
  35883. private static _tmpVecs;
  35884. private static _tmpQuat;
  35885. private static _tmpMats;
  35886. /**
  35887. * The target Vector3 that the bone will look at
  35888. */
  35889. target: Vector3;
  35890. /**
  35891. * The mesh that the bone is attached to
  35892. */
  35893. mesh: AbstractMesh;
  35894. /**
  35895. * The bone that will be looking to the target
  35896. */
  35897. bone: Bone;
  35898. /**
  35899. * The up axis of the coordinate system that is used when the bone is rotated
  35900. */
  35901. upAxis: Vector3;
  35902. /**
  35903. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35904. */
  35905. upAxisSpace: Space;
  35906. /**
  35907. * Used to make an adjustment to the yaw of the bone
  35908. */
  35909. adjustYaw: number;
  35910. /**
  35911. * Used to make an adjustment to the pitch of the bone
  35912. */
  35913. adjustPitch: number;
  35914. /**
  35915. * Used to make an adjustment to the roll of the bone
  35916. */
  35917. adjustRoll: number;
  35918. /**
  35919. * 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)
  35920. */
  35921. slerpAmount: number;
  35922. private _minYaw;
  35923. private _maxYaw;
  35924. private _minPitch;
  35925. private _maxPitch;
  35926. private _minYawSin;
  35927. private _minYawCos;
  35928. private _maxYawSin;
  35929. private _maxYawCos;
  35930. private _midYawConstraint;
  35931. private _minPitchTan;
  35932. private _maxPitchTan;
  35933. private _boneQuat;
  35934. private _slerping;
  35935. private _transformYawPitch;
  35936. private _transformYawPitchInv;
  35937. private _firstFrameSkipped;
  35938. private _yawRange;
  35939. private _fowardAxis;
  35940. /**
  35941. * Gets or sets the minimum yaw angle that the bone can look to
  35942. */
  35943. minYaw: number;
  35944. /**
  35945. * Gets or sets the maximum yaw angle that the bone can look to
  35946. */
  35947. maxYaw: number;
  35948. /**
  35949. * Gets or sets the minimum pitch angle that the bone can look to
  35950. */
  35951. minPitch: number;
  35952. /**
  35953. * Gets or sets the maximum pitch angle that the bone can look to
  35954. */
  35955. maxPitch: number;
  35956. /**
  35957. * Create a BoneLookController
  35958. * @param mesh the mesh that the bone belongs to
  35959. * @param bone the bone that will be looking to the target
  35960. * @param target the target Vector3 to look at
  35961. * @param options optional settings:
  35962. * * maxYaw: the maximum angle the bone will yaw to
  35963. * * minYaw: the minimum angle the bone will yaw to
  35964. * * maxPitch: the maximum angle the bone will pitch to
  35965. * * minPitch: the minimum angle the bone will yaw to
  35966. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35967. * * upAxis: the up axis of the coordinate system
  35968. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35969. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35970. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35971. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35972. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35973. * * adjustRoll: used to make an adjustment to the roll of the bone
  35974. **/
  35975. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35976. maxYaw?: number;
  35977. minYaw?: number;
  35978. maxPitch?: number;
  35979. minPitch?: number;
  35980. slerpAmount?: number;
  35981. upAxis?: Vector3;
  35982. upAxisSpace?: Space;
  35983. yawAxis?: Vector3;
  35984. pitchAxis?: Vector3;
  35985. adjustYaw?: number;
  35986. adjustPitch?: number;
  35987. adjustRoll?: number;
  35988. });
  35989. /**
  35990. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35991. */
  35992. update(): void;
  35993. private _getAngleDiff;
  35994. private _getAngleBetween;
  35995. private _isAngleBetween;
  35996. }
  35997. }
  35998. declare module BABYLON {
  35999. /**
  36000. * Manage the gamepad inputs to control an arc rotate camera.
  36001. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36002. */
  36003. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36004. /**
  36005. * Defines the camera the input is attached to.
  36006. */
  36007. camera: ArcRotateCamera;
  36008. /**
  36009. * Defines the gamepad the input is gathering event from.
  36010. */
  36011. gamepad: Nullable<Gamepad>;
  36012. /**
  36013. * Defines the gamepad rotation sensiblity.
  36014. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36015. */
  36016. gamepadRotationSensibility: number;
  36017. /**
  36018. * Defines the gamepad move sensiblity.
  36019. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36020. */
  36021. gamepadMoveSensibility: number;
  36022. private _onGamepadConnectedObserver;
  36023. private _onGamepadDisconnectedObserver;
  36024. /**
  36025. * Attach the input controls to a specific dom element to get the input from.
  36026. * @param element Defines the element the controls should be listened from
  36027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36028. */
  36029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36030. /**
  36031. * Detach the current controls from the specified dom element.
  36032. * @param element Defines the element to stop listening the inputs from
  36033. */
  36034. detachControl(element: Nullable<HTMLElement>): void;
  36035. /**
  36036. * Update the current camera state depending on the inputs that have been used this frame.
  36037. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36038. */
  36039. checkInputs(): void;
  36040. /**
  36041. * Gets the class name of the current intput.
  36042. * @returns the class name
  36043. */
  36044. getClassName(): string;
  36045. /**
  36046. * Get the friendly name associated with the input class.
  36047. * @returns the input friendly name
  36048. */
  36049. getSimpleName(): string;
  36050. }
  36051. }
  36052. declare module BABYLON {
  36053. interface ArcRotateCameraInputsManager {
  36054. /**
  36055. * Add orientation input support to the input manager.
  36056. * @returns the current input manager
  36057. */
  36058. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36059. }
  36060. /**
  36061. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36062. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36063. */
  36064. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36065. /**
  36066. * Defines the camera the input is attached to.
  36067. */
  36068. camera: ArcRotateCamera;
  36069. /**
  36070. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36071. */
  36072. alphaCorrection: number;
  36073. /**
  36074. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36075. */
  36076. gammaCorrection: number;
  36077. private _alpha;
  36078. private _gamma;
  36079. private _dirty;
  36080. private _deviceOrientationHandler;
  36081. /**
  36082. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36083. */
  36084. constructor();
  36085. /**
  36086. * Attach the input controls to a specific dom element to get the input from.
  36087. * @param element Defines the element the controls should be listened from
  36088. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36089. */
  36090. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36091. /** @hidden */
  36092. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36093. /**
  36094. * Update the current camera state depending on the inputs that have been used this frame.
  36095. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36096. */
  36097. checkInputs(): void;
  36098. /**
  36099. * Detach the current controls from the specified dom element.
  36100. * @param element Defines the element to stop listening the inputs from
  36101. */
  36102. detachControl(element: Nullable<HTMLElement>): void;
  36103. /**
  36104. * Gets the class name of the current intput.
  36105. * @returns the class name
  36106. */
  36107. getClassName(): string;
  36108. /**
  36109. * Get the friendly name associated with the input class.
  36110. * @returns the input friendly name
  36111. */
  36112. getSimpleName(): string;
  36113. }
  36114. }
  36115. declare module BABYLON {
  36116. /**
  36117. * Listen to mouse events to control the camera.
  36118. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36119. */
  36120. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36121. /**
  36122. * Defines the camera the input is attached to.
  36123. */
  36124. camera: FlyCamera;
  36125. /**
  36126. * Defines if touch is enabled. (Default is true.)
  36127. */
  36128. touchEnabled: boolean;
  36129. /**
  36130. * Defines the buttons associated with the input to handle camera rotation.
  36131. */
  36132. buttons: number[];
  36133. /**
  36134. * Assign buttons for Yaw control.
  36135. */
  36136. buttonsYaw: number[];
  36137. /**
  36138. * Assign buttons for Pitch control.
  36139. */
  36140. buttonsPitch: number[];
  36141. /**
  36142. * Assign buttons for Roll control.
  36143. */
  36144. buttonsRoll: number[];
  36145. /**
  36146. * Detect if any button is being pressed while mouse is moved.
  36147. * -1 = Mouse locked.
  36148. * 0 = Left button.
  36149. * 1 = Middle Button.
  36150. * 2 = Right Button.
  36151. */
  36152. activeButton: number;
  36153. /**
  36154. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36155. * Higher values reduce its sensitivity.
  36156. */
  36157. angularSensibility: number;
  36158. private _mousemoveCallback;
  36159. private _observer;
  36160. private _rollObserver;
  36161. private previousPosition;
  36162. private noPreventDefault;
  36163. private element;
  36164. /**
  36165. * Listen to mouse events to control the camera.
  36166. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36168. */
  36169. constructor(touchEnabled?: boolean);
  36170. /**
  36171. * Attach the mouse control to the HTML DOM element.
  36172. * @param element Defines the element that listens to the input events.
  36173. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36174. */
  36175. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36176. /**
  36177. * Detach the current controls from the specified dom element.
  36178. * @param element Defines the element to stop listening the inputs from
  36179. */
  36180. detachControl(element: Nullable<HTMLElement>): void;
  36181. /**
  36182. * Gets the class name of the current input.
  36183. * @returns the class name.
  36184. */
  36185. getClassName(): string;
  36186. /**
  36187. * Get the friendly name associated with the input class.
  36188. * @returns the input's friendly name.
  36189. */
  36190. getSimpleName(): string;
  36191. private _pointerInput;
  36192. private _onMouseMove;
  36193. /**
  36194. * Rotate camera by mouse offset.
  36195. */
  36196. private rotateCamera;
  36197. }
  36198. }
  36199. declare module BABYLON {
  36200. /**
  36201. * Default Inputs manager for the FlyCamera.
  36202. * It groups all the default supported inputs for ease of use.
  36203. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36204. */
  36205. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36206. /**
  36207. * Instantiates a new FlyCameraInputsManager.
  36208. * @param camera Defines the camera the inputs belong to.
  36209. */
  36210. constructor(camera: FlyCamera);
  36211. /**
  36212. * Add keyboard input support to the input manager.
  36213. * @returns the new FlyCameraKeyboardMoveInput().
  36214. */
  36215. addKeyboard(): FlyCameraInputsManager;
  36216. /**
  36217. * Add mouse input support to the input manager.
  36218. * @param touchEnabled Enable touch screen support.
  36219. * @returns the new FlyCameraMouseInput().
  36220. */
  36221. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36222. }
  36223. }
  36224. declare module BABYLON {
  36225. /**
  36226. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36227. * such as in a 3D Space Shooter or a Flight Simulator.
  36228. */
  36229. export class FlyCamera extends TargetCamera {
  36230. /**
  36231. * Define the collision ellipsoid of the camera.
  36232. * This is helpful for simulating a camera body, like a player's body.
  36233. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36234. */
  36235. ellipsoid: Vector3;
  36236. /**
  36237. * Define an offset for the position of the ellipsoid around the camera.
  36238. * This can be helpful if the camera is attached away from the player's body center,
  36239. * such as at its head.
  36240. */
  36241. ellipsoidOffset: Vector3;
  36242. /**
  36243. * Enable or disable collisions of the camera with the rest of the scene objects.
  36244. */
  36245. checkCollisions: boolean;
  36246. /**
  36247. * Enable or disable gravity on the camera.
  36248. */
  36249. applyGravity: boolean;
  36250. /**
  36251. * Define the current direction the camera is moving to.
  36252. */
  36253. cameraDirection: Vector3;
  36254. /**
  36255. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36256. * This overrides and empties cameraRotation.
  36257. */
  36258. rotationQuaternion: Quaternion;
  36259. /**
  36260. * Track Roll to maintain the wanted Rolling when looking around.
  36261. */
  36262. _trackRoll: number;
  36263. /**
  36264. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36265. */
  36266. rollCorrect: number;
  36267. /**
  36268. * Mimic a banked turn, Rolling the camera when Yawing.
  36269. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36270. */
  36271. bankedTurn: boolean;
  36272. /**
  36273. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36274. */
  36275. bankedTurnLimit: number;
  36276. /**
  36277. * Value of 0 disables the banked Roll.
  36278. * Value of 1 is equal to the Yaw angle in radians.
  36279. */
  36280. bankedTurnMultiplier: number;
  36281. /**
  36282. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36283. */
  36284. inputs: FlyCameraInputsManager;
  36285. /**
  36286. * Gets the input sensibility for mouse input.
  36287. * Higher values reduce sensitivity.
  36288. */
  36289. /**
  36290. * Sets the input sensibility for a mouse input.
  36291. * Higher values reduce sensitivity.
  36292. */
  36293. angularSensibility: number;
  36294. /**
  36295. * Get the keys for camera movement forward.
  36296. */
  36297. /**
  36298. * Set the keys for camera movement forward.
  36299. */
  36300. keysForward: number[];
  36301. /**
  36302. * Get the keys for camera movement backward.
  36303. */
  36304. keysBackward: number[];
  36305. /**
  36306. * Get the keys for camera movement up.
  36307. */
  36308. /**
  36309. * Set the keys for camera movement up.
  36310. */
  36311. keysUp: number[];
  36312. /**
  36313. * Get the keys for camera movement down.
  36314. */
  36315. /**
  36316. * Set the keys for camera movement down.
  36317. */
  36318. keysDown: number[];
  36319. /**
  36320. * Get the keys for camera movement left.
  36321. */
  36322. /**
  36323. * Set the keys for camera movement left.
  36324. */
  36325. keysLeft: number[];
  36326. /**
  36327. * Set the keys for camera movement right.
  36328. */
  36329. /**
  36330. * Set the keys for camera movement right.
  36331. */
  36332. keysRight: number[];
  36333. /**
  36334. * Event raised when the camera collides with a mesh in the scene.
  36335. */
  36336. onCollide: (collidedMesh: AbstractMesh) => void;
  36337. private _collider;
  36338. private _needMoveForGravity;
  36339. private _oldPosition;
  36340. private _diffPosition;
  36341. private _newPosition;
  36342. /** @hidden */
  36343. _localDirection: Vector3;
  36344. /** @hidden */
  36345. _transformedDirection: Vector3;
  36346. /**
  36347. * Instantiates a FlyCamera.
  36348. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36349. * such as in a 3D Space Shooter or a Flight Simulator.
  36350. * @param name Define the name of the camera in the scene.
  36351. * @param position Define the starting position of the camera in the scene.
  36352. * @param scene Define the scene the camera belongs to.
  36353. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36354. */
  36355. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36356. /**
  36357. * Attach a control to the HTML DOM element.
  36358. * @param element Defines the element that listens to the input events.
  36359. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36360. */
  36361. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36362. /**
  36363. * Detach a control from the HTML DOM element.
  36364. * The camera will stop reacting to that input.
  36365. * @param element Defines the element that listens to the input events.
  36366. */
  36367. detachControl(element: HTMLElement): void;
  36368. private _collisionMask;
  36369. /**
  36370. * Get the mask that the camera ignores in collision events.
  36371. */
  36372. /**
  36373. * Set the mask that the camera ignores in collision events.
  36374. */
  36375. collisionMask: number;
  36376. /** @hidden */
  36377. _collideWithWorld(displacement: Vector3): void;
  36378. /** @hidden */
  36379. private _onCollisionPositionChange;
  36380. /** @hidden */
  36381. _checkInputs(): void;
  36382. /** @hidden */
  36383. _decideIfNeedsToMove(): boolean;
  36384. /** @hidden */
  36385. _updatePosition(): void;
  36386. /**
  36387. * Restore the Roll to its target value at the rate specified.
  36388. * @param rate - Higher means slower restoring.
  36389. * @hidden
  36390. */
  36391. restoreRoll(rate: number): void;
  36392. /**
  36393. * Destroy the camera and release the current resources held by it.
  36394. */
  36395. dispose(): void;
  36396. /**
  36397. * Get the current object class name.
  36398. * @returns the class name.
  36399. */
  36400. getClassName(): string;
  36401. }
  36402. }
  36403. declare module BABYLON {
  36404. /**
  36405. * Listen to keyboard events to control the camera.
  36406. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36407. */
  36408. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36409. /**
  36410. * Defines the camera the input is attached to.
  36411. */
  36412. camera: FlyCamera;
  36413. /**
  36414. * The list of keyboard keys used to control the forward move of the camera.
  36415. */
  36416. keysForward: number[];
  36417. /**
  36418. * The list of keyboard keys used to control the backward move of the camera.
  36419. */
  36420. keysBackward: number[];
  36421. /**
  36422. * The list of keyboard keys used to control the forward move of the camera.
  36423. */
  36424. keysUp: number[];
  36425. /**
  36426. * The list of keyboard keys used to control the backward move of the camera.
  36427. */
  36428. keysDown: number[];
  36429. /**
  36430. * The list of keyboard keys used to control the right strafe move of the camera.
  36431. */
  36432. keysRight: number[];
  36433. /**
  36434. * The list of keyboard keys used to control the left strafe move of the camera.
  36435. */
  36436. keysLeft: number[];
  36437. private _keys;
  36438. private _onCanvasBlurObserver;
  36439. private _onKeyboardObserver;
  36440. private _engine;
  36441. private _scene;
  36442. /**
  36443. * Attach the input controls to a specific dom element to get the input from.
  36444. * @param element Defines the element the controls should be listened from
  36445. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36446. */
  36447. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36448. /**
  36449. * Detach the current controls from the specified dom element.
  36450. * @param element Defines the element to stop listening the inputs from
  36451. */
  36452. detachControl(element: Nullable<HTMLElement>): void;
  36453. /**
  36454. * Gets the class name of the current intput.
  36455. * @returns the class name
  36456. */
  36457. getClassName(): string;
  36458. /** @hidden */
  36459. _onLostFocus(e: FocusEvent): void;
  36460. /**
  36461. * Get the friendly name associated with the input class.
  36462. * @returns the input friendly name
  36463. */
  36464. getSimpleName(): string;
  36465. /**
  36466. * Update the current camera state depending on the inputs that have been used this frame.
  36467. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36468. */
  36469. checkInputs(): void;
  36470. }
  36471. }
  36472. declare module BABYLON {
  36473. /**
  36474. * Manage the mouse wheel inputs to control a follow camera.
  36475. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36476. */
  36477. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36478. /**
  36479. * Defines the camera the input is attached to.
  36480. */
  36481. camera: FollowCamera;
  36482. /**
  36483. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36484. */
  36485. axisControlRadius: boolean;
  36486. /**
  36487. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36488. */
  36489. axisControlHeight: boolean;
  36490. /**
  36491. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36492. */
  36493. axisControlRotation: boolean;
  36494. /**
  36495. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36496. * relation to mouseWheel events.
  36497. */
  36498. wheelPrecision: number;
  36499. /**
  36500. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36501. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36502. */
  36503. wheelDeltaPercentage: number;
  36504. private _wheel;
  36505. private _observer;
  36506. /**
  36507. * Attach the input controls to a specific dom element to get the input from.
  36508. * @param element Defines the element the controls should be listened from
  36509. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36510. */
  36511. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36512. /**
  36513. * Detach the current controls from the specified dom element.
  36514. * @param element Defines the element to stop listening the inputs from
  36515. */
  36516. detachControl(element: Nullable<HTMLElement>): void;
  36517. /**
  36518. * Gets the class name of the current intput.
  36519. * @returns the class name
  36520. */
  36521. getClassName(): string;
  36522. /**
  36523. * Get the friendly name associated with the input class.
  36524. * @returns the input friendly name
  36525. */
  36526. getSimpleName(): string;
  36527. }
  36528. }
  36529. declare module BABYLON {
  36530. /**
  36531. * Manage the pointers inputs to control an follow camera.
  36532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36533. */
  36534. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36535. /**
  36536. * Defines the camera the input is attached to.
  36537. */
  36538. camera: FollowCamera;
  36539. /**
  36540. * Gets the class name of the current input.
  36541. * @returns the class name
  36542. */
  36543. getClassName(): string;
  36544. /**
  36545. * Defines the pointer angular sensibility along the X axis or how fast is
  36546. * the camera rotating.
  36547. * A negative number will reverse the axis direction.
  36548. */
  36549. angularSensibilityX: number;
  36550. /**
  36551. * Defines the pointer angular sensibility along the Y axis or how fast is
  36552. * the camera rotating.
  36553. * A negative number will reverse the axis direction.
  36554. */
  36555. angularSensibilityY: number;
  36556. /**
  36557. * Defines the pointer pinch precision or how fast is the camera zooming.
  36558. * A negative number will reverse the axis direction.
  36559. */
  36560. pinchPrecision: number;
  36561. /**
  36562. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36563. * from 0.
  36564. * It defines the percentage of current camera.radius to use as delta when
  36565. * pinch zoom is used.
  36566. */
  36567. pinchDeltaPercentage: number;
  36568. /**
  36569. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36570. */
  36571. axisXControlRadius: boolean;
  36572. /**
  36573. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36574. */
  36575. axisXControlHeight: boolean;
  36576. /**
  36577. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36578. */
  36579. axisXControlRotation: boolean;
  36580. /**
  36581. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36582. */
  36583. axisYControlRadius: boolean;
  36584. /**
  36585. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36586. */
  36587. axisYControlHeight: boolean;
  36588. /**
  36589. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36590. */
  36591. axisYControlRotation: boolean;
  36592. /**
  36593. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36594. */
  36595. axisPinchControlRadius: boolean;
  36596. /**
  36597. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36598. */
  36599. axisPinchControlHeight: boolean;
  36600. /**
  36601. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36602. */
  36603. axisPinchControlRotation: boolean;
  36604. /**
  36605. * Log error messages if basic misconfiguration has occurred.
  36606. */
  36607. warningEnable: boolean;
  36608. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36609. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36610. private _warningCounter;
  36611. private _warning;
  36612. }
  36613. }
  36614. declare module BABYLON {
  36615. /**
  36616. * Default Inputs manager for the FollowCamera.
  36617. * It groups all the default supported inputs for ease of use.
  36618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36619. */
  36620. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36621. /**
  36622. * Instantiates a new FollowCameraInputsManager.
  36623. * @param camera Defines the camera the inputs belong to
  36624. */
  36625. constructor(camera: FollowCamera);
  36626. /**
  36627. * Add keyboard input support to the input manager.
  36628. * @returns the current input manager
  36629. */
  36630. addKeyboard(): FollowCameraInputsManager;
  36631. /**
  36632. * Add mouse wheel input support to the input manager.
  36633. * @returns the current input manager
  36634. */
  36635. addMouseWheel(): FollowCameraInputsManager;
  36636. /**
  36637. * Add pointers input support to the input manager.
  36638. * @returns the current input manager
  36639. */
  36640. addPointers(): FollowCameraInputsManager;
  36641. /**
  36642. * Add orientation input support to the input manager.
  36643. * @returns the current input manager
  36644. */
  36645. addVRDeviceOrientation(): FollowCameraInputsManager;
  36646. }
  36647. }
  36648. declare module BABYLON {
  36649. /**
  36650. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36651. * an arc rotate version arcFollowCamera are available.
  36652. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36653. */
  36654. export class FollowCamera extends TargetCamera {
  36655. /**
  36656. * Distance the follow camera should follow an object at
  36657. */
  36658. radius: number;
  36659. /**
  36660. * Minimum allowed distance of the camera to the axis of rotation
  36661. * (The camera can not get closer).
  36662. * This can help limiting how the Camera is able to move in the scene.
  36663. */
  36664. lowerRadiusLimit: Nullable<number>;
  36665. /**
  36666. * Maximum allowed distance of the camera to the axis of rotation
  36667. * (The camera can not get further).
  36668. * This can help limiting how the Camera is able to move in the scene.
  36669. */
  36670. upperRadiusLimit: Nullable<number>;
  36671. /**
  36672. * Define a rotation offset between the camera and the object it follows
  36673. */
  36674. rotationOffset: number;
  36675. /**
  36676. * Minimum allowed angle to camera position relative to target object.
  36677. * This can help limiting how the Camera is able to move in the scene.
  36678. */
  36679. lowerRotationOffsetLimit: Nullable<number>;
  36680. /**
  36681. * Maximum allowed angle to camera position relative to target object.
  36682. * This can help limiting how the Camera is able to move in the scene.
  36683. */
  36684. upperRotationOffsetLimit: Nullable<number>;
  36685. /**
  36686. * Define a height offset between the camera and the object it follows.
  36687. * It can help following an object from the top (like a car chaing a plane)
  36688. */
  36689. heightOffset: number;
  36690. /**
  36691. * Minimum allowed height of camera position relative to target object.
  36692. * This can help limiting how the Camera is able to move in the scene.
  36693. */
  36694. lowerHeightOffsetLimit: Nullable<number>;
  36695. /**
  36696. * Maximum allowed height of camera position relative to target object.
  36697. * This can help limiting how the Camera is able to move in the scene.
  36698. */
  36699. upperHeightOffsetLimit: Nullable<number>;
  36700. /**
  36701. * Define how fast the camera can accelerate to follow it s target.
  36702. */
  36703. cameraAcceleration: number;
  36704. /**
  36705. * Define the speed limit of the camera following an object.
  36706. */
  36707. maxCameraSpeed: number;
  36708. /**
  36709. * Define the target of the camera.
  36710. */
  36711. lockedTarget: Nullable<AbstractMesh>;
  36712. /**
  36713. * Defines the input associated with the camera.
  36714. */
  36715. inputs: FollowCameraInputsManager;
  36716. /**
  36717. * Instantiates the follow camera.
  36718. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36719. * @param name Define the name of the camera in the scene
  36720. * @param position Define the position of the camera
  36721. * @param scene Define the scene the camera belong to
  36722. * @param lockedTarget Define the target of the camera
  36723. */
  36724. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36725. private _follow;
  36726. /**
  36727. * Attached controls to the current camera.
  36728. * @param element Defines the element the controls should be listened from
  36729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36730. */
  36731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36732. /**
  36733. * Detach the current controls from the camera.
  36734. * The camera will stop reacting to inputs.
  36735. * @param element Defines the element to stop listening the inputs from
  36736. */
  36737. detachControl(element: HTMLElement): void;
  36738. /** @hidden */
  36739. _checkInputs(): void;
  36740. private _checkLimits;
  36741. /**
  36742. * Gets the camera class name.
  36743. * @returns the class name
  36744. */
  36745. getClassName(): string;
  36746. }
  36747. /**
  36748. * Arc Rotate version of the follow camera.
  36749. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36750. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36751. */
  36752. export class ArcFollowCamera extends TargetCamera {
  36753. /** The longitudinal angle of the camera */
  36754. alpha: number;
  36755. /** The latitudinal angle of the camera */
  36756. beta: number;
  36757. /** The radius of the camera from its target */
  36758. radius: number;
  36759. /** Define the camera target (the messh it should follow) */
  36760. target: Nullable<AbstractMesh>;
  36761. private _cartesianCoordinates;
  36762. /**
  36763. * Instantiates a new ArcFollowCamera
  36764. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36765. * @param name Define the name of the camera
  36766. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36767. * @param beta Define the rotation angle of the camera around the elevation axis
  36768. * @param radius Define the radius of the camera from its target point
  36769. * @param target Define the target of the camera
  36770. * @param scene Define the scene the camera belongs to
  36771. */
  36772. constructor(name: string,
  36773. /** The longitudinal angle of the camera */
  36774. alpha: number,
  36775. /** The latitudinal angle of the camera */
  36776. beta: number,
  36777. /** The radius of the camera from its target */
  36778. radius: number,
  36779. /** Define the camera target (the messh it should follow) */
  36780. target: Nullable<AbstractMesh>, scene: Scene);
  36781. private _follow;
  36782. /** @hidden */
  36783. _checkInputs(): void;
  36784. /**
  36785. * Returns the class name of the object.
  36786. * It is mostly used internally for serialization purposes.
  36787. */
  36788. getClassName(): string;
  36789. }
  36790. }
  36791. declare module BABYLON {
  36792. /**
  36793. * Manage the keyboard inputs to control the movement of a follow camera.
  36794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36795. */
  36796. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36797. /**
  36798. * Defines the camera the input is attached to.
  36799. */
  36800. camera: FollowCamera;
  36801. /**
  36802. * Defines the list of key codes associated with the up action (increase heightOffset)
  36803. */
  36804. keysHeightOffsetIncr: number[];
  36805. /**
  36806. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36807. */
  36808. keysHeightOffsetDecr: number[];
  36809. /**
  36810. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36811. */
  36812. keysHeightOffsetModifierAlt: boolean;
  36813. /**
  36814. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36815. */
  36816. keysHeightOffsetModifierCtrl: boolean;
  36817. /**
  36818. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36819. */
  36820. keysHeightOffsetModifierShift: boolean;
  36821. /**
  36822. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36823. */
  36824. keysRotationOffsetIncr: number[];
  36825. /**
  36826. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36827. */
  36828. keysRotationOffsetDecr: number[];
  36829. /**
  36830. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36831. */
  36832. keysRotationOffsetModifierAlt: boolean;
  36833. /**
  36834. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36835. */
  36836. keysRotationOffsetModifierCtrl: boolean;
  36837. /**
  36838. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36839. */
  36840. keysRotationOffsetModifierShift: boolean;
  36841. /**
  36842. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36843. */
  36844. keysRadiusIncr: number[];
  36845. /**
  36846. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36847. */
  36848. keysRadiusDecr: number[];
  36849. /**
  36850. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36851. */
  36852. keysRadiusModifierAlt: boolean;
  36853. /**
  36854. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36855. */
  36856. keysRadiusModifierCtrl: boolean;
  36857. /**
  36858. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36859. */
  36860. keysRadiusModifierShift: boolean;
  36861. /**
  36862. * Defines the rate of change of heightOffset.
  36863. */
  36864. heightSensibility: number;
  36865. /**
  36866. * Defines the rate of change of rotationOffset.
  36867. */
  36868. rotationSensibility: number;
  36869. /**
  36870. * Defines the rate of change of radius.
  36871. */
  36872. radiusSensibility: number;
  36873. private _keys;
  36874. private _ctrlPressed;
  36875. private _altPressed;
  36876. private _shiftPressed;
  36877. private _onCanvasBlurObserver;
  36878. private _onKeyboardObserver;
  36879. private _engine;
  36880. private _scene;
  36881. /**
  36882. * Attach the input controls to a specific dom element to get the input from.
  36883. * @param element Defines the element the controls should be listened from
  36884. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36885. */
  36886. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36887. /**
  36888. * Detach the current controls from the specified dom element.
  36889. * @param element Defines the element to stop listening the inputs from
  36890. */
  36891. detachControl(element: Nullable<HTMLElement>): void;
  36892. /**
  36893. * Update the current camera state depending on the inputs that have been used this frame.
  36894. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36895. */
  36896. checkInputs(): void;
  36897. /**
  36898. * Gets the class name of the current input.
  36899. * @returns the class name
  36900. */
  36901. getClassName(): string;
  36902. /**
  36903. * Get the friendly name associated with the input class.
  36904. * @returns the input friendly name
  36905. */
  36906. getSimpleName(): string;
  36907. /**
  36908. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36909. * allow modification of the heightOffset value.
  36910. */
  36911. private _modifierHeightOffset;
  36912. /**
  36913. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36914. * allow modification of the rotationOffset value.
  36915. */
  36916. private _modifierRotationOffset;
  36917. /**
  36918. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36919. * allow modification of the radius value.
  36920. */
  36921. private _modifierRadius;
  36922. }
  36923. }
  36924. declare module BABYLON {
  36925. interface FreeCameraInputsManager {
  36926. /**
  36927. * @hidden
  36928. */
  36929. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36930. /**
  36931. * Add orientation input support to the input manager.
  36932. * @returns the current input manager
  36933. */
  36934. addDeviceOrientation(): FreeCameraInputsManager;
  36935. }
  36936. /**
  36937. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36938. * Screen rotation is taken into account.
  36939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36940. */
  36941. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36942. private _camera;
  36943. private _screenOrientationAngle;
  36944. private _constantTranform;
  36945. private _screenQuaternion;
  36946. private _alpha;
  36947. private _beta;
  36948. private _gamma;
  36949. /**
  36950. * @hidden
  36951. */
  36952. _onDeviceOrientationChangedObservable: Observable<void>;
  36953. /**
  36954. * Instantiates a new input
  36955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36956. */
  36957. constructor();
  36958. /**
  36959. * Define the camera controlled by the input.
  36960. */
  36961. camera: FreeCamera;
  36962. /**
  36963. * Attach the input controls to a specific dom element to get the input from.
  36964. * @param element Defines the element the controls should be listened from
  36965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36966. */
  36967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36968. private _orientationChanged;
  36969. private _deviceOrientation;
  36970. /**
  36971. * Detach the current controls from the specified dom element.
  36972. * @param element Defines the element to stop listening the inputs from
  36973. */
  36974. detachControl(element: Nullable<HTMLElement>): void;
  36975. /**
  36976. * Update the current camera state depending on the inputs that have been used this frame.
  36977. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36978. */
  36979. checkInputs(): void;
  36980. /**
  36981. * Gets the class name of the current intput.
  36982. * @returns the class name
  36983. */
  36984. getClassName(): string;
  36985. /**
  36986. * Get the friendly name associated with the input class.
  36987. * @returns the input friendly name
  36988. */
  36989. getSimpleName(): string;
  36990. }
  36991. }
  36992. declare module BABYLON {
  36993. /**
  36994. * Manage the gamepad inputs to control a free camera.
  36995. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36996. */
  36997. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36998. /**
  36999. * Define the camera the input is attached to.
  37000. */
  37001. camera: FreeCamera;
  37002. /**
  37003. * Define the Gamepad controlling the input
  37004. */
  37005. gamepad: Nullable<Gamepad>;
  37006. /**
  37007. * Defines the gamepad rotation sensiblity.
  37008. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37009. */
  37010. gamepadAngularSensibility: number;
  37011. /**
  37012. * Defines the gamepad move sensiblity.
  37013. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37014. */
  37015. gamepadMoveSensibility: number;
  37016. private _onGamepadConnectedObserver;
  37017. private _onGamepadDisconnectedObserver;
  37018. private _cameraTransform;
  37019. private _deltaTransform;
  37020. private _vector3;
  37021. private _vector2;
  37022. /**
  37023. * Attach the input controls to a specific dom element to get the input from.
  37024. * @param element Defines the element the controls should be listened from
  37025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37026. */
  37027. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37028. /**
  37029. * Detach the current controls from the specified dom element.
  37030. * @param element Defines the element to stop listening the inputs from
  37031. */
  37032. detachControl(element: Nullable<HTMLElement>): void;
  37033. /**
  37034. * Update the current camera state depending on the inputs that have been used this frame.
  37035. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37036. */
  37037. checkInputs(): void;
  37038. /**
  37039. * Gets the class name of the current intput.
  37040. * @returns the class name
  37041. */
  37042. getClassName(): string;
  37043. /**
  37044. * Get the friendly name associated with the input class.
  37045. * @returns the input friendly name
  37046. */
  37047. getSimpleName(): string;
  37048. }
  37049. }
  37050. declare module BABYLON {
  37051. /**
  37052. * Defines the potential axis of a Joystick
  37053. */
  37054. export enum JoystickAxis {
  37055. /** X axis */
  37056. X = 0,
  37057. /** Y axis */
  37058. Y = 1,
  37059. /** Z axis */
  37060. Z = 2
  37061. }
  37062. /**
  37063. * Class used to define virtual joystick (used in touch mode)
  37064. */
  37065. export class VirtualJoystick {
  37066. /**
  37067. * Gets or sets a boolean indicating that left and right values must be inverted
  37068. */
  37069. reverseLeftRight: boolean;
  37070. /**
  37071. * Gets or sets a boolean indicating that up and down values must be inverted
  37072. */
  37073. reverseUpDown: boolean;
  37074. /**
  37075. * Gets the offset value for the position (ie. the change of the position value)
  37076. */
  37077. deltaPosition: Vector3;
  37078. /**
  37079. * Gets a boolean indicating if the virtual joystick was pressed
  37080. */
  37081. pressed: boolean;
  37082. /**
  37083. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37084. */
  37085. static Canvas: Nullable<HTMLCanvasElement>;
  37086. private static _globalJoystickIndex;
  37087. private static vjCanvasContext;
  37088. private static vjCanvasWidth;
  37089. private static vjCanvasHeight;
  37090. private static halfWidth;
  37091. private _action;
  37092. private _axisTargetedByLeftAndRight;
  37093. private _axisTargetedByUpAndDown;
  37094. private _joystickSensibility;
  37095. private _inversedSensibility;
  37096. private _joystickPointerID;
  37097. private _joystickColor;
  37098. private _joystickPointerPos;
  37099. private _joystickPreviousPointerPos;
  37100. private _joystickPointerStartPos;
  37101. private _deltaJoystickVector;
  37102. private _leftJoystick;
  37103. private _touches;
  37104. private _onPointerDownHandlerRef;
  37105. private _onPointerMoveHandlerRef;
  37106. private _onPointerUpHandlerRef;
  37107. private _onResize;
  37108. /**
  37109. * Creates a new virtual joystick
  37110. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37111. */
  37112. constructor(leftJoystick?: boolean);
  37113. /**
  37114. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37115. * @param newJoystickSensibility defines the new sensibility
  37116. */
  37117. setJoystickSensibility(newJoystickSensibility: number): void;
  37118. private _onPointerDown;
  37119. private _onPointerMove;
  37120. private _onPointerUp;
  37121. /**
  37122. * Change the color of the virtual joystick
  37123. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37124. */
  37125. setJoystickColor(newColor: string): void;
  37126. /**
  37127. * Defines a callback to call when the joystick is touched
  37128. * @param action defines the callback
  37129. */
  37130. setActionOnTouch(action: () => any): void;
  37131. /**
  37132. * Defines which axis you'd like to control for left & right
  37133. * @param axis defines the axis to use
  37134. */
  37135. setAxisForLeftRight(axis: JoystickAxis): void;
  37136. /**
  37137. * Defines which axis you'd like to control for up & down
  37138. * @param axis defines the axis to use
  37139. */
  37140. setAxisForUpDown(axis: JoystickAxis): void;
  37141. private _drawVirtualJoystick;
  37142. /**
  37143. * Release internal HTML canvas
  37144. */
  37145. releaseCanvas(): void;
  37146. }
  37147. }
  37148. declare module BABYLON {
  37149. interface FreeCameraInputsManager {
  37150. /**
  37151. * Add virtual joystick input support to the input manager.
  37152. * @returns the current input manager
  37153. */
  37154. addVirtualJoystick(): FreeCameraInputsManager;
  37155. }
  37156. /**
  37157. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37159. */
  37160. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37161. /**
  37162. * Defines the camera the input is attached to.
  37163. */
  37164. camera: FreeCamera;
  37165. private _leftjoystick;
  37166. private _rightjoystick;
  37167. /**
  37168. * Gets the left stick of the virtual joystick.
  37169. * @returns The virtual Joystick
  37170. */
  37171. getLeftJoystick(): VirtualJoystick;
  37172. /**
  37173. * Gets the right stick of the virtual joystick.
  37174. * @returns The virtual Joystick
  37175. */
  37176. getRightJoystick(): VirtualJoystick;
  37177. /**
  37178. * Update the current camera state depending on the inputs that have been used this frame.
  37179. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37180. */
  37181. checkInputs(): void;
  37182. /**
  37183. * Attach the input controls to a specific dom element to get the input from.
  37184. * @param element Defines the element the controls should be listened from
  37185. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37186. */
  37187. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37188. /**
  37189. * Detach the current controls from the specified dom element.
  37190. * @param element Defines the element to stop listening the inputs from
  37191. */
  37192. detachControl(element: Nullable<HTMLElement>): void;
  37193. /**
  37194. * Gets the class name of the current intput.
  37195. * @returns the class name
  37196. */
  37197. getClassName(): string;
  37198. /**
  37199. * Get the friendly name associated with the input class.
  37200. * @returns the input friendly name
  37201. */
  37202. getSimpleName(): string;
  37203. }
  37204. }
  37205. declare module BABYLON {
  37206. /**
  37207. * This represents a FPS type of camera controlled by touch.
  37208. * This is like a universal camera minus the Gamepad controls.
  37209. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37210. */
  37211. export class TouchCamera extends FreeCamera {
  37212. /**
  37213. * Defines the touch sensibility for rotation.
  37214. * The higher the faster.
  37215. */
  37216. touchAngularSensibility: number;
  37217. /**
  37218. * Defines the touch sensibility for move.
  37219. * The higher the faster.
  37220. */
  37221. touchMoveSensibility: number;
  37222. /**
  37223. * Instantiates a new touch camera.
  37224. * This represents a FPS type of camera controlled by touch.
  37225. * This is like a universal camera minus the Gamepad controls.
  37226. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37227. * @param name Define the name of the camera in the scene
  37228. * @param position Define the start position of the camera in the scene
  37229. * @param scene Define the scene the camera belongs to
  37230. */
  37231. constructor(name: string, position: Vector3, scene: Scene);
  37232. /**
  37233. * Gets the current object class name.
  37234. * @return the class name
  37235. */
  37236. getClassName(): string;
  37237. /** @hidden */
  37238. _setupInputs(): void;
  37239. }
  37240. }
  37241. declare module BABYLON {
  37242. /**
  37243. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37244. * being tilted forward or back and left or right.
  37245. */
  37246. export class DeviceOrientationCamera extends FreeCamera {
  37247. private _initialQuaternion;
  37248. private _quaternionCache;
  37249. private _tmpDragQuaternion;
  37250. /**
  37251. * Creates a new device orientation camera
  37252. * @param name The name of the camera
  37253. * @param position The start position camera
  37254. * @param scene The scene the camera belongs to
  37255. */
  37256. constructor(name: string, position: Vector3, scene: Scene);
  37257. /**
  37258. * @hidden
  37259. * Disabled pointer input on first orientation sensor update (Default: true)
  37260. */
  37261. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37262. private _dragFactor;
  37263. /**
  37264. * Enabled turning on the y axis when the orientation sensor is active
  37265. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37266. */
  37267. enableHorizontalDragging(dragFactor?: number): void;
  37268. /**
  37269. * Gets the current instance class name ("DeviceOrientationCamera").
  37270. * This helps avoiding instanceof at run time.
  37271. * @returns the class name
  37272. */
  37273. getClassName(): string;
  37274. /**
  37275. * @hidden
  37276. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37277. */
  37278. _checkInputs(): void;
  37279. /**
  37280. * Reset the camera to its default orientation on the specified axis only.
  37281. * @param axis The axis to reset
  37282. */
  37283. resetToCurrentRotation(axis?: Axis): void;
  37284. }
  37285. }
  37286. declare module BABYLON {
  37287. /**
  37288. * 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,
  37289. * which still works and will still be found in many Playgrounds.
  37290. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37291. */
  37292. export class UniversalCamera extends TouchCamera {
  37293. /**
  37294. * Defines the gamepad rotation sensiblity.
  37295. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37296. */
  37297. gamepadAngularSensibility: number;
  37298. /**
  37299. * Defines the gamepad move sensiblity.
  37300. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37301. */
  37302. gamepadMoveSensibility: number;
  37303. /**
  37304. * 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,
  37305. * which still works and will still be found in many Playgrounds.
  37306. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37307. * @param name Define the name of the camera in the scene
  37308. * @param position Define the start position of the camera in the scene
  37309. * @param scene Define the scene the camera belongs to
  37310. */
  37311. constructor(name: string, position: Vector3, scene: Scene);
  37312. /**
  37313. * Gets the current object class name.
  37314. * @return the class name
  37315. */
  37316. getClassName(): string;
  37317. }
  37318. }
  37319. declare module BABYLON {
  37320. /**
  37321. * This represents a FPS type of camera. This is only here for back compat purpose.
  37322. * Please use the UniversalCamera instead as both are identical.
  37323. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37324. */
  37325. export class GamepadCamera extends UniversalCamera {
  37326. /**
  37327. * Instantiates a new Gamepad Camera
  37328. * This represents a FPS type of camera. This is only here for back compat purpose.
  37329. * Please use the UniversalCamera instead as both are identical.
  37330. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37331. * @param name Define the name of the camera in the scene
  37332. * @param position Define the start position of the camera in the scene
  37333. * @param scene Define the scene the camera belongs to
  37334. */
  37335. constructor(name: string, position: Vector3, scene: Scene);
  37336. /**
  37337. * Gets the current object class name.
  37338. * @return the class name
  37339. */
  37340. getClassName(): string;
  37341. }
  37342. }
  37343. declare module BABYLON {
  37344. /** @hidden */
  37345. export var passPixelShader: {
  37346. name: string;
  37347. shader: string;
  37348. };
  37349. }
  37350. declare module BABYLON {
  37351. /** @hidden */
  37352. export var passCubePixelShader: {
  37353. name: string;
  37354. shader: string;
  37355. };
  37356. }
  37357. declare module BABYLON {
  37358. /**
  37359. * PassPostProcess which produces an output the same as it's input
  37360. */
  37361. export class PassPostProcess extends PostProcess {
  37362. /**
  37363. * Creates the PassPostProcess
  37364. * @param name The name of the effect.
  37365. * @param options The required width/height ratio to downsize to before computing the render pass.
  37366. * @param camera The camera to apply the render pass to.
  37367. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37368. * @param engine The engine which the post process will be applied. (default: current engine)
  37369. * @param reusable If the post process can be reused on the same frame. (default: false)
  37370. * @param textureType The type of texture to be used when performing the post processing.
  37371. * @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)
  37372. */
  37373. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37374. }
  37375. /**
  37376. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37377. */
  37378. export class PassCubePostProcess extends PostProcess {
  37379. private _face;
  37380. /**
  37381. * Gets or sets the cube face to display.
  37382. * * 0 is +X
  37383. * * 1 is -X
  37384. * * 2 is +Y
  37385. * * 3 is -Y
  37386. * * 4 is +Z
  37387. * * 5 is -Z
  37388. */
  37389. face: number;
  37390. /**
  37391. * Creates the PassCubePostProcess
  37392. * @param name The name of the effect.
  37393. * @param options The required width/height ratio to downsize to before computing the render pass.
  37394. * @param camera The camera to apply the render pass to.
  37395. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37396. * @param engine The engine which the post process will be applied. (default: current engine)
  37397. * @param reusable If the post process can be reused on the same frame. (default: false)
  37398. * @param textureType The type of texture to be used when performing the post processing.
  37399. * @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)
  37400. */
  37401. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37402. }
  37403. }
  37404. declare module BABYLON {
  37405. /** @hidden */
  37406. export var anaglyphPixelShader: {
  37407. name: string;
  37408. shader: string;
  37409. };
  37410. }
  37411. declare module BABYLON {
  37412. /**
  37413. * Postprocess used to generate anaglyphic rendering
  37414. */
  37415. export class AnaglyphPostProcess extends PostProcess {
  37416. private _passedProcess;
  37417. /**
  37418. * Creates a new AnaglyphPostProcess
  37419. * @param name defines postprocess name
  37420. * @param options defines creation options or target ratio scale
  37421. * @param rigCameras defines cameras using this postprocess
  37422. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37423. * @param engine defines hosting engine
  37424. * @param reusable defines if the postprocess will be reused multiple times per frame
  37425. */
  37426. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37427. }
  37428. }
  37429. declare module BABYLON {
  37430. /**
  37431. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37432. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37433. */
  37434. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37435. /**
  37436. * Creates a new AnaglyphArcRotateCamera
  37437. * @param name defines camera name
  37438. * @param alpha defines alpha angle (in radians)
  37439. * @param beta defines beta angle (in radians)
  37440. * @param radius defines radius
  37441. * @param target defines camera target
  37442. * @param interaxialDistance defines distance between each color axis
  37443. * @param scene defines the hosting scene
  37444. */
  37445. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37446. /**
  37447. * Gets camera class name
  37448. * @returns AnaglyphArcRotateCamera
  37449. */
  37450. getClassName(): string;
  37451. }
  37452. }
  37453. declare module BABYLON {
  37454. /**
  37455. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37456. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37457. */
  37458. export class AnaglyphFreeCamera extends FreeCamera {
  37459. /**
  37460. * Creates a new AnaglyphFreeCamera
  37461. * @param name defines camera name
  37462. * @param position defines initial position
  37463. * @param interaxialDistance defines distance between each color axis
  37464. * @param scene defines the hosting scene
  37465. */
  37466. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37467. /**
  37468. * Gets camera class name
  37469. * @returns AnaglyphFreeCamera
  37470. */
  37471. getClassName(): string;
  37472. }
  37473. }
  37474. declare module BABYLON {
  37475. /**
  37476. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37477. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37478. */
  37479. export class AnaglyphGamepadCamera extends GamepadCamera {
  37480. /**
  37481. * Creates a new AnaglyphGamepadCamera
  37482. * @param name defines camera name
  37483. * @param position defines initial position
  37484. * @param interaxialDistance defines distance between each color axis
  37485. * @param scene defines the hosting scene
  37486. */
  37487. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37488. /**
  37489. * Gets camera class name
  37490. * @returns AnaglyphGamepadCamera
  37491. */
  37492. getClassName(): string;
  37493. }
  37494. }
  37495. declare module BABYLON {
  37496. /**
  37497. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37498. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37499. */
  37500. export class AnaglyphUniversalCamera extends UniversalCamera {
  37501. /**
  37502. * Creates a new AnaglyphUniversalCamera
  37503. * @param name defines camera name
  37504. * @param position defines initial position
  37505. * @param interaxialDistance defines distance between each color axis
  37506. * @param scene defines the hosting scene
  37507. */
  37508. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37509. /**
  37510. * Gets camera class name
  37511. * @returns AnaglyphUniversalCamera
  37512. */
  37513. getClassName(): string;
  37514. }
  37515. }
  37516. declare module BABYLON {
  37517. /** @hidden */
  37518. export var stereoscopicInterlacePixelShader: {
  37519. name: string;
  37520. shader: string;
  37521. };
  37522. }
  37523. declare module BABYLON {
  37524. /**
  37525. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37526. */
  37527. export class StereoscopicInterlacePostProcess extends PostProcess {
  37528. private _stepSize;
  37529. private _passedProcess;
  37530. /**
  37531. * Initializes a StereoscopicInterlacePostProcess
  37532. * @param name The name of the effect.
  37533. * @param rigCameras The rig cameras to be appled to the post process
  37534. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37535. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37536. * @param engine The engine which the post process will be applied. (default: current engine)
  37537. * @param reusable If the post process can be reused on the same frame. (default: false)
  37538. */
  37539. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37540. }
  37541. }
  37542. declare module BABYLON {
  37543. /**
  37544. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37545. * @see http://doc.babylonjs.com/features/cameras
  37546. */
  37547. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37548. /**
  37549. * Creates a new StereoscopicArcRotateCamera
  37550. * @param name defines camera name
  37551. * @param alpha defines alpha angle (in radians)
  37552. * @param beta defines beta angle (in radians)
  37553. * @param radius defines radius
  37554. * @param target defines camera target
  37555. * @param interaxialDistance defines distance between each color axis
  37556. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37557. * @param scene defines the hosting scene
  37558. */
  37559. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37560. /**
  37561. * Gets camera class name
  37562. * @returns StereoscopicArcRotateCamera
  37563. */
  37564. getClassName(): string;
  37565. }
  37566. }
  37567. declare module BABYLON {
  37568. /**
  37569. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37570. * @see http://doc.babylonjs.com/features/cameras
  37571. */
  37572. export class StereoscopicFreeCamera extends FreeCamera {
  37573. /**
  37574. * Creates a new StereoscopicFreeCamera
  37575. * @param name defines camera name
  37576. * @param position defines initial position
  37577. * @param interaxialDistance defines distance between each color axis
  37578. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37579. * @param scene defines the hosting scene
  37580. */
  37581. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37582. /**
  37583. * Gets camera class name
  37584. * @returns StereoscopicFreeCamera
  37585. */
  37586. getClassName(): string;
  37587. }
  37588. }
  37589. declare module BABYLON {
  37590. /**
  37591. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37592. * @see http://doc.babylonjs.com/features/cameras
  37593. */
  37594. export class StereoscopicGamepadCamera extends GamepadCamera {
  37595. /**
  37596. * Creates a new StereoscopicGamepadCamera
  37597. * @param name defines camera name
  37598. * @param position defines initial position
  37599. * @param interaxialDistance defines distance between each color axis
  37600. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37601. * @param scene defines the hosting scene
  37602. */
  37603. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37604. /**
  37605. * Gets camera class name
  37606. * @returns StereoscopicGamepadCamera
  37607. */
  37608. getClassName(): string;
  37609. }
  37610. }
  37611. declare module BABYLON {
  37612. /**
  37613. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37614. * @see http://doc.babylonjs.com/features/cameras
  37615. */
  37616. export class StereoscopicUniversalCamera extends UniversalCamera {
  37617. /**
  37618. * Creates a new StereoscopicUniversalCamera
  37619. * @param name defines camera name
  37620. * @param position defines initial position
  37621. * @param interaxialDistance defines distance between each color axis
  37622. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37623. * @param scene defines the hosting scene
  37624. */
  37625. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37626. /**
  37627. * Gets camera class name
  37628. * @returns StereoscopicUniversalCamera
  37629. */
  37630. getClassName(): string;
  37631. }
  37632. }
  37633. declare module BABYLON {
  37634. /**
  37635. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37636. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37637. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37638. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37639. */
  37640. export class VirtualJoysticksCamera extends FreeCamera {
  37641. /**
  37642. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37643. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37644. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37645. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37646. * @param name Define the name of the camera in the scene
  37647. * @param position Define the start position of the camera in the scene
  37648. * @param scene Define the scene the camera belongs to
  37649. */
  37650. constructor(name: string, position: Vector3, scene: Scene);
  37651. /**
  37652. * Gets the current object class name.
  37653. * @return the class name
  37654. */
  37655. getClassName(): string;
  37656. }
  37657. }
  37658. declare module BABYLON {
  37659. /**
  37660. * This represents all the required metrics to create a VR camera.
  37661. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37662. */
  37663. export class VRCameraMetrics {
  37664. /**
  37665. * Define the horizontal resolution off the screen.
  37666. */
  37667. hResolution: number;
  37668. /**
  37669. * Define the vertical resolution off the screen.
  37670. */
  37671. vResolution: number;
  37672. /**
  37673. * Define the horizontal screen size.
  37674. */
  37675. hScreenSize: number;
  37676. /**
  37677. * Define the vertical screen size.
  37678. */
  37679. vScreenSize: number;
  37680. /**
  37681. * Define the vertical screen center position.
  37682. */
  37683. vScreenCenter: number;
  37684. /**
  37685. * Define the distance of the eyes to the screen.
  37686. */
  37687. eyeToScreenDistance: number;
  37688. /**
  37689. * Define the distance between both lenses
  37690. */
  37691. lensSeparationDistance: number;
  37692. /**
  37693. * Define the distance between both viewer's eyes.
  37694. */
  37695. interpupillaryDistance: number;
  37696. /**
  37697. * Define the distortion factor of the VR postprocess.
  37698. * Please, touch with care.
  37699. */
  37700. distortionK: number[];
  37701. /**
  37702. * Define the chromatic aberration correction factors for the VR post process.
  37703. */
  37704. chromaAbCorrection: number[];
  37705. /**
  37706. * Define the scale factor of the post process.
  37707. * The smaller the better but the slower.
  37708. */
  37709. postProcessScaleFactor: number;
  37710. /**
  37711. * Define an offset for the lens center.
  37712. */
  37713. lensCenterOffset: number;
  37714. /**
  37715. * Define if the current vr camera should compensate the distortion of the lense or not.
  37716. */
  37717. compensateDistortion: boolean;
  37718. /**
  37719. * Defines if multiview should be enabled when rendering (Default: false)
  37720. */
  37721. multiviewEnabled: boolean;
  37722. /**
  37723. * Gets the rendering aspect ratio based on the provided resolutions.
  37724. */
  37725. readonly aspectRatio: number;
  37726. /**
  37727. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37728. */
  37729. readonly aspectRatioFov: number;
  37730. /**
  37731. * @hidden
  37732. */
  37733. readonly leftHMatrix: Matrix;
  37734. /**
  37735. * @hidden
  37736. */
  37737. readonly rightHMatrix: Matrix;
  37738. /**
  37739. * @hidden
  37740. */
  37741. readonly leftPreViewMatrix: Matrix;
  37742. /**
  37743. * @hidden
  37744. */
  37745. readonly rightPreViewMatrix: Matrix;
  37746. /**
  37747. * Get the default VRMetrics based on the most generic setup.
  37748. * @returns the default vr metrics
  37749. */
  37750. static GetDefault(): VRCameraMetrics;
  37751. }
  37752. }
  37753. declare module BABYLON {
  37754. /** @hidden */
  37755. export var vrDistortionCorrectionPixelShader: {
  37756. name: string;
  37757. shader: string;
  37758. };
  37759. }
  37760. declare module BABYLON {
  37761. /**
  37762. * VRDistortionCorrectionPostProcess used for mobile VR
  37763. */
  37764. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37765. private _isRightEye;
  37766. private _distortionFactors;
  37767. private _postProcessScaleFactor;
  37768. private _lensCenterOffset;
  37769. private _scaleIn;
  37770. private _scaleFactor;
  37771. private _lensCenter;
  37772. /**
  37773. * Initializes the VRDistortionCorrectionPostProcess
  37774. * @param name The name of the effect.
  37775. * @param camera The camera to apply the render pass to.
  37776. * @param isRightEye If this is for the right eye distortion
  37777. * @param vrMetrics All the required metrics for the VR camera
  37778. */
  37779. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37780. }
  37781. }
  37782. declare module BABYLON {
  37783. /**
  37784. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37785. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37786. */
  37787. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37788. /**
  37789. * Creates a new VRDeviceOrientationArcRotateCamera
  37790. * @param name defines camera name
  37791. * @param alpha defines the camera rotation along the logitudinal axis
  37792. * @param beta defines the camera rotation along the latitudinal axis
  37793. * @param radius defines the camera distance from its target
  37794. * @param target defines the camera target
  37795. * @param scene defines the scene the camera belongs to
  37796. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37797. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37798. */
  37799. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37800. /**
  37801. * Gets camera class name
  37802. * @returns VRDeviceOrientationArcRotateCamera
  37803. */
  37804. getClassName(): string;
  37805. }
  37806. }
  37807. declare module BABYLON {
  37808. /**
  37809. * Camera used to simulate VR rendering (based on FreeCamera)
  37810. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37811. */
  37812. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37813. /**
  37814. * Creates a new VRDeviceOrientationFreeCamera
  37815. * @param name defines camera name
  37816. * @param position defines the start position of the camera
  37817. * @param scene defines the scene the camera belongs to
  37818. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37819. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37820. */
  37821. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37822. /**
  37823. * Gets camera class name
  37824. * @returns VRDeviceOrientationFreeCamera
  37825. */
  37826. getClassName(): string;
  37827. }
  37828. }
  37829. declare module BABYLON {
  37830. /**
  37831. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37832. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37833. */
  37834. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37835. /**
  37836. * Creates a new VRDeviceOrientationGamepadCamera
  37837. * @param name defines camera name
  37838. * @param position defines the start position of the camera
  37839. * @param scene defines the scene the camera belongs to
  37840. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37841. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37842. */
  37843. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37844. /**
  37845. * Gets camera class name
  37846. * @returns VRDeviceOrientationGamepadCamera
  37847. */
  37848. getClassName(): string;
  37849. }
  37850. }
  37851. declare module BABYLON {
  37852. /**
  37853. * Defines supported buttons for XBox360 compatible gamepads
  37854. */
  37855. export enum Xbox360Button {
  37856. /** A */
  37857. A = 0,
  37858. /** B */
  37859. B = 1,
  37860. /** X */
  37861. X = 2,
  37862. /** Y */
  37863. Y = 3,
  37864. /** Start */
  37865. Start = 4,
  37866. /** Back */
  37867. Back = 5,
  37868. /** Left button */
  37869. LB = 6,
  37870. /** Right button */
  37871. RB = 7,
  37872. /** Left stick */
  37873. LeftStick = 8,
  37874. /** Right stick */
  37875. RightStick = 9
  37876. }
  37877. /** Defines values for XBox360 DPad */
  37878. export enum Xbox360Dpad {
  37879. /** Up */
  37880. Up = 0,
  37881. /** Down */
  37882. Down = 1,
  37883. /** Left */
  37884. Left = 2,
  37885. /** Right */
  37886. Right = 3
  37887. }
  37888. /**
  37889. * Defines a XBox360 gamepad
  37890. */
  37891. export class Xbox360Pad extends Gamepad {
  37892. private _leftTrigger;
  37893. private _rightTrigger;
  37894. private _onlefttriggerchanged;
  37895. private _onrighttriggerchanged;
  37896. private _onbuttondown;
  37897. private _onbuttonup;
  37898. private _ondpaddown;
  37899. private _ondpadup;
  37900. /** Observable raised when a button is pressed */
  37901. onButtonDownObservable: Observable<Xbox360Button>;
  37902. /** Observable raised when a button is released */
  37903. onButtonUpObservable: Observable<Xbox360Button>;
  37904. /** Observable raised when a pad is pressed */
  37905. onPadDownObservable: Observable<Xbox360Dpad>;
  37906. /** Observable raised when a pad is released */
  37907. onPadUpObservable: Observable<Xbox360Dpad>;
  37908. private _buttonA;
  37909. private _buttonB;
  37910. private _buttonX;
  37911. private _buttonY;
  37912. private _buttonBack;
  37913. private _buttonStart;
  37914. private _buttonLB;
  37915. private _buttonRB;
  37916. private _buttonLeftStick;
  37917. private _buttonRightStick;
  37918. private _dPadUp;
  37919. private _dPadDown;
  37920. private _dPadLeft;
  37921. private _dPadRight;
  37922. private _isXboxOnePad;
  37923. /**
  37924. * Creates a new XBox360 gamepad object
  37925. * @param id defines the id of this gamepad
  37926. * @param index defines its index
  37927. * @param gamepad defines the internal HTML gamepad object
  37928. * @param xboxOne defines if it is a XBox One gamepad
  37929. */
  37930. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37931. /**
  37932. * Defines the callback to call when left trigger is pressed
  37933. * @param callback defines the callback to use
  37934. */
  37935. onlefttriggerchanged(callback: (value: number) => void): void;
  37936. /**
  37937. * Defines the callback to call when right trigger is pressed
  37938. * @param callback defines the callback to use
  37939. */
  37940. onrighttriggerchanged(callback: (value: number) => void): void;
  37941. /**
  37942. * Gets the left trigger value
  37943. */
  37944. /**
  37945. * Sets the left trigger value
  37946. */
  37947. leftTrigger: number;
  37948. /**
  37949. * Gets the right trigger value
  37950. */
  37951. /**
  37952. * Sets the right trigger value
  37953. */
  37954. rightTrigger: number;
  37955. /**
  37956. * Defines the callback to call when a button is pressed
  37957. * @param callback defines the callback to use
  37958. */
  37959. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37960. /**
  37961. * Defines the callback to call when a button is released
  37962. * @param callback defines the callback to use
  37963. */
  37964. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37965. /**
  37966. * Defines the callback to call when a pad is pressed
  37967. * @param callback defines the callback to use
  37968. */
  37969. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37970. /**
  37971. * Defines the callback to call when a pad is released
  37972. * @param callback defines the callback to use
  37973. */
  37974. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37975. private _setButtonValue;
  37976. private _setDPadValue;
  37977. /**
  37978. * Gets the value of the `A` button
  37979. */
  37980. /**
  37981. * Sets the value of the `A` button
  37982. */
  37983. buttonA: number;
  37984. /**
  37985. * Gets the value of the `B` button
  37986. */
  37987. /**
  37988. * Sets the value of the `B` button
  37989. */
  37990. buttonB: number;
  37991. /**
  37992. * Gets the value of the `X` button
  37993. */
  37994. /**
  37995. * Sets the value of the `X` button
  37996. */
  37997. buttonX: number;
  37998. /**
  37999. * Gets the value of the `Y` button
  38000. */
  38001. /**
  38002. * Sets the value of the `Y` button
  38003. */
  38004. buttonY: number;
  38005. /**
  38006. * Gets the value of the `Start` button
  38007. */
  38008. /**
  38009. * Sets the value of the `Start` button
  38010. */
  38011. buttonStart: number;
  38012. /**
  38013. * Gets the value of the `Back` button
  38014. */
  38015. /**
  38016. * Sets the value of the `Back` button
  38017. */
  38018. buttonBack: number;
  38019. /**
  38020. * Gets the value of the `Left` button
  38021. */
  38022. /**
  38023. * Sets the value of the `Left` button
  38024. */
  38025. buttonLB: number;
  38026. /**
  38027. * Gets the value of the `Right` button
  38028. */
  38029. /**
  38030. * Sets the value of the `Right` button
  38031. */
  38032. buttonRB: number;
  38033. /**
  38034. * Gets the value of the Left joystick
  38035. */
  38036. /**
  38037. * Sets the value of the Left joystick
  38038. */
  38039. buttonLeftStick: number;
  38040. /**
  38041. * Gets the value of the Right joystick
  38042. */
  38043. /**
  38044. * Sets the value of the Right joystick
  38045. */
  38046. buttonRightStick: number;
  38047. /**
  38048. * Gets the value of D-pad up
  38049. */
  38050. /**
  38051. * Sets the value of D-pad up
  38052. */
  38053. dPadUp: number;
  38054. /**
  38055. * Gets the value of D-pad down
  38056. */
  38057. /**
  38058. * Sets the value of D-pad down
  38059. */
  38060. dPadDown: number;
  38061. /**
  38062. * Gets the value of D-pad left
  38063. */
  38064. /**
  38065. * Sets the value of D-pad left
  38066. */
  38067. dPadLeft: number;
  38068. /**
  38069. * Gets the value of D-pad right
  38070. */
  38071. /**
  38072. * Sets the value of D-pad right
  38073. */
  38074. dPadRight: number;
  38075. /**
  38076. * Force the gamepad to synchronize with device values
  38077. */
  38078. update(): void;
  38079. /**
  38080. * Disposes the gamepad
  38081. */
  38082. dispose(): void;
  38083. }
  38084. }
  38085. declare module BABYLON {
  38086. /**
  38087. * Base class of materials working in push mode in babylon JS
  38088. * @hidden
  38089. */
  38090. export class PushMaterial extends Material {
  38091. protected _activeEffect: Effect;
  38092. protected _normalMatrix: Matrix;
  38093. /**
  38094. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38095. * This means that the material can keep using a previous shader while a new one is being compiled.
  38096. * This is mostly used when shader parallel compilation is supported (true by default)
  38097. */
  38098. allowShaderHotSwapping: boolean;
  38099. constructor(name: string, scene: Scene);
  38100. getEffect(): Effect;
  38101. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38102. /**
  38103. * Binds the given world matrix to the active effect
  38104. *
  38105. * @param world the matrix to bind
  38106. */
  38107. bindOnlyWorldMatrix(world: Matrix): void;
  38108. /**
  38109. * Binds the given normal matrix to the active effect
  38110. *
  38111. * @param normalMatrix the matrix to bind
  38112. */
  38113. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38114. bind(world: Matrix, mesh?: Mesh): void;
  38115. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38116. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38117. }
  38118. }
  38119. declare module BABYLON {
  38120. /**
  38121. * This groups all the flags used to control the materials channel.
  38122. */
  38123. export class MaterialFlags {
  38124. private static _DiffuseTextureEnabled;
  38125. /**
  38126. * Are diffuse textures enabled in the application.
  38127. */
  38128. static DiffuseTextureEnabled: boolean;
  38129. private static _AmbientTextureEnabled;
  38130. /**
  38131. * Are ambient textures enabled in the application.
  38132. */
  38133. static AmbientTextureEnabled: boolean;
  38134. private static _OpacityTextureEnabled;
  38135. /**
  38136. * Are opacity textures enabled in the application.
  38137. */
  38138. static OpacityTextureEnabled: boolean;
  38139. private static _ReflectionTextureEnabled;
  38140. /**
  38141. * Are reflection textures enabled in the application.
  38142. */
  38143. static ReflectionTextureEnabled: boolean;
  38144. private static _EmissiveTextureEnabled;
  38145. /**
  38146. * Are emissive textures enabled in the application.
  38147. */
  38148. static EmissiveTextureEnabled: boolean;
  38149. private static _SpecularTextureEnabled;
  38150. /**
  38151. * Are specular textures enabled in the application.
  38152. */
  38153. static SpecularTextureEnabled: boolean;
  38154. private static _BumpTextureEnabled;
  38155. /**
  38156. * Are bump textures enabled in the application.
  38157. */
  38158. static BumpTextureEnabled: boolean;
  38159. private static _LightmapTextureEnabled;
  38160. /**
  38161. * Are lightmap textures enabled in the application.
  38162. */
  38163. static LightmapTextureEnabled: boolean;
  38164. private static _RefractionTextureEnabled;
  38165. /**
  38166. * Are refraction textures enabled in the application.
  38167. */
  38168. static RefractionTextureEnabled: boolean;
  38169. private static _ColorGradingTextureEnabled;
  38170. /**
  38171. * Are color grading textures enabled in the application.
  38172. */
  38173. static ColorGradingTextureEnabled: boolean;
  38174. private static _FresnelEnabled;
  38175. /**
  38176. * Are fresnels enabled in the application.
  38177. */
  38178. static FresnelEnabled: boolean;
  38179. private static _ClearCoatTextureEnabled;
  38180. /**
  38181. * Are clear coat textures enabled in the application.
  38182. */
  38183. static ClearCoatTextureEnabled: boolean;
  38184. private static _ClearCoatBumpTextureEnabled;
  38185. /**
  38186. * Are clear coat bump textures enabled in the application.
  38187. */
  38188. static ClearCoatBumpTextureEnabled: boolean;
  38189. private static _ClearCoatTintTextureEnabled;
  38190. /**
  38191. * Are clear coat tint textures enabled in the application.
  38192. */
  38193. static ClearCoatTintTextureEnabled: boolean;
  38194. private static _SheenTextureEnabled;
  38195. /**
  38196. * Are sheen textures enabled in the application.
  38197. */
  38198. static SheenTextureEnabled: boolean;
  38199. private static _AnisotropicTextureEnabled;
  38200. /**
  38201. * Are anisotropic textures enabled in the application.
  38202. */
  38203. static AnisotropicTextureEnabled: boolean;
  38204. private static _ThicknessTextureEnabled;
  38205. /**
  38206. * Are thickness textures enabled in the application.
  38207. */
  38208. static ThicknessTextureEnabled: boolean;
  38209. }
  38210. }
  38211. declare module BABYLON {
  38212. /** @hidden */
  38213. export var defaultFragmentDeclaration: {
  38214. name: string;
  38215. shader: string;
  38216. };
  38217. }
  38218. declare module BABYLON {
  38219. /** @hidden */
  38220. export var defaultUboDeclaration: {
  38221. name: string;
  38222. shader: string;
  38223. };
  38224. }
  38225. declare module BABYLON {
  38226. /** @hidden */
  38227. export var lightFragmentDeclaration: {
  38228. name: string;
  38229. shader: string;
  38230. };
  38231. }
  38232. declare module BABYLON {
  38233. /** @hidden */
  38234. export var lightUboDeclaration: {
  38235. name: string;
  38236. shader: string;
  38237. };
  38238. }
  38239. declare module BABYLON {
  38240. /** @hidden */
  38241. export var lightsFragmentFunctions: {
  38242. name: string;
  38243. shader: string;
  38244. };
  38245. }
  38246. declare module BABYLON {
  38247. /** @hidden */
  38248. export var shadowsFragmentFunctions: {
  38249. name: string;
  38250. shader: string;
  38251. };
  38252. }
  38253. declare module BABYLON {
  38254. /** @hidden */
  38255. export var fresnelFunction: {
  38256. name: string;
  38257. shader: string;
  38258. };
  38259. }
  38260. declare module BABYLON {
  38261. /** @hidden */
  38262. export var reflectionFunction: {
  38263. name: string;
  38264. shader: string;
  38265. };
  38266. }
  38267. declare module BABYLON {
  38268. /** @hidden */
  38269. export var bumpFragmentFunctions: {
  38270. name: string;
  38271. shader: string;
  38272. };
  38273. }
  38274. declare module BABYLON {
  38275. /** @hidden */
  38276. export var logDepthDeclaration: {
  38277. name: string;
  38278. shader: string;
  38279. };
  38280. }
  38281. declare module BABYLON {
  38282. /** @hidden */
  38283. export var bumpFragment: {
  38284. name: string;
  38285. shader: string;
  38286. };
  38287. }
  38288. declare module BABYLON {
  38289. /** @hidden */
  38290. export var depthPrePass: {
  38291. name: string;
  38292. shader: string;
  38293. };
  38294. }
  38295. declare module BABYLON {
  38296. /** @hidden */
  38297. export var lightFragment: {
  38298. name: string;
  38299. shader: string;
  38300. };
  38301. }
  38302. declare module BABYLON {
  38303. /** @hidden */
  38304. export var logDepthFragment: {
  38305. name: string;
  38306. shader: string;
  38307. };
  38308. }
  38309. declare module BABYLON {
  38310. /** @hidden */
  38311. export var defaultPixelShader: {
  38312. name: string;
  38313. shader: string;
  38314. };
  38315. }
  38316. declare module BABYLON {
  38317. /** @hidden */
  38318. export var defaultVertexDeclaration: {
  38319. name: string;
  38320. shader: string;
  38321. };
  38322. }
  38323. declare module BABYLON {
  38324. /** @hidden */
  38325. export var bumpVertexDeclaration: {
  38326. name: string;
  38327. shader: string;
  38328. };
  38329. }
  38330. declare module BABYLON {
  38331. /** @hidden */
  38332. export var bumpVertex: {
  38333. name: string;
  38334. shader: string;
  38335. };
  38336. }
  38337. declare module BABYLON {
  38338. /** @hidden */
  38339. export var fogVertex: {
  38340. name: string;
  38341. shader: string;
  38342. };
  38343. }
  38344. declare module BABYLON {
  38345. /** @hidden */
  38346. export var shadowsVertex: {
  38347. name: string;
  38348. shader: string;
  38349. };
  38350. }
  38351. declare module BABYLON {
  38352. /** @hidden */
  38353. export var pointCloudVertex: {
  38354. name: string;
  38355. shader: string;
  38356. };
  38357. }
  38358. declare module BABYLON {
  38359. /** @hidden */
  38360. export var logDepthVertex: {
  38361. name: string;
  38362. shader: string;
  38363. };
  38364. }
  38365. declare module BABYLON {
  38366. /** @hidden */
  38367. export var defaultVertexShader: {
  38368. name: string;
  38369. shader: string;
  38370. };
  38371. }
  38372. declare module BABYLON {
  38373. /** @hidden */
  38374. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38375. MAINUV1: boolean;
  38376. MAINUV2: boolean;
  38377. DIFFUSE: boolean;
  38378. DIFFUSEDIRECTUV: number;
  38379. AMBIENT: boolean;
  38380. AMBIENTDIRECTUV: number;
  38381. OPACITY: boolean;
  38382. OPACITYDIRECTUV: number;
  38383. OPACITYRGB: boolean;
  38384. REFLECTION: boolean;
  38385. EMISSIVE: boolean;
  38386. EMISSIVEDIRECTUV: number;
  38387. SPECULAR: boolean;
  38388. SPECULARDIRECTUV: number;
  38389. BUMP: boolean;
  38390. BUMPDIRECTUV: number;
  38391. PARALLAX: boolean;
  38392. PARALLAXOCCLUSION: boolean;
  38393. SPECULAROVERALPHA: boolean;
  38394. CLIPPLANE: boolean;
  38395. CLIPPLANE2: boolean;
  38396. CLIPPLANE3: boolean;
  38397. CLIPPLANE4: boolean;
  38398. ALPHATEST: boolean;
  38399. DEPTHPREPASS: boolean;
  38400. ALPHAFROMDIFFUSE: boolean;
  38401. POINTSIZE: boolean;
  38402. FOG: boolean;
  38403. SPECULARTERM: boolean;
  38404. DIFFUSEFRESNEL: boolean;
  38405. OPACITYFRESNEL: boolean;
  38406. REFLECTIONFRESNEL: boolean;
  38407. REFRACTIONFRESNEL: boolean;
  38408. EMISSIVEFRESNEL: boolean;
  38409. FRESNEL: boolean;
  38410. NORMAL: boolean;
  38411. UV1: boolean;
  38412. UV2: boolean;
  38413. VERTEXCOLOR: boolean;
  38414. VERTEXALPHA: boolean;
  38415. NUM_BONE_INFLUENCERS: number;
  38416. BonesPerMesh: number;
  38417. BONETEXTURE: boolean;
  38418. INSTANCES: boolean;
  38419. GLOSSINESS: boolean;
  38420. ROUGHNESS: boolean;
  38421. EMISSIVEASILLUMINATION: boolean;
  38422. LINKEMISSIVEWITHDIFFUSE: boolean;
  38423. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38424. LIGHTMAP: boolean;
  38425. LIGHTMAPDIRECTUV: number;
  38426. OBJECTSPACE_NORMALMAP: boolean;
  38427. USELIGHTMAPASSHADOWMAP: boolean;
  38428. REFLECTIONMAP_3D: boolean;
  38429. REFLECTIONMAP_SPHERICAL: boolean;
  38430. REFLECTIONMAP_PLANAR: boolean;
  38431. REFLECTIONMAP_CUBIC: boolean;
  38432. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38433. REFLECTIONMAP_PROJECTION: boolean;
  38434. REFLECTIONMAP_SKYBOX: boolean;
  38435. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38436. REFLECTIONMAP_EXPLICIT: boolean;
  38437. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38438. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38439. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38440. INVERTCUBICMAP: boolean;
  38441. LOGARITHMICDEPTH: boolean;
  38442. REFRACTION: boolean;
  38443. REFRACTIONMAP_3D: boolean;
  38444. REFLECTIONOVERALPHA: boolean;
  38445. TWOSIDEDLIGHTING: boolean;
  38446. SHADOWFLOAT: boolean;
  38447. MORPHTARGETS: boolean;
  38448. MORPHTARGETS_NORMAL: boolean;
  38449. MORPHTARGETS_TANGENT: boolean;
  38450. NUM_MORPH_INFLUENCERS: number;
  38451. NONUNIFORMSCALING: boolean;
  38452. PREMULTIPLYALPHA: boolean;
  38453. IMAGEPROCESSING: boolean;
  38454. VIGNETTE: boolean;
  38455. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38456. VIGNETTEBLENDMODEOPAQUE: boolean;
  38457. TONEMAPPING: boolean;
  38458. TONEMAPPING_ACES: boolean;
  38459. CONTRAST: boolean;
  38460. COLORCURVES: boolean;
  38461. COLORGRADING: boolean;
  38462. COLORGRADING3D: boolean;
  38463. SAMPLER3DGREENDEPTH: boolean;
  38464. SAMPLER3DBGRMAP: boolean;
  38465. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38466. MULTIVIEW: boolean;
  38467. /**
  38468. * If the reflection texture on this material is in linear color space
  38469. * @hidden
  38470. */
  38471. IS_REFLECTION_LINEAR: boolean;
  38472. /**
  38473. * If the refraction texture on this material is in linear color space
  38474. * @hidden
  38475. */
  38476. IS_REFRACTION_LINEAR: boolean;
  38477. EXPOSURE: boolean;
  38478. constructor();
  38479. setReflectionMode(modeToEnable: string): void;
  38480. }
  38481. /**
  38482. * This is the default material used in Babylon. It is the best trade off between quality
  38483. * and performances.
  38484. * @see http://doc.babylonjs.com/babylon101/materials
  38485. */
  38486. export class StandardMaterial extends PushMaterial {
  38487. private _diffuseTexture;
  38488. /**
  38489. * The basic texture of the material as viewed under a light.
  38490. */
  38491. diffuseTexture: Nullable<BaseTexture>;
  38492. private _ambientTexture;
  38493. /**
  38494. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38495. */
  38496. ambientTexture: Nullable<BaseTexture>;
  38497. private _opacityTexture;
  38498. /**
  38499. * Define the transparency of the material from a texture.
  38500. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38501. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38502. */
  38503. opacityTexture: Nullable<BaseTexture>;
  38504. private _reflectionTexture;
  38505. /**
  38506. * Define the texture used to display the reflection.
  38507. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38508. */
  38509. reflectionTexture: Nullable<BaseTexture>;
  38510. private _emissiveTexture;
  38511. /**
  38512. * Define texture of the material as if self lit.
  38513. * This will be mixed in the final result even in the absence of light.
  38514. */
  38515. emissiveTexture: Nullable<BaseTexture>;
  38516. private _specularTexture;
  38517. /**
  38518. * Define how the color and intensity of the highlight given by the light in the material.
  38519. */
  38520. specularTexture: Nullable<BaseTexture>;
  38521. private _bumpTexture;
  38522. /**
  38523. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38524. * 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.
  38525. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38526. */
  38527. bumpTexture: Nullable<BaseTexture>;
  38528. private _lightmapTexture;
  38529. /**
  38530. * Complex lighting can be computationally expensive to compute at runtime.
  38531. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38532. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38533. */
  38534. lightmapTexture: Nullable<BaseTexture>;
  38535. private _refractionTexture;
  38536. /**
  38537. * Define the texture used to display the refraction.
  38538. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38539. */
  38540. refractionTexture: Nullable<BaseTexture>;
  38541. /**
  38542. * The color of the material lit by the environmental background lighting.
  38543. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38544. */
  38545. ambientColor: Color3;
  38546. /**
  38547. * The basic color of the material as viewed under a light.
  38548. */
  38549. diffuseColor: Color3;
  38550. /**
  38551. * Define how the color and intensity of the highlight given by the light in the material.
  38552. */
  38553. specularColor: Color3;
  38554. /**
  38555. * Define the color of the material as if self lit.
  38556. * This will be mixed in the final result even in the absence of light.
  38557. */
  38558. emissiveColor: Color3;
  38559. /**
  38560. * Defines how sharp are the highlights in the material.
  38561. * The bigger the value the sharper giving a more glossy feeling to the result.
  38562. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38563. */
  38564. specularPower: number;
  38565. private _useAlphaFromDiffuseTexture;
  38566. /**
  38567. * Does the transparency come from the diffuse texture alpha channel.
  38568. */
  38569. useAlphaFromDiffuseTexture: boolean;
  38570. private _useEmissiveAsIllumination;
  38571. /**
  38572. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38573. */
  38574. useEmissiveAsIllumination: boolean;
  38575. private _linkEmissiveWithDiffuse;
  38576. /**
  38577. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38578. * the emissive level when the final color is close to one.
  38579. */
  38580. linkEmissiveWithDiffuse: boolean;
  38581. private _useSpecularOverAlpha;
  38582. /**
  38583. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38584. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38585. */
  38586. useSpecularOverAlpha: boolean;
  38587. private _useReflectionOverAlpha;
  38588. /**
  38589. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38590. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38591. */
  38592. useReflectionOverAlpha: boolean;
  38593. private _disableLighting;
  38594. /**
  38595. * Does lights from the scene impacts this material.
  38596. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38597. */
  38598. disableLighting: boolean;
  38599. private _useObjectSpaceNormalMap;
  38600. /**
  38601. * Allows using an object space normal map (instead of tangent space).
  38602. */
  38603. useObjectSpaceNormalMap: boolean;
  38604. private _useParallax;
  38605. /**
  38606. * Is parallax enabled or not.
  38607. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38608. */
  38609. useParallax: boolean;
  38610. private _useParallaxOcclusion;
  38611. /**
  38612. * Is parallax occlusion enabled or not.
  38613. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38614. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38615. */
  38616. useParallaxOcclusion: boolean;
  38617. /**
  38618. * 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.
  38619. */
  38620. parallaxScaleBias: number;
  38621. private _roughness;
  38622. /**
  38623. * Helps to define how blurry the reflections should appears in the material.
  38624. */
  38625. roughness: number;
  38626. /**
  38627. * In case of refraction, define the value of the indice of refraction.
  38628. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38629. */
  38630. indexOfRefraction: number;
  38631. /**
  38632. * Invert the refraction texture alongside the y axis.
  38633. * It can be useful with procedural textures or probe for instance.
  38634. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38635. */
  38636. invertRefractionY: boolean;
  38637. /**
  38638. * Defines the alpha limits in alpha test mode.
  38639. */
  38640. alphaCutOff: number;
  38641. private _useLightmapAsShadowmap;
  38642. /**
  38643. * In case of light mapping, define whether the map contains light or shadow informations.
  38644. */
  38645. useLightmapAsShadowmap: boolean;
  38646. private _diffuseFresnelParameters;
  38647. /**
  38648. * Define the diffuse fresnel parameters of the material.
  38649. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38650. */
  38651. diffuseFresnelParameters: FresnelParameters;
  38652. private _opacityFresnelParameters;
  38653. /**
  38654. * Define the opacity fresnel parameters of the material.
  38655. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38656. */
  38657. opacityFresnelParameters: FresnelParameters;
  38658. private _reflectionFresnelParameters;
  38659. /**
  38660. * Define the reflection fresnel parameters of the material.
  38661. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38662. */
  38663. reflectionFresnelParameters: FresnelParameters;
  38664. private _refractionFresnelParameters;
  38665. /**
  38666. * Define the refraction fresnel parameters of the material.
  38667. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38668. */
  38669. refractionFresnelParameters: FresnelParameters;
  38670. private _emissiveFresnelParameters;
  38671. /**
  38672. * Define the emissive fresnel parameters of the material.
  38673. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38674. */
  38675. emissiveFresnelParameters: FresnelParameters;
  38676. private _useReflectionFresnelFromSpecular;
  38677. /**
  38678. * If true automatically deducts the fresnels values from the material specularity.
  38679. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38680. */
  38681. useReflectionFresnelFromSpecular: boolean;
  38682. private _useGlossinessFromSpecularMapAlpha;
  38683. /**
  38684. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38685. */
  38686. useGlossinessFromSpecularMapAlpha: boolean;
  38687. private _maxSimultaneousLights;
  38688. /**
  38689. * Defines the maximum number of lights that can be used in the material
  38690. */
  38691. maxSimultaneousLights: number;
  38692. private _invertNormalMapX;
  38693. /**
  38694. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38695. */
  38696. invertNormalMapX: boolean;
  38697. private _invertNormalMapY;
  38698. /**
  38699. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38700. */
  38701. invertNormalMapY: boolean;
  38702. private _twoSidedLighting;
  38703. /**
  38704. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38705. */
  38706. twoSidedLighting: boolean;
  38707. /**
  38708. * Default configuration related to image processing available in the standard Material.
  38709. */
  38710. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38711. /**
  38712. * Gets the image processing configuration used either in this material.
  38713. */
  38714. /**
  38715. * Sets the Default image processing configuration used either in the this material.
  38716. *
  38717. * If sets to null, the scene one is in use.
  38718. */
  38719. imageProcessingConfiguration: ImageProcessingConfiguration;
  38720. /**
  38721. * Keep track of the image processing observer to allow dispose and replace.
  38722. */
  38723. private _imageProcessingObserver;
  38724. /**
  38725. * Attaches a new image processing configuration to the Standard Material.
  38726. * @param configuration
  38727. */
  38728. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38729. /**
  38730. * Gets wether the color curves effect is enabled.
  38731. */
  38732. /**
  38733. * Sets wether the color curves effect is enabled.
  38734. */
  38735. cameraColorCurvesEnabled: boolean;
  38736. /**
  38737. * Gets wether the color grading effect is enabled.
  38738. */
  38739. /**
  38740. * Gets wether the color grading effect is enabled.
  38741. */
  38742. cameraColorGradingEnabled: boolean;
  38743. /**
  38744. * Gets wether tonemapping is enabled or not.
  38745. */
  38746. /**
  38747. * Sets wether tonemapping is enabled or not
  38748. */
  38749. cameraToneMappingEnabled: boolean;
  38750. /**
  38751. * The camera exposure used on this material.
  38752. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38753. * This corresponds to a photographic exposure.
  38754. */
  38755. /**
  38756. * The camera exposure used on this material.
  38757. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38758. * This corresponds to a photographic exposure.
  38759. */
  38760. cameraExposure: number;
  38761. /**
  38762. * Gets The camera contrast used on this material.
  38763. */
  38764. /**
  38765. * Sets The camera contrast used on this material.
  38766. */
  38767. cameraContrast: number;
  38768. /**
  38769. * Gets the Color Grading 2D Lookup Texture.
  38770. */
  38771. /**
  38772. * Sets the Color Grading 2D Lookup Texture.
  38773. */
  38774. cameraColorGradingTexture: Nullable<BaseTexture>;
  38775. /**
  38776. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38777. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38778. * 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;
  38779. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38780. */
  38781. /**
  38782. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38783. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38784. * 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;
  38785. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38786. */
  38787. cameraColorCurves: Nullable<ColorCurves>;
  38788. /**
  38789. * Custom callback helping to override the default shader used in the material.
  38790. */
  38791. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38792. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38793. protected _worldViewProjectionMatrix: Matrix;
  38794. protected _globalAmbientColor: Color3;
  38795. protected _useLogarithmicDepth: boolean;
  38796. /**
  38797. * Instantiates a new standard material.
  38798. * This is the default material used in Babylon. It is the best trade off between quality
  38799. * and performances.
  38800. * @see http://doc.babylonjs.com/babylon101/materials
  38801. * @param name Define the name of the material in the scene
  38802. * @param scene Define the scene the material belong to
  38803. */
  38804. constructor(name: string, scene: Scene);
  38805. /**
  38806. * Gets a boolean indicating that current material needs to register RTT
  38807. */
  38808. readonly hasRenderTargetTextures: boolean;
  38809. /**
  38810. * Gets the current class name of the material e.g. "StandardMaterial"
  38811. * Mainly use in serialization.
  38812. * @returns the class name
  38813. */
  38814. getClassName(): string;
  38815. /**
  38816. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38817. * You can try switching to logarithmic depth.
  38818. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38819. */
  38820. useLogarithmicDepth: boolean;
  38821. /**
  38822. * Specifies if the material will require alpha blending
  38823. * @returns a boolean specifying if alpha blending is needed
  38824. */
  38825. needAlphaBlending(): boolean;
  38826. /**
  38827. * Specifies if this material should be rendered in alpha test mode
  38828. * @returns a boolean specifying if an alpha test is needed.
  38829. */
  38830. needAlphaTesting(): boolean;
  38831. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38832. /**
  38833. * Get the texture used for alpha test purpose.
  38834. * @returns the diffuse texture in case of the standard material.
  38835. */
  38836. getAlphaTestTexture(): Nullable<BaseTexture>;
  38837. /**
  38838. * Get if the submesh is ready to be used and all its information available.
  38839. * Child classes can use it to update shaders
  38840. * @param mesh defines the mesh to check
  38841. * @param subMesh defines which submesh to check
  38842. * @param useInstances specifies that instances should be used
  38843. * @returns a boolean indicating that the submesh is ready or not
  38844. */
  38845. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38846. /**
  38847. * Builds the material UBO layouts.
  38848. * Used internally during the effect preparation.
  38849. */
  38850. buildUniformLayout(): void;
  38851. /**
  38852. * Unbinds the material from the mesh
  38853. */
  38854. unbind(): void;
  38855. /**
  38856. * Binds the submesh to this material by preparing the effect and shader to draw
  38857. * @param world defines the world transformation matrix
  38858. * @param mesh defines the mesh containing the submesh
  38859. * @param subMesh defines the submesh to bind the material to
  38860. */
  38861. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38862. /**
  38863. * Get the list of animatables in the material.
  38864. * @returns the list of animatables object used in the material
  38865. */
  38866. getAnimatables(): IAnimatable[];
  38867. /**
  38868. * Gets the active textures from the material
  38869. * @returns an array of textures
  38870. */
  38871. getActiveTextures(): BaseTexture[];
  38872. /**
  38873. * Specifies if the material uses a texture
  38874. * @param texture defines the texture to check against the material
  38875. * @returns a boolean specifying if the material uses the texture
  38876. */
  38877. hasTexture(texture: BaseTexture): boolean;
  38878. /**
  38879. * Disposes the material
  38880. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38881. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38882. */
  38883. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38884. /**
  38885. * Makes a duplicate of the material, and gives it a new name
  38886. * @param name defines the new name for the duplicated material
  38887. * @returns the cloned material
  38888. */
  38889. clone(name: string): StandardMaterial;
  38890. /**
  38891. * Serializes this material in a JSON representation
  38892. * @returns the serialized material object
  38893. */
  38894. serialize(): any;
  38895. /**
  38896. * Creates a standard material from parsed material data
  38897. * @param source defines the JSON representation of the material
  38898. * @param scene defines the hosting scene
  38899. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38900. * @returns a new standard material
  38901. */
  38902. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38903. /**
  38904. * Are diffuse textures enabled in the application.
  38905. */
  38906. static DiffuseTextureEnabled: boolean;
  38907. /**
  38908. * Are ambient textures enabled in the application.
  38909. */
  38910. static AmbientTextureEnabled: boolean;
  38911. /**
  38912. * Are opacity textures enabled in the application.
  38913. */
  38914. static OpacityTextureEnabled: boolean;
  38915. /**
  38916. * Are reflection textures enabled in the application.
  38917. */
  38918. static ReflectionTextureEnabled: boolean;
  38919. /**
  38920. * Are emissive textures enabled in the application.
  38921. */
  38922. static EmissiveTextureEnabled: boolean;
  38923. /**
  38924. * Are specular textures enabled in the application.
  38925. */
  38926. static SpecularTextureEnabled: boolean;
  38927. /**
  38928. * Are bump textures enabled in the application.
  38929. */
  38930. static BumpTextureEnabled: boolean;
  38931. /**
  38932. * Are lightmap textures enabled in the application.
  38933. */
  38934. static LightmapTextureEnabled: boolean;
  38935. /**
  38936. * Are refraction textures enabled in the application.
  38937. */
  38938. static RefractionTextureEnabled: boolean;
  38939. /**
  38940. * Are color grading textures enabled in the application.
  38941. */
  38942. static ColorGradingTextureEnabled: boolean;
  38943. /**
  38944. * Are fresnels enabled in the application.
  38945. */
  38946. static FresnelEnabled: boolean;
  38947. }
  38948. }
  38949. declare module BABYLON {
  38950. /**
  38951. * A class extending Texture allowing drawing on a texture
  38952. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38953. */
  38954. export class DynamicTexture extends Texture {
  38955. private _generateMipMaps;
  38956. private _canvas;
  38957. private _context;
  38958. private _engine;
  38959. /**
  38960. * Creates a DynamicTexture
  38961. * @param name defines the name of the texture
  38962. * @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
  38963. * @param scene defines the scene where you want the texture
  38964. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38965. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38966. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38967. */
  38968. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38969. /**
  38970. * Get the current class name of the texture useful for serialization or dynamic coding.
  38971. * @returns "DynamicTexture"
  38972. */
  38973. getClassName(): string;
  38974. /**
  38975. * Gets the current state of canRescale
  38976. */
  38977. readonly canRescale: boolean;
  38978. private _recreate;
  38979. /**
  38980. * Scales the texture
  38981. * @param ratio the scale factor to apply to both width and height
  38982. */
  38983. scale(ratio: number): void;
  38984. /**
  38985. * Resizes the texture
  38986. * @param width the new width
  38987. * @param height the new height
  38988. */
  38989. scaleTo(width: number, height: number): void;
  38990. /**
  38991. * Gets the context of the canvas used by the texture
  38992. * @returns the canvas context of the dynamic texture
  38993. */
  38994. getContext(): CanvasRenderingContext2D;
  38995. /**
  38996. * Clears the texture
  38997. */
  38998. clear(): void;
  38999. /**
  39000. * Updates the texture
  39001. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39002. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39003. */
  39004. update(invertY?: boolean, premulAlpha?: boolean): void;
  39005. /**
  39006. * Draws text onto the texture
  39007. * @param text defines the text to be drawn
  39008. * @param x defines the placement of the text from the left
  39009. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39010. * @param font defines the font to be used with font-style, font-size, font-name
  39011. * @param color defines the color used for the text
  39012. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39013. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39014. * @param update defines whether texture is immediately update (default is true)
  39015. */
  39016. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39017. /**
  39018. * Clones the texture
  39019. * @returns the clone of the texture.
  39020. */
  39021. clone(): DynamicTexture;
  39022. /**
  39023. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39024. * @returns a serialized dynamic texture object
  39025. */
  39026. serialize(): any;
  39027. /** @hidden */
  39028. _rebuild(): void;
  39029. }
  39030. }
  39031. declare module BABYLON {
  39032. /** @hidden */
  39033. export var imageProcessingPixelShader: {
  39034. name: string;
  39035. shader: string;
  39036. };
  39037. }
  39038. declare module BABYLON {
  39039. /**
  39040. * ImageProcessingPostProcess
  39041. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39042. */
  39043. export class ImageProcessingPostProcess extends PostProcess {
  39044. /**
  39045. * Default configuration related to image processing available in the PBR Material.
  39046. */
  39047. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39048. /**
  39049. * Gets the image processing configuration used either in this material.
  39050. */
  39051. /**
  39052. * Sets the Default image processing configuration used either in the this material.
  39053. *
  39054. * If sets to null, the scene one is in use.
  39055. */
  39056. imageProcessingConfiguration: ImageProcessingConfiguration;
  39057. /**
  39058. * Keep track of the image processing observer to allow dispose and replace.
  39059. */
  39060. private _imageProcessingObserver;
  39061. /**
  39062. * Attaches a new image processing configuration to the PBR Material.
  39063. * @param configuration
  39064. */
  39065. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39066. /**
  39067. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39068. */
  39069. /**
  39070. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39071. */
  39072. colorCurves: Nullable<ColorCurves>;
  39073. /**
  39074. * Gets wether the color curves effect is enabled.
  39075. */
  39076. /**
  39077. * Sets wether the color curves effect is enabled.
  39078. */
  39079. colorCurvesEnabled: boolean;
  39080. /**
  39081. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39082. */
  39083. /**
  39084. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39085. */
  39086. colorGradingTexture: Nullable<BaseTexture>;
  39087. /**
  39088. * Gets wether the color grading effect is enabled.
  39089. */
  39090. /**
  39091. * Gets wether the color grading effect is enabled.
  39092. */
  39093. colorGradingEnabled: boolean;
  39094. /**
  39095. * Gets exposure used in the effect.
  39096. */
  39097. /**
  39098. * Sets exposure used in the effect.
  39099. */
  39100. exposure: number;
  39101. /**
  39102. * Gets wether tonemapping is enabled or not.
  39103. */
  39104. /**
  39105. * Sets wether tonemapping is enabled or not
  39106. */
  39107. toneMappingEnabled: boolean;
  39108. /**
  39109. * Gets the type of tone mapping effect.
  39110. */
  39111. /**
  39112. * Sets the type of tone mapping effect.
  39113. */
  39114. toneMappingType: number;
  39115. /**
  39116. * Gets contrast used in the effect.
  39117. */
  39118. /**
  39119. * Sets contrast used in the effect.
  39120. */
  39121. contrast: number;
  39122. /**
  39123. * Gets Vignette stretch size.
  39124. */
  39125. /**
  39126. * Sets Vignette stretch size.
  39127. */
  39128. vignetteStretch: number;
  39129. /**
  39130. * Gets Vignette centre X Offset.
  39131. */
  39132. /**
  39133. * Sets Vignette centre X Offset.
  39134. */
  39135. vignetteCentreX: number;
  39136. /**
  39137. * Gets Vignette centre Y Offset.
  39138. */
  39139. /**
  39140. * Sets Vignette centre Y Offset.
  39141. */
  39142. vignetteCentreY: number;
  39143. /**
  39144. * Gets Vignette weight or intensity of the vignette effect.
  39145. */
  39146. /**
  39147. * Sets Vignette weight or intensity of the vignette effect.
  39148. */
  39149. vignetteWeight: number;
  39150. /**
  39151. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39152. * if vignetteEnabled is set to true.
  39153. */
  39154. /**
  39155. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39156. * if vignetteEnabled is set to true.
  39157. */
  39158. vignetteColor: Color4;
  39159. /**
  39160. * Gets Camera field of view used by the Vignette effect.
  39161. */
  39162. /**
  39163. * Sets Camera field of view used by the Vignette effect.
  39164. */
  39165. vignetteCameraFov: number;
  39166. /**
  39167. * Gets the vignette blend mode allowing different kind of effect.
  39168. */
  39169. /**
  39170. * Sets the vignette blend mode allowing different kind of effect.
  39171. */
  39172. vignetteBlendMode: number;
  39173. /**
  39174. * Gets wether the vignette effect is enabled.
  39175. */
  39176. /**
  39177. * Sets wether the vignette effect is enabled.
  39178. */
  39179. vignetteEnabled: boolean;
  39180. private _fromLinearSpace;
  39181. /**
  39182. * Gets wether the input of the processing is in Gamma or Linear Space.
  39183. */
  39184. /**
  39185. * Sets wether the input of the processing is in Gamma or Linear Space.
  39186. */
  39187. fromLinearSpace: boolean;
  39188. /**
  39189. * Defines cache preventing GC.
  39190. */
  39191. private _defines;
  39192. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39193. /**
  39194. * "ImageProcessingPostProcess"
  39195. * @returns "ImageProcessingPostProcess"
  39196. */
  39197. getClassName(): string;
  39198. protected _updateParameters(): void;
  39199. dispose(camera?: Camera): void;
  39200. }
  39201. }
  39202. declare module BABYLON {
  39203. /**
  39204. * Class containing static functions to help procedurally build meshes
  39205. */
  39206. export class GroundBuilder {
  39207. /**
  39208. * Creates a ground mesh
  39209. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39210. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39212. * @param name defines the name of the mesh
  39213. * @param options defines the options used to create the mesh
  39214. * @param scene defines the hosting scene
  39215. * @returns the ground mesh
  39216. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39217. */
  39218. static CreateGround(name: string, options: {
  39219. width?: number;
  39220. height?: number;
  39221. subdivisions?: number;
  39222. subdivisionsX?: number;
  39223. subdivisionsY?: number;
  39224. updatable?: boolean;
  39225. }, scene: any): Mesh;
  39226. /**
  39227. * Creates a tiled ground mesh
  39228. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39229. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39230. * * 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
  39231. * * 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
  39232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39233. * @param name defines the name of the mesh
  39234. * @param options defines the options used to create the mesh
  39235. * @param scene defines the hosting scene
  39236. * @returns the tiled ground mesh
  39237. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39238. */
  39239. static CreateTiledGround(name: string, options: {
  39240. xmin: number;
  39241. zmin: number;
  39242. xmax: number;
  39243. zmax: number;
  39244. subdivisions?: {
  39245. w: number;
  39246. h: number;
  39247. };
  39248. precision?: {
  39249. w: number;
  39250. h: number;
  39251. };
  39252. updatable?: boolean;
  39253. }, scene?: Nullable<Scene>): Mesh;
  39254. /**
  39255. * Creates a ground mesh from a height map
  39256. * * The parameter `url` sets the URL of the height map image resource.
  39257. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39258. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39259. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39260. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39261. * * 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.
  39262. * * 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).
  39263. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39265. * @param name defines the name of the mesh
  39266. * @param url defines the url to the height map
  39267. * @param options defines the options used to create the mesh
  39268. * @param scene defines the hosting scene
  39269. * @returns the ground mesh
  39270. * @see https://doc.babylonjs.com/babylon101/height_map
  39271. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39272. */
  39273. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39274. width?: number;
  39275. height?: number;
  39276. subdivisions?: number;
  39277. minHeight?: number;
  39278. maxHeight?: number;
  39279. colorFilter?: Color3;
  39280. alphaFilter?: number;
  39281. updatable?: boolean;
  39282. onReady?: (mesh: GroundMesh) => void;
  39283. }, scene?: Nullable<Scene>): GroundMesh;
  39284. }
  39285. }
  39286. declare module BABYLON {
  39287. /**
  39288. * Class containing static functions to help procedurally build meshes
  39289. */
  39290. export class TorusBuilder {
  39291. /**
  39292. * Creates a torus mesh
  39293. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39294. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39295. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39299. * @param name defines the name of the mesh
  39300. * @param options defines the options used to create the mesh
  39301. * @param scene defines the hosting scene
  39302. * @returns the torus mesh
  39303. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39304. */
  39305. static CreateTorus(name: string, options: {
  39306. diameter?: number;
  39307. thickness?: number;
  39308. tessellation?: number;
  39309. updatable?: boolean;
  39310. sideOrientation?: number;
  39311. frontUVs?: Vector4;
  39312. backUVs?: Vector4;
  39313. }, scene: any): Mesh;
  39314. }
  39315. }
  39316. declare module BABYLON {
  39317. /**
  39318. * Class containing static functions to help procedurally build meshes
  39319. */
  39320. export class CylinderBuilder {
  39321. /**
  39322. * Creates a cylinder or a cone mesh
  39323. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39324. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39325. * * 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.
  39326. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39327. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39328. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39329. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39330. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39331. * * 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).
  39332. * * 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
  39333. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39334. * * 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
  39335. * * 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.
  39336. * * If `enclose` is false, a ring surface is one element.
  39337. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39338. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  39339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39340. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39342. * @param name defines the name of the mesh
  39343. * @param options defines the options used to create the mesh
  39344. * @param scene defines the hosting scene
  39345. * @returns the cylinder mesh
  39346. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39347. */
  39348. static CreateCylinder(name: string, options: {
  39349. height?: number;
  39350. diameterTop?: number;
  39351. diameterBottom?: number;
  39352. diameter?: number;
  39353. tessellation?: number;
  39354. subdivisions?: number;
  39355. arc?: number;
  39356. faceColors?: Color4[];
  39357. faceUV?: Vector4[];
  39358. updatable?: boolean;
  39359. hasRings?: boolean;
  39360. enclose?: boolean;
  39361. sideOrientation?: number;
  39362. frontUVs?: Vector4;
  39363. backUVs?: Vector4;
  39364. }, scene: any): Mesh;
  39365. }
  39366. }
  39367. declare module BABYLON {
  39368. /**
  39369. * Manager for handling gamepads
  39370. */
  39371. export class GamepadManager {
  39372. private _scene?;
  39373. private _babylonGamepads;
  39374. private _oneGamepadConnected;
  39375. /** @hidden */
  39376. _isMonitoring: boolean;
  39377. private _gamepadEventSupported;
  39378. private _gamepadSupport;
  39379. /**
  39380. * observable to be triggered when the gamepad controller has been connected
  39381. */
  39382. onGamepadConnectedObservable: Observable<Gamepad>;
  39383. /**
  39384. * observable to be triggered when the gamepad controller has been disconnected
  39385. */
  39386. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39387. private _onGamepadConnectedEvent;
  39388. private _onGamepadDisconnectedEvent;
  39389. /**
  39390. * Initializes the gamepad manager
  39391. * @param _scene BabylonJS scene
  39392. */
  39393. constructor(_scene?: Scene | undefined);
  39394. /**
  39395. * The gamepads in the game pad manager
  39396. */
  39397. readonly gamepads: Gamepad[];
  39398. /**
  39399. * Get the gamepad controllers based on type
  39400. * @param type The type of gamepad controller
  39401. * @returns Nullable gamepad
  39402. */
  39403. getGamepadByType(type?: number): Nullable<Gamepad>;
  39404. /**
  39405. * Disposes the gamepad manager
  39406. */
  39407. dispose(): void;
  39408. private _addNewGamepad;
  39409. private _startMonitoringGamepads;
  39410. private _stopMonitoringGamepads;
  39411. /** @hidden */
  39412. _checkGamepadsStatus(): void;
  39413. private _updateGamepadObjects;
  39414. }
  39415. }
  39416. declare module BABYLON {
  39417. interface Scene {
  39418. /** @hidden */
  39419. _gamepadManager: Nullable<GamepadManager>;
  39420. /**
  39421. * Gets the gamepad manager associated with the scene
  39422. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39423. */
  39424. gamepadManager: GamepadManager;
  39425. }
  39426. /**
  39427. * Interface representing a free camera inputs manager
  39428. */
  39429. interface FreeCameraInputsManager {
  39430. /**
  39431. * Adds gamepad input support to the FreeCameraInputsManager.
  39432. * @returns the FreeCameraInputsManager
  39433. */
  39434. addGamepad(): FreeCameraInputsManager;
  39435. }
  39436. /**
  39437. * Interface representing an arc rotate camera inputs manager
  39438. */
  39439. interface ArcRotateCameraInputsManager {
  39440. /**
  39441. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39442. * @returns the camera inputs manager
  39443. */
  39444. addGamepad(): ArcRotateCameraInputsManager;
  39445. }
  39446. /**
  39447. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39448. */
  39449. export class GamepadSystemSceneComponent implements ISceneComponent {
  39450. /**
  39451. * The component name helpfull to identify the component in the list of scene components.
  39452. */
  39453. readonly name: string;
  39454. /**
  39455. * The scene the component belongs to.
  39456. */
  39457. scene: Scene;
  39458. /**
  39459. * Creates a new instance of the component for the given scene
  39460. * @param scene Defines the scene to register the component in
  39461. */
  39462. constructor(scene: Scene);
  39463. /**
  39464. * Registers the component in a given scene
  39465. */
  39466. register(): void;
  39467. /**
  39468. * Rebuilds the elements related to this component in case of
  39469. * context lost for instance.
  39470. */
  39471. rebuild(): void;
  39472. /**
  39473. * Disposes the component and the associated ressources
  39474. */
  39475. dispose(): void;
  39476. private _beforeCameraUpdate;
  39477. }
  39478. }
  39479. declare module BABYLON {
  39480. /**
  39481. * Options to modify the vr teleportation behavior.
  39482. */
  39483. export interface VRTeleportationOptions {
  39484. /**
  39485. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39486. */
  39487. floorMeshName?: string;
  39488. /**
  39489. * A list of meshes to be used as the teleportation floor. (default: empty)
  39490. */
  39491. floorMeshes?: Mesh[];
  39492. }
  39493. /**
  39494. * Options to modify the vr experience helper's behavior.
  39495. */
  39496. export interface VRExperienceHelperOptions extends WebVROptions {
  39497. /**
  39498. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39499. */
  39500. createDeviceOrientationCamera?: boolean;
  39501. /**
  39502. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39503. */
  39504. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39505. /**
  39506. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39507. */
  39508. laserToggle?: boolean;
  39509. /**
  39510. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39511. */
  39512. floorMeshes?: Mesh[];
  39513. /**
  39514. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39515. */
  39516. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39517. }
  39518. /**
  39519. * Event containing information after VR has been entered
  39520. */
  39521. export class OnAfterEnteringVRObservableEvent {
  39522. /**
  39523. * If entering vr was successful
  39524. */
  39525. success: boolean;
  39526. }
  39527. /**
  39528. * Helps to quickly add VR support to an existing scene.
  39529. * See http://doc.babylonjs.com/how_to/webvr_helper
  39530. */
  39531. export class VRExperienceHelper {
  39532. /** Options to modify the vr experience helper's behavior. */
  39533. webVROptions: VRExperienceHelperOptions;
  39534. private _scene;
  39535. private _position;
  39536. private _btnVR;
  39537. private _btnVRDisplayed;
  39538. private _webVRsupported;
  39539. private _webVRready;
  39540. private _webVRrequesting;
  39541. private _webVRpresenting;
  39542. private _hasEnteredVR;
  39543. private _fullscreenVRpresenting;
  39544. private _canvas;
  39545. private _webVRCamera;
  39546. private _vrDeviceOrientationCamera;
  39547. private _deviceOrientationCamera;
  39548. private _existingCamera;
  39549. private _onKeyDown;
  39550. private _onVrDisplayPresentChange;
  39551. private _onVRDisplayChanged;
  39552. private _onVRRequestPresentStart;
  39553. private _onVRRequestPresentComplete;
  39554. /**
  39555. * Observable raised right before entering VR.
  39556. */
  39557. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39558. /**
  39559. * Observable raised when entering VR has completed.
  39560. */
  39561. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39562. /**
  39563. * Observable raised when exiting VR.
  39564. */
  39565. onExitingVRObservable: Observable<VRExperienceHelper>;
  39566. /**
  39567. * Observable raised when controller mesh is loaded.
  39568. */
  39569. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39570. /** Return this.onEnteringVRObservable
  39571. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39572. */
  39573. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39574. /** Return this.onExitingVRObservable
  39575. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39576. */
  39577. readonly onExitingVR: Observable<VRExperienceHelper>;
  39578. /** Return this.onControllerMeshLoadedObservable
  39579. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39580. */
  39581. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39582. private _rayLength;
  39583. private _useCustomVRButton;
  39584. private _teleportationRequested;
  39585. private _teleportActive;
  39586. private _floorMeshName;
  39587. private _floorMeshesCollection;
  39588. private _rotationAllowed;
  39589. private _teleportBackwardsVector;
  39590. private _teleportationTarget;
  39591. private _isDefaultTeleportationTarget;
  39592. private _postProcessMove;
  39593. private _teleportationFillColor;
  39594. private _teleportationBorderColor;
  39595. private _rotationAngle;
  39596. private _haloCenter;
  39597. private _cameraGazer;
  39598. private _padSensibilityUp;
  39599. private _padSensibilityDown;
  39600. private _leftController;
  39601. private _rightController;
  39602. /**
  39603. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39604. */
  39605. onNewMeshSelected: Observable<AbstractMesh>;
  39606. /**
  39607. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39608. */
  39609. onNewMeshPicked: Observable<PickingInfo>;
  39610. private _circleEase;
  39611. /**
  39612. * Observable raised before camera teleportation
  39613. */
  39614. onBeforeCameraTeleport: Observable<Vector3>;
  39615. /**
  39616. * Observable raised after camera teleportation
  39617. */
  39618. onAfterCameraTeleport: Observable<Vector3>;
  39619. /**
  39620. * Observable raised when current selected mesh gets unselected
  39621. */
  39622. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39623. private _raySelectionPredicate;
  39624. /**
  39625. * To be optionaly changed by user to define custom ray selection
  39626. */
  39627. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39628. /**
  39629. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39630. */
  39631. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39632. /**
  39633. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39634. */
  39635. teleportationEnabled: boolean;
  39636. private _defaultHeight;
  39637. private _teleportationInitialized;
  39638. private _interactionsEnabled;
  39639. private _interactionsRequested;
  39640. private _displayGaze;
  39641. private _displayLaserPointer;
  39642. /**
  39643. * The mesh used to display where the user is going to teleport.
  39644. */
  39645. /**
  39646. * Sets the mesh to be used to display where the user is going to teleport.
  39647. */
  39648. teleportationTarget: Mesh;
  39649. /**
  39650. * 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
  39651. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39652. * See http://doc.babylonjs.com/resources/baking_transformations
  39653. */
  39654. gazeTrackerMesh: Mesh;
  39655. /**
  39656. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39657. */
  39658. updateGazeTrackerScale: boolean;
  39659. /**
  39660. * If the gaze trackers color should be updated when selecting meshes
  39661. */
  39662. updateGazeTrackerColor: boolean;
  39663. /**
  39664. * The gaze tracking mesh corresponding to the left controller
  39665. */
  39666. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39667. /**
  39668. * The gaze tracking mesh corresponding to the right controller
  39669. */
  39670. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39671. /**
  39672. * If the ray of the gaze should be displayed.
  39673. */
  39674. /**
  39675. * Sets if the ray of the gaze should be displayed.
  39676. */
  39677. displayGaze: boolean;
  39678. /**
  39679. * If the ray of the LaserPointer should be displayed.
  39680. */
  39681. /**
  39682. * Sets if the ray of the LaserPointer should be displayed.
  39683. */
  39684. displayLaserPointer: boolean;
  39685. /**
  39686. * The deviceOrientationCamera used as the camera when not in VR.
  39687. */
  39688. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39689. /**
  39690. * Based on the current WebVR support, returns the current VR camera used.
  39691. */
  39692. readonly currentVRCamera: Nullable<Camera>;
  39693. /**
  39694. * The webVRCamera which is used when in VR.
  39695. */
  39696. readonly webVRCamera: WebVRFreeCamera;
  39697. /**
  39698. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39699. */
  39700. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39701. private readonly _teleportationRequestInitiated;
  39702. /**
  39703. * Defines wether or not Pointer lock should be requested when switching to
  39704. * full screen.
  39705. */
  39706. requestPointerLockOnFullScreen: boolean;
  39707. /**
  39708. * Instantiates a VRExperienceHelper.
  39709. * Helps to quickly add VR support to an existing scene.
  39710. * @param scene The scene the VRExperienceHelper belongs to.
  39711. * @param webVROptions Options to modify the vr experience helper's behavior.
  39712. */
  39713. constructor(scene: Scene,
  39714. /** Options to modify the vr experience helper's behavior. */
  39715. webVROptions?: VRExperienceHelperOptions);
  39716. private _onDefaultMeshLoaded;
  39717. private _onResize;
  39718. private _onFullscreenChange;
  39719. /**
  39720. * Gets a value indicating if we are currently in VR mode.
  39721. */
  39722. readonly isInVRMode: boolean;
  39723. private onVrDisplayPresentChange;
  39724. private onVRDisplayChanged;
  39725. private moveButtonToBottomRight;
  39726. private displayVRButton;
  39727. private updateButtonVisibility;
  39728. private _cachedAngularSensibility;
  39729. /**
  39730. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39731. * Otherwise, will use the fullscreen API.
  39732. */
  39733. enterVR(): void;
  39734. /**
  39735. * Attempt to exit VR, or fullscreen.
  39736. */
  39737. exitVR(): void;
  39738. /**
  39739. * The position of the vr experience helper.
  39740. */
  39741. /**
  39742. * Sets the position of the vr experience helper.
  39743. */
  39744. position: Vector3;
  39745. /**
  39746. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39747. */
  39748. enableInteractions(): void;
  39749. private readonly _noControllerIsActive;
  39750. private beforeRender;
  39751. private _isTeleportationFloor;
  39752. /**
  39753. * Adds a floor mesh to be used for teleportation.
  39754. * @param floorMesh the mesh to be used for teleportation.
  39755. */
  39756. addFloorMesh(floorMesh: Mesh): void;
  39757. /**
  39758. * Removes a floor mesh from being used for teleportation.
  39759. * @param floorMesh the mesh to be removed.
  39760. */
  39761. removeFloorMesh(floorMesh: Mesh): void;
  39762. /**
  39763. * Enables interactions and teleportation using the VR controllers and gaze.
  39764. * @param vrTeleportationOptions options to modify teleportation behavior.
  39765. */
  39766. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39767. private _onNewGamepadConnected;
  39768. private _tryEnableInteractionOnController;
  39769. private _onNewGamepadDisconnected;
  39770. private _enableInteractionOnController;
  39771. private _checkTeleportWithRay;
  39772. private _checkRotate;
  39773. private _checkTeleportBackwards;
  39774. private _enableTeleportationOnController;
  39775. private _createTeleportationCircles;
  39776. private _displayTeleportationTarget;
  39777. private _hideTeleportationTarget;
  39778. private _rotateCamera;
  39779. private _moveTeleportationSelectorTo;
  39780. private _workingVector;
  39781. private _workingQuaternion;
  39782. private _workingMatrix;
  39783. /**
  39784. * Teleports the users feet to the desired location
  39785. * @param location The location where the user's feet should be placed
  39786. */
  39787. teleportCamera(location: Vector3): void;
  39788. private _convertNormalToDirectionOfRay;
  39789. private _castRayAndSelectObject;
  39790. private _notifySelectedMeshUnselected;
  39791. /**
  39792. * Sets the color of the laser ray from the vr controllers.
  39793. * @param color new color for the ray.
  39794. */
  39795. changeLaserColor(color: Color3): void;
  39796. /**
  39797. * Sets the color of the ray from the vr headsets gaze.
  39798. * @param color new color for the ray.
  39799. */
  39800. changeGazeColor(color: Color3): void;
  39801. /**
  39802. * Exits VR and disposes of the vr experience helper
  39803. */
  39804. dispose(): void;
  39805. /**
  39806. * Gets the name of the VRExperienceHelper class
  39807. * @returns "VRExperienceHelper"
  39808. */
  39809. getClassName(): string;
  39810. }
  39811. }
  39812. declare module BABYLON {
  39813. /**
  39814. * Manages an XRSession
  39815. * @see https://doc.babylonjs.com/how_to/webxr
  39816. */
  39817. export class WebXRSessionManager implements IDisposable {
  39818. private scene;
  39819. /**
  39820. * Fires every time a new xrFrame arrives which can be used to update the camera
  39821. */
  39822. onXRFrameObservable: Observable<any>;
  39823. /**
  39824. * Fires when the xr session is ended either by the device or manually done
  39825. */
  39826. onXRSessionEnded: Observable<any>;
  39827. /** @hidden */
  39828. _xrSession: XRSession;
  39829. /** @hidden */
  39830. _frameOfReference: XRFrameOfReference;
  39831. /** @hidden */
  39832. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39833. /** @hidden */
  39834. _currentXRFrame: Nullable<XRFrame>;
  39835. private _xrNavigator;
  39836. private _xrDevice;
  39837. private _tmpMatrix;
  39838. /**
  39839. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39840. * @param scene The scene which the session should be created for
  39841. */
  39842. constructor(scene: Scene);
  39843. /**
  39844. * Initializes the manager
  39845. * After initialization enterXR can be called to start an XR session
  39846. * @returns Promise which resolves after it is initialized
  39847. */
  39848. initializeAsync(): Promise<void>;
  39849. /**
  39850. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39851. * @param sessionCreationOptions xr options to create the session with
  39852. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39853. * @returns Promise which resolves after it enters XR
  39854. */
  39855. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39856. /**
  39857. * Stops the xrSession and restores the renderloop
  39858. * @returns Promise which resolves after it exits XR
  39859. */
  39860. exitXRAsync(): Promise<void>;
  39861. /**
  39862. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39863. * @param ray ray to cast into the environment
  39864. * @returns Promise which resolves with a collision point in the environment if it exists
  39865. */
  39866. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39867. /**
  39868. * Checks if a session would be supported for the creation options specified
  39869. * @param options creation options to check if they are supported
  39870. * @returns true if supported
  39871. */
  39872. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39873. /**
  39874. * @hidden
  39875. * Converts the render layer of xrSession to a render target
  39876. * @param session session to create render target for
  39877. * @param scene scene the new render target should be created for
  39878. */
  39879. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39880. /**
  39881. * Disposes of the session manager
  39882. */
  39883. dispose(): void;
  39884. }
  39885. }
  39886. declare module BABYLON {
  39887. /**
  39888. * WebXR Camera which holds the views for the xrSession
  39889. * @see https://doc.babylonjs.com/how_to/webxr
  39890. */
  39891. export class WebXRCamera extends FreeCamera {
  39892. private static _TmpMatrix;
  39893. /**
  39894. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39895. * @param name the name of the camera
  39896. * @param scene the scene to add the camera to
  39897. */
  39898. constructor(name: string, scene: Scene);
  39899. private _updateNumberOfRigCameras;
  39900. /** @hidden */
  39901. _updateForDualEyeDebugging(pupilDistance?: number): void;
  39902. /**
  39903. * Updates the cameras position from the current pose information of the XR session
  39904. * @param xrSessionManager the session containing pose information
  39905. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39906. */
  39907. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39908. }
  39909. }
  39910. declare module BABYLON {
  39911. /**
  39912. * States of the webXR experience
  39913. */
  39914. export enum WebXRState {
  39915. /**
  39916. * Transitioning to being in XR mode
  39917. */
  39918. ENTERING_XR = 0,
  39919. /**
  39920. * Transitioning to non XR mode
  39921. */
  39922. EXITING_XR = 1,
  39923. /**
  39924. * In XR mode and presenting
  39925. */
  39926. IN_XR = 2,
  39927. /**
  39928. * Not entered XR mode
  39929. */
  39930. NOT_IN_XR = 3
  39931. }
  39932. /**
  39933. * Helper class used to enable XR
  39934. * @see https://doc.babylonjs.com/how_to/webxr
  39935. */
  39936. export class WebXRExperienceHelper implements IDisposable {
  39937. private scene;
  39938. /**
  39939. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  39940. */
  39941. container: AbstractMesh;
  39942. /**
  39943. * Camera used to render xr content
  39944. */
  39945. camera: WebXRCamera;
  39946. /**
  39947. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39948. */
  39949. state: WebXRState;
  39950. private _setState;
  39951. private static _TmpVector;
  39952. /**
  39953. * Fires when the state of the experience helper has changed
  39954. */
  39955. onStateChangedObservable: Observable<WebXRState>;
  39956. /** @hidden */
  39957. _sessionManager: WebXRSessionManager;
  39958. private _nonVRCamera;
  39959. private _originalSceneAutoClear;
  39960. private _supported;
  39961. /**
  39962. * Creates the experience helper
  39963. * @param scene the scene to attach the experience helper to
  39964. * @returns a promise for the experience helper
  39965. */
  39966. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39967. /**
  39968. * Creates a WebXRExperienceHelper
  39969. * @param scene The scene the helper should be created in
  39970. */
  39971. private constructor();
  39972. /**
  39973. * Exits XR mode and returns the scene to its original state
  39974. * @returns promise that resolves after xr mode has exited
  39975. */
  39976. exitXRAsync(): Promise<void>;
  39977. /**
  39978. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39979. * @param sessionCreationOptions options for the XR session
  39980. * @param frameOfReference frame of reference of the XR session
  39981. * @returns promise that resolves after xr mode has entered
  39982. */
  39983. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39984. /**
  39985. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39986. * @param ray ray to cast into the environment
  39987. * @returns Promise which resolves with a collision point in the environment if it exists
  39988. */
  39989. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39990. /**
  39991. * Updates the global position of the camera by moving the camera's container
  39992. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39993. * @param position The desired global position of the camera
  39994. */
  39995. setPositionOfCameraUsingContainer(position: Vector3): void;
  39996. /**
  39997. * Rotates the xr camera by rotating the camera's container around the camera's position
  39998. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39999. * @param rotation the desired quaternion rotation to apply to the camera
  40000. */
  40001. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40002. /**
  40003. * Checks if the creation options are supported by the xr session
  40004. * @param options creation options
  40005. * @returns true if supported
  40006. */
  40007. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40008. /**
  40009. * Disposes of the experience helper
  40010. */
  40011. dispose(): void;
  40012. }
  40013. }
  40014. declare module BABYLON {
  40015. /**
  40016. * Button which can be used to enter a different mode of XR
  40017. */
  40018. export class WebXREnterExitUIButton {
  40019. /** button element */
  40020. element: HTMLElement;
  40021. /** XR initialization options for the button */
  40022. initializationOptions: XRSessionCreationOptions;
  40023. /**
  40024. * Creates a WebXREnterExitUIButton
  40025. * @param element button element
  40026. * @param initializationOptions XR initialization options for the button
  40027. */
  40028. constructor(
  40029. /** button element */
  40030. element: HTMLElement,
  40031. /** XR initialization options for the button */
  40032. initializationOptions: XRSessionCreationOptions);
  40033. /**
  40034. * Overwritable function which can be used to update the button's visuals when the state changes
  40035. * @param activeButton the current active button in the UI
  40036. */
  40037. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40038. }
  40039. /**
  40040. * Options to create the webXR UI
  40041. */
  40042. export class WebXREnterExitUIOptions {
  40043. /**
  40044. * Context to enter xr with
  40045. */
  40046. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40047. /**
  40048. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40049. */
  40050. customButtons?: Array<WebXREnterExitUIButton>;
  40051. }
  40052. /**
  40053. * UI to allow the user to enter/exit XR mode
  40054. */
  40055. export class WebXREnterExitUI implements IDisposable {
  40056. private scene;
  40057. private _overlay;
  40058. private _buttons;
  40059. private _activeButton;
  40060. /**
  40061. * Fired every time the active button is changed.
  40062. *
  40063. * When xr is entered via a button that launches xr that button will be the callback parameter
  40064. *
  40065. * When exiting xr the callback parameter will be null)
  40066. */
  40067. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40068. /**
  40069. * Creates UI to allow the user to enter/exit XR mode
  40070. * @param scene the scene to add the ui to
  40071. * @param helper the xr experience helper to enter/exit xr with
  40072. * @param options options to configure the UI
  40073. * @returns the created ui
  40074. */
  40075. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40076. private constructor();
  40077. private _updateButtons;
  40078. /**
  40079. * Disposes of the object
  40080. */
  40081. dispose(): void;
  40082. }
  40083. }
  40084. declare module BABYLON {
  40085. /**
  40086. * Represents an XR input
  40087. */
  40088. export class WebXRController {
  40089. /**
  40090. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  40091. */
  40092. grip?: AbstractMesh;
  40093. /**
  40094. * Pointer which can be used to select objects or attach a visible laser to
  40095. */
  40096. pointer: AbstractMesh;
  40097. /**
  40098. * Creates the controller
  40099. * @see https://doc.babylonjs.com/how_to/webxr
  40100. * @param scene the scene which the controller should be associated to
  40101. */
  40102. constructor(scene: Scene);
  40103. /**
  40104. * Disposes of the object
  40105. */
  40106. dispose(): void;
  40107. }
  40108. /**
  40109. * XR input used to track XR inputs such as controllers/rays
  40110. */
  40111. export class WebXRInput implements IDisposable {
  40112. private helper;
  40113. /**
  40114. * XR controllers being tracked
  40115. */
  40116. controllers: Array<WebXRController>;
  40117. private _tmpMatrix;
  40118. private _frameObserver;
  40119. /**
  40120. * Initializes the WebXRInput
  40121. * @param helper experience helper which the input should be created for
  40122. */
  40123. constructor(helper: WebXRExperienceHelper);
  40124. /**
  40125. * Disposes of the object
  40126. */
  40127. dispose(): void;
  40128. }
  40129. }
  40130. declare module BABYLON {
  40131. /**
  40132. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40133. */
  40134. export class WebXRManagedOutputCanvas implements IDisposable {
  40135. private _canvas;
  40136. /**
  40137. * xrpresent context of the canvas which can be used to display/mirror xr content
  40138. */
  40139. canvasContext: Nullable<WebGLRenderingContext>;
  40140. /**
  40141. * Initializes the canvas to be added/removed upon entering/exiting xr
  40142. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40143. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40144. */
  40145. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40146. /**
  40147. * Disposes of the object
  40148. */
  40149. dispose(): void;
  40150. private _setManagedOutputCanvas;
  40151. private _addCanvas;
  40152. private _removeCanvas;
  40153. }
  40154. }
  40155. declare module BABYLON {
  40156. /**
  40157. * Contains an array of blocks representing the octree
  40158. */
  40159. export interface IOctreeContainer<T> {
  40160. /**
  40161. * Blocks within the octree
  40162. */
  40163. blocks: Array<OctreeBlock<T>>;
  40164. }
  40165. /**
  40166. * Class used to store a cell in an octree
  40167. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40168. */
  40169. export class OctreeBlock<T> {
  40170. /**
  40171. * Gets the content of the current block
  40172. */
  40173. entries: T[];
  40174. /**
  40175. * Gets the list of block children
  40176. */
  40177. blocks: Array<OctreeBlock<T>>;
  40178. private _depth;
  40179. private _maxDepth;
  40180. private _capacity;
  40181. private _minPoint;
  40182. private _maxPoint;
  40183. private _boundingVectors;
  40184. private _creationFunc;
  40185. /**
  40186. * Creates a new block
  40187. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40188. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40189. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40190. * @param depth defines the current depth of this block in the octree
  40191. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40192. * @param creationFunc defines a callback to call when an element is added to the block
  40193. */
  40194. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40195. /**
  40196. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40197. */
  40198. readonly capacity: number;
  40199. /**
  40200. * Gets the minimum vector (in world space) of the block's bounding box
  40201. */
  40202. readonly minPoint: Vector3;
  40203. /**
  40204. * Gets the maximum vector (in world space) of the block's bounding box
  40205. */
  40206. readonly maxPoint: Vector3;
  40207. /**
  40208. * Add a new element to this block
  40209. * @param entry defines the element to add
  40210. */
  40211. addEntry(entry: T): void;
  40212. /**
  40213. * Remove an element from this block
  40214. * @param entry defines the element to remove
  40215. */
  40216. removeEntry(entry: T): void;
  40217. /**
  40218. * Add an array of elements to this block
  40219. * @param entries defines the array of elements to add
  40220. */
  40221. addEntries(entries: T[]): void;
  40222. /**
  40223. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40224. * @param frustumPlanes defines the frustum planes to test
  40225. * @param selection defines the array to store current content if selection is positive
  40226. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40227. */
  40228. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40229. /**
  40230. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40231. * @param sphereCenter defines the bounding sphere center
  40232. * @param sphereRadius defines the bounding sphere radius
  40233. * @param selection defines the array to store current content if selection is positive
  40234. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40235. */
  40236. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40237. /**
  40238. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40239. * @param ray defines the ray to test with
  40240. * @param selection defines the array to store current content if selection is positive
  40241. */
  40242. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40243. /**
  40244. * Subdivide the content into child blocks (this block will then be empty)
  40245. */
  40246. createInnerBlocks(): void;
  40247. /**
  40248. * @hidden
  40249. */
  40250. 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;
  40251. }
  40252. }
  40253. declare module BABYLON {
  40254. /**
  40255. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40256. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40257. */
  40258. export class Octree<T> {
  40259. /** 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.) */
  40260. maxDepth: number;
  40261. /**
  40262. * Blocks within the octree containing objects
  40263. */
  40264. blocks: Array<OctreeBlock<T>>;
  40265. /**
  40266. * Content stored in the octree
  40267. */
  40268. dynamicContent: T[];
  40269. private _maxBlockCapacity;
  40270. private _selectionContent;
  40271. private _creationFunc;
  40272. /**
  40273. * Creates a octree
  40274. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40275. * @param creationFunc function to be used to instatiate the octree
  40276. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40277. * @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.)
  40278. */
  40279. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40280. /** 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.) */
  40281. maxDepth?: number);
  40282. /**
  40283. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40284. * @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);
  40285. * @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);
  40286. * @param entries meshes to be added to the octree blocks
  40287. */
  40288. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40289. /**
  40290. * Adds a mesh to the octree
  40291. * @param entry Mesh to add to the octree
  40292. */
  40293. addMesh(entry: T): void;
  40294. /**
  40295. * Remove an element from the octree
  40296. * @param entry defines the element to remove
  40297. */
  40298. removeMesh(entry: T): void;
  40299. /**
  40300. * Selects an array of meshes within the frustum
  40301. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40302. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40303. * @returns array of meshes within the frustum
  40304. */
  40305. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40306. /**
  40307. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40308. * @param sphereCenter defines the bounding sphere center
  40309. * @param sphereRadius defines the bounding sphere radius
  40310. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40311. * @returns an array of objects that intersect the sphere
  40312. */
  40313. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40314. /**
  40315. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40316. * @param ray defines the ray to test with
  40317. * @returns array of intersected objects
  40318. */
  40319. intersectsRay(ray: Ray): SmartArray<T>;
  40320. /**
  40321. * Adds a mesh into the octree block if it intersects the block
  40322. */
  40323. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40324. /**
  40325. * Adds a submesh into the octree block if it intersects the block
  40326. */
  40327. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40328. }
  40329. }
  40330. declare module BABYLON {
  40331. interface Scene {
  40332. /**
  40333. * @hidden
  40334. * Backing Filed
  40335. */
  40336. _selectionOctree: Octree<AbstractMesh>;
  40337. /**
  40338. * Gets the octree used to boost mesh selection (picking)
  40339. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40340. */
  40341. selectionOctree: Octree<AbstractMesh>;
  40342. /**
  40343. * Creates or updates the octree used to boost selection (picking)
  40344. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40345. * @param maxCapacity defines the maximum capacity per leaf
  40346. * @param maxDepth defines the maximum depth of the octree
  40347. * @returns an octree of AbstractMesh
  40348. */
  40349. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40350. }
  40351. interface AbstractMesh {
  40352. /**
  40353. * @hidden
  40354. * Backing Field
  40355. */
  40356. _submeshesOctree: Octree<SubMesh>;
  40357. /**
  40358. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40359. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40360. * @param maxCapacity defines the maximum size of each block (64 by default)
  40361. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40362. * @returns the new octree
  40363. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40364. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40365. */
  40366. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40367. }
  40368. /**
  40369. * Defines the octree scene component responsible to manage any octrees
  40370. * in a given scene.
  40371. */
  40372. export class OctreeSceneComponent {
  40373. /**
  40374. * The component name helpfull to identify the component in the list of scene components.
  40375. */
  40376. readonly name: string;
  40377. /**
  40378. * The scene the component belongs to.
  40379. */
  40380. scene: Scene;
  40381. /**
  40382. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40383. */
  40384. readonly checksIsEnabled: boolean;
  40385. /**
  40386. * Creates a new instance of the component for the given scene
  40387. * @param scene Defines the scene to register the component in
  40388. */
  40389. constructor(scene: Scene);
  40390. /**
  40391. * Registers the component in a given scene
  40392. */
  40393. register(): void;
  40394. /**
  40395. * Return the list of active meshes
  40396. * @returns the list of active meshes
  40397. */
  40398. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40399. /**
  40400. * Return the list of active sub meshes
  40401. * @param mesh The mesh to get the candidates sub meshes from
  40402. * @returns the list of active sub meshes
  40403. */
  40404. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40405. private _tempRay;
  40406. /**
  40407. * Return the list of sub meshes intersecting with a given local ray
  40408. * @param mesh defines the mesh to find the submesh for
  40409. * @param localRay defines the ray in local space
  40410. * @returns the list of intersecting sub meshes
  40411. */
  40412. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40413. /**
  40414. * Return the list of sub meshes colliding with a collider
  40415. * @param mesh defines the mesh to find the submesh for
  40416. * @param collider defines the collider to evaluate the collision against
  40417. * @returns the list of colliding sub meshes
  40418. */
  40419. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40420. /**
  40421. * Rebuilds the elements related to this component in case of
  40422. * context lost for instance.
  40423. */
  40424. rebuild(): void;
  40425. /**
  40426. * Disposes the component and the associated ressources.
  40427. */
  40428. dispose(): void;
  40429. }
  40430. }
  40431. declare module BABYLON {
  40432. /**
  40433. * Renders a layer on top of an existing scene
  40434. */
  40435. export class UtilityLayerRenderer implements IDisposable {
  40436. /** the original scene that will be rendered on top of */
  40437. originalScene: Scene;
  40438. private _pointerCaptures;
  40439. private _lastPointerEvents;
  40440. private static _DefaultUtilityLayer;
  40441. private static _DefaultKeepDepthUtilityLayer;
  40442. private _sharedGizmoLight;
  40443. /**
  40444. * @hidden
  40445. * Light which used by gizmos to get light shading
  40446. */
  40447. _getSharedGizmoLight(): HemisphericLight;
  40448. /**
  40449. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40450. */
  40451. pickUtilitySceneFirst: boolean;
  40452. /**
  40453. * 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)
  40454. */
  40455. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40456. /**
  40457. * 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)
  40458. */
  40459. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40460. /**
  40461. * The scene that is rendered on top of the original scene
  40462. */
  40463. utilityLayerScene: Scene;
  40464. /**
  40465. * If the utility layer should automatically be rendered on top of existing scene
  40466. */
  40467. shouldRender: boolean;
  40468. /**
  40469. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40470. */
  40471. onlyCheckPointerDownEvents: boolean;
  40472. /**
  40473. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40474. */
  40475. processAllEvents: boolean;
  40476. /**
  40477. * Observable raised when the pointer move from the utility layer scene to the main scene
  40478. */
  40479. onPointerOutObservable: Observable<number>;
  40480. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40481. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40482. private _afterRenderObserver;
  40483. private _sceneDisposeObserver;
  40484. private _originalPointerObserver;
  40485. /**
  40486. * Instantiates a UtilityLayerRenderer
  40487. * @param originalScene the original scene that will be rendered on top of
  40488. * @param handleEvents boolean indicating if the utility layer should handle events
  40489. */
  40490. constructor(
  40491. /** the original scene that will be rendered on top of */
  40492. originalScene: Scene, handleEvents?: boolean);
  40493. private _notifyObservers;
  40494. /**
  40495. * Renders the utility layers scene on top of the original scene
  40496. */
  40497. render(): void;
  40498. /**
  40499. * Disposes of the renderer
  40500. */
  40501. dispose(): void;
  40502. private _updateCamera;
  40503. }
  40504. }
  40505. declare module BABYLON {
  40506. /**
  40507. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40508. */
  40509. export class Gizmo implements IDisposable {
  40510. /** The utility layer the gizmo will be added to */
  40511. gizmoLayer: UtilityLayerRenderer;
  40512. /**
  40513. * The root mesh of the gizmo
  40514. */
  40515. _rootMesh: Mesh;
  40516. private _attachedMesh;
  40517. /**
  40518. * Ratio for the scale of the gizmo (Default: 1)
  40519. */
  40520. scaleRatio: number;
  40521. /**
  40522. * If a custom mesh has been set (Default: false)
  40523. */
  40524. protected _customMeshSet: boolean;
  40525. /**
  40526. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40527. * * When set, interactions will be enabled
  40528. */
  40529. attachedMesh: Nullable<AbstractMesh>;
  40530. /**
  40531. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40532. * @param mesh The mesh to replace the default mesh of the gizmo
  40533. */
  40534. setCustomMesh(mesh: Mesh): void;
  40535. /**
  40536. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40537. */
  40538. updateGizmoRotationToMatchAttachedMesh: boolean;
  40539. /**
  40540. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40541. */
  40542. updateGizmoPositionToMatchAttachedMesh: boolean;
  40543. /**
  40544. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40545. */
  40546. protected _updateScale: boolean;
  40547. protected _interactionsEnabled: boolean;
  40548. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40549. private _beforeRenderObserver;
  40550. private _tempVector;
  40551. /**
  40552. * Creates a gizmo
  40553. * @param gizmoLayer The utility layer the gizmo will be added to
  40554. */
  40555. constructor(
  40556. /** The utility layer the gizmo will be added to */
  40557. gizmoLayer?: UtilityLayerRenderer);
  40558. /**
  40559. * Updates the gizmo to match the attached mesh's position/rotation
  40560. */
  40561. protected _update(): void;
  40562. /**
  40563. * Disposes of the gizmo
  40564. */
  40565. dispose(): void;
  40566. }
  40567. }
  40568. declare module BABYLON {
  40569. /**
  40570. * Single axis drag gizmo
  40571. */
  40572. export class AxisDragGizmo extends Gizmo {
  40573. /**
  40574. * Drag behavior responsible for the gizmos dragging interactions
  40575. */
  40576. dragBehavior: PointerDragBehavior;
  40577. private _pointerObserver;
  40578. /**
  40579. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40580. */
  40581. snapDistance: number;
  40582. /**
  40583. * Event that fires each time the gizmo snaps to a new location.
  40584. * * snapDistance is the the change in distance
  40585. */
  40586. onSnapObservable: Observable<{
  40587. snapDistance: number;
  40588. }>;
  40589. /** @hidden */
  40590. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40591. /** @hidden */
  40592. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40593. /**
  40594. * Creates an AxisDragGizmo
  40595. * @param gizmoLayer The utility layer the gizmo will be added to
  40596. * @param dragAxis The axis which the gizmo will be able to drag on
  40597. * @param color The color of the gizmo
  40598. */
  40599. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40600. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40601. /**
  40602. * Disposes of the gizmo
  40603. */
  40604. dispose(): void;
  40605. }
  40606. }
  40607. declare module BABYLON.Debug {
  40608. /**
  40609. * The Axes viewer will show 3 axes in a specific point in space
  40610. */
  40611. export class AxesViewer {
  40612. private _xAxis;
  40613. private _yAxis;
  40614. private _zAxis;
  40615. private _scaleLinesFactor;
  40616. private _instanced;
  40617. /**
  40618. * Gets the hosting scene
  40619. */
  40620. scene: Scene;
  40621. /**
  40622. * Gets or sets a number used to scale line length
  40623. */
  40624. scaleLines: number;
  40625. /** Gets the node hierarchy used to render x-axis */
  40626. readonly xAxis: TransformNode;
  40627. /** Gets the node hierarchy used to render y-axis */
  40628. readonly yAxis: TransformNode;
  40629. /** Gets the node hierarchy used to render z-axis */
  40630. readonly zAxis: TransformNode;
  40631. /**
  40632. * Creates a new AxesViewer
  40633. * @param scene defines the hosting scene
  40634. * @param scaleLines defines a number used to scale line length (1 by default)
  40635. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40636. * @param xAxis defines the node hierarchy used to render the x-axis
  40637. * @param yAxis defines the node hierarchy used to render the y-axis
  40638. * @param zAxis defines the node hierarchy used to render the z-axis
  40639. */
  40640. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40641. /**
  40642. * Force the viewer to update
  40643. * @param position defines the position of the viewer
  40644. * @param xaxis defines the x axis of the viewer
  40645. * @param yaxis defines the y axis of the viewer
  40646. * @param zaxis defines the z axis of the viewer
  40647. */
  40648. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40649. /**
  40650. * Creates an instance of this axes viewer.
  40651. * @returns a new axes viewer with instanced meshes
  40652. */
  40653. createInstance(): AxesViewer;
  40654. /** Releases resources */
  40655. dispose(): void;
  40656. private static _SetRenderingGroupId;
  40657. }
  40658. }
  40659. declare module BABYLON.Debug {
  40660. /**
  40661. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40662. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40663. */
  40664. export class BoneAxesViewer extends AxesViewer {
  40665. /**
  40666. * Gets or sets the target mesh where to display the axes viewer
  40667. */
  40668. mesh: Nullable<Mesh>;
  40669. /**
  40670. * Gets or sets the target bone where to display the axes viewer
  40671. */
  40672. bone: Nullable<Bone>;
  40673. /** Gets current position */
  40674. pos: Vector3;
  40675. /** Gets direction of X axis */
  40676. xaxis: Vector3;
  40677. /** Gets direction of Y axis */
  40678. yaxis: Vector3;
  40679. /** Gets direction of Z axis */
  40680. zaxis: Vector3;
  40681. /**
  40682. * Creates a new BoneAxesViewer
  40683. * @param scene defines the hosting scene
  40684. * @param bone defines the target bone
  40685. * @param mesh defines the target mesh
  40686. * @param scaleLines defines a scaling factor for line length (1 by default)
  40687. */
  40688. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40689. /**
  40690. * Force the viewer to update
  40691. */
  40692. update(): void;
  40693. /** Releases resources */
  40694. dispose(): void;
  40695. }
  40696. }
  40697. declare module BABYLON {
  40698. /**
  40699. * Interface used to define scene explorer extensibility option
  40700. */
  40701. export interface IExplorerExtensibilityOption {
  40702. /**
  40703. * Define the option label
  40704. */
  40705. label: string;
  40706. /**
  40707. * Defines the action to execute on click
  40708. */
  40709. action: (entity: any) => void;
  40710. }
  40711. /**
  40712. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40713. */
  40714. export interface IExplorerExtensibilityGroup {
  40715. /**
  40716. * Defines a predicate to test if a given type mut be extended
  40717. */
  40718. predicate: (entity: any) => boolean;
  40719. /**
  40720. * Gets the list of options added to a type
  40721. */
  40722. entries: IExplorerExtensibilityOption[];
  40723. }
  40724. /**
  40725. * Interface used to define the options to use to create the Inspector
  40726. */
  40727. export interface IInspectorOptions {
  40728. /**
  40729. * Display in overlay mode (default: false)
  40730. */
  40731. overlay?: boolean;
  40732. /**
  40733. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40734. */
  40735. globalRoot?: HTMLElement;
  40736. /**
  40737. * Display the Scene explorer
  40738. */
  40739. showExplorer?: boolean;
  40740. /**
  40741. * Display the property inspector
  40742. */
  40743. showInspector?: boolean;
  40744. /**
  40745. * Display in embed mode (both panes on the right)
  40746. */
  40747. embedMode?: boolean;
  40748. /**
  40749. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40750. */
  40751. handleResize?: boolean;
  40752. /**
  40753. * Allow the panes to popup (default: true)
  40754. */
  40755. enablePopup?: boolean;
  40756. /**
  40757. * Allow the panes to be closed by users (default: true)
  40758. */
  40759. enableClose?: boolean;
  40760. /**
  40761. * Optional list of extensibility entries
  40762. */
  40763. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40764. /**
  40765. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40766. */
  40767. inspectorURL?: string;
  40768. }
  40769. interface Scene {
  40770. /**
  40771. * @hidden
  40772. * Backing field
  40773. */
  40774. _debugLayer: DebugLayer;
  40775. /**
  40776. * Gets the debug layer (aka Inspector) associated with the scene
  40777. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40778. */
  40779. debugLayer: DebugLayer;
  40780. }
  40781. /**
  40782. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40783. * what is happening in your scene
  40784. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40785. */
  40786. export class DebugLayer {
  40787. /**
  40788. * Define the url to get the inspector script from.
  40789. * By default it uses the babylonjs CDN.
  40790. * @ignoreNaming
  40791. */
  40792. static InspectorURL: string;
  40793. private _scene;
  40794. private BJSINSPECTOR;
  40795. /**
  40796. * Observable triggered when a property is changed through the inspector.
  40797. */
  40798. onPropertyChangedObservable: Observable<{
  40799. object: any;
  40800. property: string;
  40801. value: any;
  40802. initialValue: any;
  40803. }>;
  40804. /**
  40805. * Instantiates a new debug layer.
  40806. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40807. * what is happening in your scene
  40808. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40809. * @param scene Defines the scene to inspect
  40810. */
  40811. constructor(scene: Scene);
  40812. /** Creates the inspector window. */
  40813. private _createInspector;
  40814. /**
  40815. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40816. * @param entity defines the entity to select
  40817. * @param lineContainerTitle defines the specific block to highlight
  40818. */
  40819. select(entity: any, lineContainerTitle?: string): void;
  40820. /** Get the inspector from bundle or global */
  40821. private _getGlobalInspector;
  40822. /**
  40823. * Get if the inspector is visible or not.
  40824. * @returns true if visible otherwise, false
  40825. */
  40826. isVisible(): boolean;
  40827. /**
  40828. * Hide the inspector and close its window.
  40829. */
  40830. hide(): void;
  40831. /**
  40832. * Launch the debugLayer.
  40833. * @param config Define the configuration of the inspector
  40834. * @return a promise fulfilled when the debug layer is visible
  40835. */
  40836. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40837. }
  40838. }
  40839. declare module BABYLON {
  40840. /**
  40841. * Class containing static functions to help procedurally build meshes
  40842. */
  40843. export class BoxBuilder {
  40844. /**
  40845. * Creates a box mesh
  40846. * * The parameter `size` sets the size (float) of each box side (default 1)
  40847. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40848. * * 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)
  40849. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40851. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40853. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40854. * @param name defines the name of the mesh
  40855. * @param options defines the options used to create the mesh
  40856. * @param scene defines the hosting scene
  40857. * @returns the box mesh
  40858. */
  40859. static CreateBox(name: string, options: {
  40860. size?: number;
  40861. width?: number;
  40862. height?: number;
  40863. depth?: number;
  40864. faceUV?: Vector4[];
  40865. faceColors?: Color4[];
  40866. sideOrientation?: number;
  40867. frontUVs?: Vector4;
  40868. backUVs?: Vector4;
  40869. wrap?: boolean;
  40870. topBaseAt?: number;
  40871. bottomBaseAt?: number;
  40872. updatable?: boolean;
  40873. }, scene?: Nullable<Scene>): Mesh;
  40874. }
  40875. }
  40876. declare module BABYLON {
  40877. /**
  40878. * Class containing static functions to help procedurally build meshes
  40879. */
  40880. export class SphereBuilder {
  40881. /**
  40882. * Creates a sphere mesh
  40883. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40884. * * 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`)
  40885. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40886. * * 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
  40887. * * 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)
  40888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40891. * @param name defines the name of the mesh
  40892. * @param options defines the options used to create the mesh
  40893. * @param scene defines the hosting scene
  40894. * @returns the sphere mesh
  40895. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40896. */
  40897. static CreateSphere(name: string, options: {
  40898. segments?: number;
  40899. diameter?: number;
  40900. diameterX?: number;
  40901. diameterY?: number;
  40902. diameterZ?: number;
  40903. arc?: number;
  40904. slice?: number;
  40905. sideOrientation?: number;
  40906. frontUVs?: Vector4;
  40907. backUVs?: Vector4;
  40908. updatable?: boolean;
  40909. }, scene: any): Mesh;
  40910. }
  40911. }
  40912. declare module BABYLON.Debug {
  40913. /**
  40914. * Used to show the physics impostor around the specific mesh
  40915. */
  40916. export class PhysicsViewer {
  40917. /** @hidden */
  40918. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40919. /** @hidden */
  40920. protected _meshes: Array<Nullable<AbstractMesh>>;
  40921. /** @hidden */
  40922. protected _scene: Nullable<Scene>;
  40923. /** @hidden */
  40924. protected _numMeshes: number;
  40925. /** @hidden */
  40926. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40927. private _renderFunction;
  40928. private _utilityLayer;
  40929. private _debugBoxMesh;
  40930. private _debugSphereMesh;
  40931. private _debugCylinderMesh;
  40932. private _debugMaterial;
  40933. private _debugMeshMeshes;
  40934. /**
  40935. * Creates a new PhysicsViewer
  40936. * @param scene defines the hosting scene
  40937. */
  40938. constructor(scene: Scene);
  40939. /** @hidden */
  40940. protected _updateDebugMeshes(): void;
  40941. /**
  40942. * Renders a specified physic impostor
  40943. * @param impostor defines the impostor to render
  40944. * @param targetMesh defines the mesh represented by the impostor
  40945. * @returns the new debug mesh used to render the impostor
  40946. */
  40947. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40948. /**
  40949. * Hides a specified physic impostor
  40950. * @param impostor defines the impostor to hide
  40951. */
  40952. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40953. private _getDebugMaterial;
  40954. private _getDebugBoxMesh;
  40955. private _getDebugSphereMesh;
  40956. private _getDebugCylinderMesh;
  40957. private _getDebugMeshMesh;
  40958. private _getDebugMesh;
  40959. /** Releases all resources */
  40960. dispose(): void;
  40961. }
  40962. }
  40963. declare module BABYLON {
  40964. /**
  40965. * Class containing static functions to help procedurally build meshes
  40966. */
  40967. export class LinesBuilder {
  40968. /**
  40969. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40970. * * 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
  40971. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40972. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40973. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40974. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40975. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40976. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  40977. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40979. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40980. * @param name defines the name of the new line system
  40981. * @param options defines the options used to create the line system
  40982. * @param scene defines the hosting scene
  40983. * @returns a new line system mesh
  40984. */
  40985. static CreateLineSystem(name: string, options: {
  40986. lines: Vector3[][];
  40987. updatable?: boolean;
  40988. instance?: Nullable<LinesMesh>;
  40989. colors?: Nullable<Color4[][]>;
  40990. useVertexAlpha?: boolean;
  40991. }, scene: Nullable<Scene>): LinesMesh;
  40992. /**
  40993. * Creates a line mesh
  40994. * 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
  40995. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40996. * * The parameter `points` is an array successive Vector3
  40997. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  40998. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40999. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41000. * * When updating an instance, remember that only point positions can change, not the number of points
  41001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41002. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41003. * @param name defines the name of the new line system
  41004. * @param options defines the options used to create the line system
  41005. * @param scene defines the hosting scene
  41006. * @returns a new line mesh
  41007. */
  41008. static CreateLines(name: string, options: {
  41009. points: Vector3[];
  41010. updatable?: boolean;
  41011. instance?: Nullable<LinesMesh>;
  41012. colors?: Color4[];
  41013. useVertexAlpha?: boolean;
  41014. }, scene?: Nullable<Scene>): LinesMesh;
  41015. /**
  41016. * Creates a dashed line mesh
  41017. * * 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
  41018. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41019. * * The parameter `points` is an array successive Vector3
  41020. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41021. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41022. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41023. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  41024. * * When updating an instance, remember that only point positions can change, not the number of points
  41025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41026. * @param name defines the name of the mesh
  41027. * @param options defines the options used to create the mesh
  41028. * @param scene defines the hosting scene
  41029. * @returns the dashed line mesh
  41030. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41031. */
  41032. static CreateDashedLines(name: string, options: {
  41033. points: Vector3[];
  41034. dashSize?: number;
  41035. gapSize?: number;
  41036. dashNb?: number;
  41037. updatable?: boolean;
  41038. instance?: LinesMesh;
  41039. }, scene?: Nullable<Scene>): LinesMesh;
  41040. }
  41041. }
  41042. declare module BABYLON {
  41043. /**
  41044. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41045. * in order to better appreciate the issue one might have.
  41046. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41047. */
  41048. export class RayHelper {
  41049. /**
  41050. * Defines the ray we are currently tryin to visualize.
  41051. */
  41052. ray: Nullable<Ray>;
  41053. private _renderPoints;
  41054. private _renderLine;
  41055. private _renderFunction;
  41056. private _scene;
  41057. private _updateToMeshFunction;
  41058. private _attachedToMesh;
  41059. private _meshSpaceDirection;
  41060. private _meshSpaceOrigin;
  41061. /**
  41062. * Helper function to create a colored helper in a scene in one line.
  41063. * @param ray Defines the ray we are currently tryin to visualize
  41064. * @param scene Defines the scene the ray is used in
  41065. * @param color Defines the color we want to see the ray in
  41066. * @returns The newly created ray helper.
  41067. */
  41068. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41069. /**
  41070. * Instantiate a new ray helper.
  41071. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41072. * in order to better appreciate the issue one might have.
  41073. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41074. * @param ray Defines the ray we are currently tryin to visualize
  41075. */
  41076. constructor(ray: Ray);
  41077. /**
  41078. * Shows the ray we are willing to debug.
  41079. * @param scene Defines the scene the ray needs to be rendered in
  41080. * @param color Defines the color the ray needs to be rendered in
  41081. */
  41082. show(scene: Scene, color?: Color3): void;
  41083. /**
  41084. * Hides the ray we are debugging.
  41085. */
  41086. hide(): void;
  41087. private _render;
  41088. /**
  41089. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41090. * @param mesh Defines the mesh we want the helper attached to
  41091. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41092. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41093. * @param length Defines the length of the ray
  41094. */
  41095. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41096. /**
  41097. * Detach the ray helper from the mesh it has previously been attached to.
  41098. */
  41099. detachFromMesh(): void;
  41100. private _updateToMesh;
  41101. /**
  41102. * Dispose the helper and release its associated resources.
  41103. */
  41104. dispose(): void;
  41105. }
  41106. }
  41107. declare module BABYLON.Debug {
  41108. /**
  41109. * Class used to render a debug view of a given skeleton
  41110. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41111. */
  41112. export class SkeletonViewer {
  41113. /** defines the skeleton to render */
  41114. skeleton: Skeleton;
  41115. /** defines the mesh attached to the skeleton */
  41116. mesh: AbstractMesh;
  41117. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41118. autoUpdateBonesMatrices: boolean;
  41119. /** defines the rendering group id to use with the viewer */
  41120. renderingGroupId: number;
  41121. /** Gets or sets the color used to render the skeleton */
  41122. color: Color3;
  41123. private _scene;
  41124. private _debugLines;
  41125. private _debugMesh;
  41126. private _isEnabled;
  41127. private _renderFunction;
  41128. private _utilityLayer;
  41129. /**
  41130. * Returns the mesh used to render the bones
  41131. */
  41132. readonly debugMesh: Nullable<LinesMesh>;
  41133. /**
  41134. * Creates a new SkeletonViewer
  41135. * @param skeleton defines the skeleton to render
  41136. * @param mesh defines the mesh attached to the skeleton
  41137. * @param scene defines the hosting scene
  41138. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41139. * @param renderingGroupId defines the rendering group id to use with the viewer
  41140. */
  41141. constructor(
  41142. /** defines the skeleton to render */
  41143. skeleton: Skeleton,
  41144. /** defines the mesh attached to the skeleton */
  41145. mesh: AbstractMesh, scene: Scene,
  41146. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41147. autoUpdateBonesMatrices?: boolean,
  41148. /** defines the rendering group id to use with the viewer */
  41149. renderingGroupId?: number);
  41150. /** Gets or sets a boolean indicating if the viewer is enabled */
  41151. isEnabled: boolean;
  41152. private _getBonePosition;
  41153. private _getLinesForBonesWithLength;
  41154. private _getLinesForBonesNoLength;
  41155. /** Update the viewer to sync with current skeleton state */
  41156. update(): void;
  41157. /** Release associated resources */
  41158. dispose(): void;
  41159. }
  41160. }
  41161. declare module BABYLON {
  41162. /**
  41163. * Options to create the null engine
  41164. */
  41165. export class NullEngineOptions {
  41166. /**
  41167. * Render width (Default: 512)
  41168. */
  41169. renderWidth: number;
  41170. /**
  41171. * Render height (Default: 256)
  41172. */
  41173. renderHeight: number;
  41174. /**
  41175. * Texture size (Default: 512)
  41176. */
  41177. textureSize: number;
  41178. /**
  41179. * If delta time between frames should be constant
  41180. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41181. */
  41182. deterministicLockstep: boolean;
  41183. /**
  41184. * Maximum about of steps between frames (Default: 4)
  41185. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41186. */
  41187. lockstepMaxSteps: number;
  41188. }
  41189. /**
  41190. * The null engine class provides support for headless version of babylon.js.
  41191. * This can be used in server side scenario or for testing purposes
  41192. */
  41193. export class NullEngine extends Engine {
  41194. private _options;
  41195. /**
  41196. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41197. */
  41198. isDeterministicLockStep(): boolean;
  41199. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41200. getLockstepMaxSteps(): number;
  41201. /**
  41202. * Sets hardware scaling, used to save performance if needed
  41203. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41204. */
  41205. getHardwareScalingLevel(): number;
  41206. constructor(options?: NullEngineOptions);
  41207. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41208. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41209. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41210. getRenderWidth(useScreen?: boolean): number;
  41211. getRenderHeight(useScreen?: boolean): number;
  41212. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41213. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41214. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41215. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41216. bindSamplers(effect: Effect): void;
  41217. enableEffect(effect: Effect): void;
  41218. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41219. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41220. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41221. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41222. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41223. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41224. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41225. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41226. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41227. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41228. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41229. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41230. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41231. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41232. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41233. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41234. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41235. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41236. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41237. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41238. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41239. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41240. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41241. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41242. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41243. bindBuffers(vertexBuffers: {
  41244. [key: string]: VertexBuffer;
  41245. }, indexBuffer: DataBuffer, effect: Effect): void;
  41246. wipeCaches(bruteForce?: boolean): void;
  41247. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41248. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41249. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41250. /** @hidden */
  41251. _createTexture(): WebGLTexture;
  41252. /** @hidden */
  41253. _releaseTexture(texture: InternalTexture): void;
  41254. 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;
  41255. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41256. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41257. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41258. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41259. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  41260. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41261. areAllEffectsReady(): boolean;
  41262. /**
  41263. * @hidden
  41264. * Get the current error code of the webGL context
  41265. * @returns the error code
  41266. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41267. */
  41268. getError(): number;
  41269. /** @hidden */
  41270. _getUnpackAlignement(): number;
  41271. /** @hidden */
  41272. _unpackFlipY(value: boolean): void;
  41273. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41274. /**
  41275. * Updates a dynamic vertex buffer.
  41276. * @param vertexBuffer the vertex buffer to update
  41277. * @param data the data used to update the vertex buffer
  41278. * @param byteOffset the byte offset of the data (optional)
  41279. * @param byteLength the byte length of the data (optional)
  41280. */
  41281. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41282. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41283. /** @hidden */
  41284. _bindTexture(channel: number, texture: InternalTexture): void;
  41285. /** @hidden */
  41286. _releaseBuffer(buffer: DataBuffer): boolean;
  41287. releaseEffects(): void;
  41288. displayLoadingUI(): void;
  41289. hideLoadingUI(): void;
  41290. /** @hidden */
  41291. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41292. /** @hidden */
  41293. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41294. /** @hidden */
  41295. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41296. /** @hidden */
  41297. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41298. }
  41299. }
  41300. declare module BABYLON {
  41301. /** @hidden */
  41302. export class _OcclusionDataStorage {
  41303. /** @hidden */
  41304. occlusionInternalRetryCounter: number;
  41305. /** @hidden */
  41306. isOcclusionQueryInProgress: boolean;
  41307. /** @hidden */
  41308. isOccluded: boolean;
  41309. /** @hidden */
  41310. occlusionRetryCount: number;
  41311. /** @hidden */
  41312. occlusionType: number;
  41313. /** @hidden */
  41314. occlusionQueryAlgorithmType: number;
  41315. }
  41316. interface Engine {
  41317. /**
  41318. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41319. * @return the new query
  41320. */
  41321. createQuery(): WebGLQuery;
  41322. /**
  41323. * Delete and release a webGL query
  41324. * @param query defines the query to delete
  41325. * @return the current engine
  41326. */
  41327. deleteQuery(query: WebGLQuery): Engine;
  41328. /**
  41329. * Check if a given query has resolved and got its value
  41330. * @param query defines the query to check
  41331. * @returns true if the query got its value
  41332. */
  41333. isQueryResultAvailable(query: WebGLQuery): boolean;
  41334. /**
  41335. * Gets the value of a given query
  41336. * @param query defines the query to check
  41337. * @returns the value of the query
  41338. */
  41339. getQueryResult(query: WebGLQuery): number;
  41340. /**
  41341. * Initiates an occlusion query
  41342. * @param algorithmType defines the algorithm to use
  41343. * @param query defines the query to use
  41344. * @returns the current engine
  41345. * @see http://doc.babylonjs.com/features/occlusionquery
  41346. */
  41347. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41348. /**
  41349. * Ends an occlusion query
  41350. * @see http://doc.babylonjs.com/features/occlusionquery
  41351. * @param algorithmType defines the algorithm to use
  41352. * @returns the current engine
  41353. */
  41354. endOcclusionQuery(algorithmType: number): Engine;
  41355. /**
  41356. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41357. * Please note that only one query can be issued at a time
  41358. * @returns a time token used to track the time span
  41359. */
  41360. startTimeQuery(): Nullable<_TimeToken>;
  41361. /**
  41362. * Ends a time query
  41363. * @param token defines the token used to measure the time span
  41364. * @returns the time spent (in ns)
  41365. */
  41366. endTimeQuery(token: _TimeToken): int;
  41367. /** @hidden */
  41368. _currentNonTimestampToken: Nullable<_TimeToken>;
  41369. /** @hidden */
  41370. _createTimeQuery(): WebGLQuery;
  41371. /** @hidden */
  41372. _deleteTimeQuery(query: WebGLQuery): void;
  41373. /** @hidden */
  41374. _getGlAlgorithmType(algorithmType: number): number;
  41375. /** @hidden */
  41376. _getTimeQueryResult(query: WebGLQuery): any;
  41377. /** @hidden */
  41378. _getTimeQueryAvailability(query: WebGLQuery): any;
  41379. }
  41380. interface AbstractMesh {
  41381. /**
  41382. * Backing filed
  41383. * @hidden
  41384. */
  41385. __occlusionDataStorage: _OcclusionDataStorage;
  41386. /**
  41387. * Access property
  41388. * @hidden
  41389. */
  41390. _occlusionDataStorage: _OcclusionDataStorage;
  41391. /**
  41392. * 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.
  41393. * The default value is -1 which means don't break the query and wait till the result
  41394. * @see http://doc.babylonjs.com/features/occlusionquery
  41395. */
  41396. occlusionRetryCount: number;
  41397. /**
  41398. * 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:
  41399. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41400. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41401. * * 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.
  41402. * @see http://doc.babylonjs.com/features/occlusionquery
  41403. */
  41404. occlusionType: number;
  41405. /**
  41406. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41407. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41408. * * 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.
  41409. * @see http://doc.babylonjs.com/features/occlusionquery
  41410. */
  41411. occlusionQueryAlgorithmType: number;
  41412. /**
  41413. * 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
  41414. * @see http://doc.babylonjs.com/features/occlusionquery
  41415. */
  41416. isOccluded: boolean;
  41417. /**
  41418. * Flag to check the progress status of the query
  41419. * @see http://doc.babylonjs.com/features/occlusionquery
  41420. */
  41421. isOcclusionQueryInProgress: boolean;
  41422. }
  41423. }
  41424. declare module BABYLON {
  41425. /** @hidden */
  41426. export var _forceTransformFeedbackToBundle: boolean;
  41427. interface Engine {
  41428. /**
  41429. * Creates a webGL transform feedback object
  41430. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41431. * @returns the webGL transform feedback object
  41432. */
  41433. createTransformFeedback(): WebGLTransformFeedback;
  41434. /**
  41435. * Delete a webGL transform feedback object
  41436. * @param value defines the webGL transform feedback object to delete
  41437. */
  41438. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41439. /**
  41440. * Bind a webGL transform feedback object to the webgl context
  41441. * @param value defines the webGL transform feedback object to bind
  41442. */
  41443. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41444. /**
  41445. * Begins a transform feedback operation
  41446. * @param usePoints defines if points or triangles must be used
  41447. */
  41448. beginTransformFeedback(usePoints: boolean): void;
  41449. /**
  41450. * Ends a transform feedback operation
  41451. */
  41452. endTransformFeedback(): void;
  41453. /**
  41454. * Specify the varyings to use with transform feedback
  41455. * @param program defines the associated webGL program
  41456. * @param value defines the list of strings representing the varying names
  41457. */
  41458. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41459. /**
  41460. * Bind a webGL buffer for a transform feedback operation
  41461. * @param value defines the webGL buffer to bind
  41462. */
  41463. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41464. }
  41465. }
  41466. declare module BABYLON {
  41467. /**
  41468. * Creation options of the multi render target texture.
  41469. */
  41470. export interface IMultiRenderTargetOptions {
  41471. /**
  41472. * Define if the texture needs to create mip maps after render.
  41473. */
  41474. generateMipMaps?: boolean;
  41475. /**
  41476. * Define the types of all the draw buffers we want to create
  41477. */
  41478. types?: number[];
  41479. /**
  41480. * Define the sampling modes of all the draw buffers we want to create
  41481. */
  41482. samplingModes?: number[];
  41483. /**
  41484. * Define if a depth buffer is required
  41485. */
  41486. generateDepthBuffer?: boolean;
  41487. /**
  41488. * Define if a stencil buffer is required
  41489. */
  41490. generateStencilBuffer?: boolean;
  41491. /**
  41492. * Define if a depth texture is required instead of a depth buffer
  41493. */
  41494. generateDepthTexture?: boolean;
  41495. /**
  41496. * Define the number of desired draw buffers
  41497. */
  41498. textureCount?: number;
  41499. /**
  41500. * Define if aspect ratio should be adapted to the texture or stay the scene one
  41501. */
  41502. doNotChangeAspectRatio?: boolean;
  41503. /**
  41504. * Define the default type of the buffers we are creating
  41505. */
  41506. defaultType?: number;
  41507. }
  41508. /**
  41509. * A multi render target, like a render target provides the ability to render to a texture.
  41510. * Unlike the render target, it can render to several draw buffers in one draw.
  41511. * This is specially interesting in deferred rendering or for any effects requiring more than
  41512. * just one color from a single pass.
  41513. */
  41514. export class MultiRenderTarget extends RenderTargetTexture {
  41515. private _internalTextures;
  41516. private _textures;
  41517. private _multiRenderTargetOptions;
  41518. /**
  41519. * Get if draw buffers are currently supported by the used hardware and browser.
  41520. */
  41521. readonly isSupported: boolean;
  41522. /**
  41523. * Get the list of textures generated by the multi render target.
  41524. */
  41525. readonly textures: Texture[];
  41526. /**
  41527. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  41528. */
  41529. readonly depthTexture: Texture;
  41530. /**
  41531. * Set the wrapping mode on U of all the textures we are rendering to.
  41532. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41533. */
  41534. wrapU: number;
  41535. /**
  41536. * Set the wrapping mode on V of all the textures we are rendering to.
  41537. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41538. */
  41539. wrapV: number;
  41540. /**
  41541. * Instantiate a new multi render target texture.
  41542. * A multi render target, like a render target provides the ability to render to a texture.
  41543. * Unlike the render target, it can render to several draw buffers in one draw.
  41544. * This is specially interesting in deferred rendering or for any effects requiring more than
  41545. * just one color from a single pass.
  41546. * @param name Define the name of the texture
  41547. * @param size Define the size of the buffers to render to
  41548. * @param count Define the number of target we are rendering into
  41549. * @param scene Define the scene the texture belongs to
  41550. * @param options Define the options used to create the multi render target
  41551. */
  41552. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41553. /** @hidden */
  41554. _rebuild(): void;
  41555. private _createInternalTextures;
  41556. private _createTextures;
  41557. /**
  41558. * Define the number of samples used if MSAA is enabled.
  41559. */
  41560. samples: number;
  41561. /**
  41562. * Resize all the textures in the multi render target.
  41563. * Be carrefull as it will recreate all the data in the new texture.
  41564. * @param size Define the new size
  41565. */
  41566. resize(size: any): void;
  41567. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41568. /**
  41569. * Dispose the render targets and their associated resources
  41570. */
  41571. dispose(): void;
  41572. /**
  41573. * Release all the underlying texture used as draw buffers.
  41574. */
  41575. releaseInternalTextures(): void;
  41576. }
  41577. }
  41578. declare module BABYLON {
  41579. interface Engine {
  41580. /**
  41581. * Unbind a list of render target textures from the webGL context
  41582. * This is used only when drawBuffer extension or webGL2 are active
  41583. * @param textures defines the render target textures to unbind
  41584. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41585. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41586. */
  41587. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41588. /**
  41589. * Create a multi render target texture
  41590. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41591. * @param size defines the size of the texture
  41592. * @param options defines the creation options
  41593. * @returns the cube texture as an InternalTexture
  41594. */
  41595. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41596. /**
  41597. * Update the sample count for a given multiple render target texture
  41598. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41599. * @param textures defines the textures to update
  41600. * @param samples defines the sample count to set
  41601. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41602. */
  41603. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41604. }
  41605. }
  41606. declare module BABYLON {
  41607. /**
  41608. * Gather the list of clipboard event types as constants.
  41609. */
  41610. export class ClipboardEventTypes {
  41611. /**
  41612. * The clipboard event is fired when a copy command is active (pressed).
  41613. */
  41614. static readonly COPY: number;
  41615. /**
  41616. * The clipboard event is fired when a cut command is active (pressed).
  41617. */
  41618. static readonly CUT: number;
  41619. /**
  41620. * The clipboard event is fired when a paste command is active (pressed).
  41621. */
  41622. static readonly PASTE: number;
  41623. }
  41624. /**
  41625. * This class is used to store clipboard related info for the onClipboardObservable event.
  41626. */
  41627. export class ClipboardInfo {
  41628. /**
  41629. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41630. */
  41631. type: number;
  41632. /**
  41633. * Defines the related dom event
  41634. */
  41635. event: ClipboardEvent;
  41636. /**
  41637. *Creates an instance of ClipboardInfo.
  41638. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41639. * @param event Defines the related dom event
  41640. */
  41641. constructor(
  41642. /**
  41643. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41644. */
  41645. type: number,
  41646. /**
  41647. * Defines the related dom event
  41648. */
  41649. event: ClipboardEvent);
  41650. /**
  41651. * Get the clipboard event's type from the keycode.
  41652. * @param keyCode Defines the keyCode for the current keyboard event.
  41653. * @return {number}
  41654. */
  41655. static GetTypeFromCharacter(keyCode: number): number;
  41656. }
  41657. }
  41658. declare module BABYLON {
  41659. /**
  41660. * Class used to represent data loading progression
  41661. */
  41662. export class SceneLoaderProgressEvent {
  41663. /** defines if data length to load can be evaluated */
  41664. readonly lengthComputable: boolean;
  41665. /** defines the loaded data length */
  41666. readonly loaded: number;
  41667. /** defines the data length to load */
  41668. readonly total: number;
  41669. /**
  41670. * Create a new progress event
  41671. * @param lengthComputable defines if data length to load can be evaluated
  41672. * @param loaded defines the loaded data length
  41673. * @param total defines the data length to load
  41674. */
  41675. constructor(
  41676. /** defines if data length to load can be evaluated */
  41677. lengthComputable: boolean,
  41678. /** defines the loaded data length */
  41679. loaded: number,
  41680. /** defines the data length to load */
  41681. total: number);
  41682. /**
  41683. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41684. * @param event defines the source event
  41685. * @returns a new SceneLoaderProgressEvent
  41686. */
  41687. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41688. }
  41689. /**
  41690. * Interface used by SceneLoader plugins to define supported file extensions
  41691. */
  41692. export interface ISceneLoaderPluginExtensions {
  41693. /**
  41694. * Defines the list of supported extensions
  41695. */
  41696. [extension: string]: {
  41697. isBinary: boolean;
  41698. };
  41699. }
  41700. /**
  41701. * Interface used by SceneLoader plugin factory
  41702. */
  41703. export interface ISceneLoaderPluginFactory {
  41704. /**
  41705. * Defines the name of the factory
  41706. */
  41707. name: string;
  41708. /**
  41709. * Function called to create a new plugin
  41710. * @return the new plugin
  41711. */
  41712. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41713. /**
  41714. * Boolean indicating if the plugin can direct load specific data
  41715. */
  41716. canDirectLoad?: (data: string) => boolean;
  41717. }
  41718. /**
  41719. * Interface used to define a SceneLoader plugin
  41720. */
  41721. export interface ISceneLoaderPlugin {
  41722. /**
  41723. * The friendly name of this plugin.
  41724. */
  41725. name: string;
  41726. /**
  41727. * The file extensions supported by this plugin.
  41728. */
  41729. extensions: string | ISceneLoaderPluginExtensions;
  41730. /**
  41731. * Import meshes into a scene.
  41732. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41733. * @param scene The scene to import into
  41734. * @param data The data to import
  41735. * @param rootUrl The root url for scene and resources
  41736. * @param meshes The meshes array to import into
  41737. * @param particleSystems The particle systems array to import into
  41738. * @param skeletons The skeletons array to import into
  41739. * @param onError The callback when import fails
  41740. * @returns True if successful or false otherwise
  41741. */
  41742. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41743. /**
  41744. * Load into a scene.
  41745. * @param scene The scene to load into
  41746. * @param data The data to import
  41747. * @param rootUrl The root url for scene and resources
  41748. * @param onError The callback when import fails
  41749. * @returns true if successful or false otherwise
  41750. */
  41751. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41752. /**
  41753. * The callback that returns true if the data can be directly loaded.
  41754. */
  41755. canDirectLoad?: (data: string) => boolean;
  41756. /**
  41757. * The callback that allows custom handling of the root url based on the response url.
  41758. */
  41759. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41760. /**
  41761. * Load into an asset container.
  41762. * @param scene The scene to load into
  41763. * @param data The data to import
  41764. * @param rootUrl The root url for scene and resources
  41765. * @param onError The callback when import fails
  41766. * @returns The loaded asset container
  41767. */
  41768. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41769. }
  41770. /**
  41771. * Interface used to define an async SceneLoader plugin
  41772. */
  41773. export interface ISceneLoaderPluginAsync {
  41774. /**
  41775. * The friendly name of this plugin.
  41776. */
  41777. name: string;
  41778. /**
  41779. * The file extensions supported by this plugin.
  41780. */
  41781. extensions: string | ISceneLoaderPluginExtensions;
  41782. /**
  41783. * Import meshes into a scene.
  41784. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41785. * @param scene The scene to import into
  41786. * @param data The data to import
  41787. * @param rootUrl The root url for scene and resources
  41788. * @param onProgress The callback when the load progresses
  41789. * @param fileName Defines the name of the file to load
  41790. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41791. */
  41792. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41793. meshes: AbstractMesh[];
  41794. particleSystems: IParticleSystem[];
  41795. skeletons: Skeleton[];
  41796. animationGroups: AnimationGroup[];
  41797. }>;
  41798. /**
  41799. * Load into a scene.
  41800. * @param scene The scene to load into
  41801. * @param data The data to import
  41802. * @param rootUrl The root url for scene and resources
  41803. * @param onProgress The callback when the load progresses
  41804. * @param fileName Defines the name of the file to load
  41805. * @returns Nothing
  41806. */
  41807. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41808. /**
  41809. * The callback that returns true if the data can be directly loaded.
  41810. */
  41811. canDirectLoad?: (data: string) => boolean;
  41812. /**
  41813. * The callback that allows custom handling of the root url based on the response url.
  41814. */
  41815. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41816. /**
  41817. * Load into an asset container.
  41818. * @param scene The scene to load into
  41819. * @param data The data to import
  41820. * @param rootUrl The root url for scene and resources
  41821. * @param onProgress The callback when the load progresses
  41822. * @param fileName Defines the name of the file to load
  41823. * @returns The loaded asset container
  41824. */
  41825. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41826. }
  41827. /**
  41828. * Class used to load scene from various file formats using registered plugins
  41829. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41830. */
  41831. export class SceneLoader {
  41832. /**
  41833. * No logging while loading
  41834. */
  41835. static readonly NO_LOGGING: number;
  41836. /**
  41837. * Minimal logging while loading
  41838. */
  41839. static readonly MINIMAL_LOGGING: number;
  41840. /**
  41841. * Summary logging while loading
  41842. */
  41843. static readonly SUMMARY_LOGGING: number;
  41844. /**
  41845. * Detailled logging while loading
  41846. */
  41847. static readonly DETAILED_LOGGING: number;
  41848. /**
  41849. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41850. */
  41851. static ForceFullSceneLoadingForIncremental: boolean;
  41852. /**
  41853. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41854. */
  41855. static ShowLoadingScreen: boolean;
  41856. /**
  41857. * Defines the current logging level (while loading the scene)
  41858. * @ignorenaming
  41859. */
  41860. static loggingLevel: number;
  41861. /**
  41862. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41863. */
  41864. static CleanBoneMatrixWeights: boolean;
  41865. /**
  41866. * Event raised when a plugin is used to load a scene
  41867. */
  41868. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41869. private static _registeredPlugins;
  41870. private static _getDefaultPlugin;
  41871. private static _getPluginForExtension;
  41872. private static _getPluginForDirectLoad;
  41873. private static _getPluginForFilename;
  41874. private static _getDirectLoad;
  41875. private static _loadData;
  41876. private static _getFileInfo;
  41877. /**
  41878. * Gets a plugin that can load the given extension
  41879. * @param extension defines the extension to load
  41880. * @returns a plugin or null if none works
  41881. */
  41882. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41883. /**
  41884. * Gets a boolean indicating that the given extension can be loaded
  41885. * @param extension defines the extension to load
  41886. * @returns true if the extension is supported
  41887. */
  41888. static IsPluginForExtensionAvailable(extension: string): boolean;
  41889. /**
  41890. * Adds a new plugin to the list of registered plugins
  41891. * @param plugin defines the plugin to add
  41892. */
  41893. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41894. /**
  41895. * Import meshes into a scene
  41896. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41897. * @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)
  41898. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41899. * @param scene the instance of BABYLON.Scene to append to
  41900. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41901. * @param onProgress a callback with a progress event for each file being loaded
  41902. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41903. * @param pluginExtension the extension used to determine the plugin
  41904. * @returns The loaded plugin
  41905. */
  41906. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41907. /**
  41908. * Import meshes into a scene
  41909. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41910. * @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)
  41911. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41912. * @param scene the instance of BABYLON.Scene to append to
  41913. * @param onProgress a callback with a progress event for each file being loaded
  41914. * @param pluginExtension the extension used to determine the plugin
  41915. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41916. */
  41917. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41918. meshes: AbstractMesh[];
  41919. particleSystems: IParticleSystem[];
  41920. skeletons: Skeleton[];
  41921. animationGroups: AnimationGroup[];
  41922. }>;
  41923. /**
  41924. * Load a scene
  41925. * @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)
  41926. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41927. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41928. * @param onSuccess a callback with the scene when import succeeds
  41929. * @param onProgress a callback with a progress event for each file being loaded
  41930. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41931. * @param pluginExtension the extension used to determine the plugin
  41932. * @returns The loaded plugin
  41933. */
  41934. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41935. /**
  41936. * Load a scene
  41937. * @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)
  41938. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41939. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41940. * @param onProgress a callback with a progress event for each file being loaded
  41941. * @param pluginExtension the extension used to determine the plugin
  41942. * @returns The loaded scene
  41943. */
  41944. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41945. /**
  41946. * Append a scene
  41947. * @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)
  41948. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41949. * @param scene is the instance of BABYLON.Scene to append to
  41950. * @param onSuccess a callback with the scene when import succeeds
  41951. * @param onProgress a callback with a progress event for each file being loaded
  41952. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41953. * @param pluginExtension the extension used to determine the plugin
  41954. * @returns The loaded plugin
  41955. */
  41956. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41957. /**
  41958. * Append a scene
  41959. * @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)
  41960. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41961. * @param scene is the instance of BABYLON.Scene to append to
  41962. * @param onProgress a callback with a progress event for each file being loaded
  41963. * @param pluginExtension the extension used to determine the plugin
  41964. * @returns The given scene
  41965. */
  41966. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41967. /**
  41968. * Load a scene into an asset container
  41969. * @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)
  41970. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41971. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41972. * @param onSuccess a callback with the scene when import succeeds
  41973. * @param onProgress a callback with a progress event for each file being loaded
  41974. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41975. * @param pluginExtension the extension used to determine the plugin
  41976. * @returns The loaded plugin
  41977. */
  41978. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41979. /**
  41980. * Load a scene into an asset container
  41981. * @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)
  41982. * @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)
  41983. * @param scene is the instance of Scene to append to
  41984. * @param onProgress a callback with a progress event for each file being loaded
  41985. * @param pluginExtension the extension used to determine the plugin
  41986. * @returns The loaded asset container
  41987. */
  41988. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41989. }
  41990. }
  41991. declare module BABYLON {
  41992. /**
  41993. * Google Daydream controller
  41994. */
  41995. export class DaydreamController extends WebVRController {
  41996. /**
  41997. * Base Url for the controller model.
  41998. */
  41999. static MODEL_BASE_URL: string;
  42000. /**
  42001. * File name for the controller model.
  42002. */
  42003. static MODEL_FILENAME: string;
  42004. /**
  42005. * Gamepad Id prefix used to identify Daydream Controller.
  42006. */
  42007. static readonly GAMEPAD_ID_PREFIX: string;
  42008. /**
  42009. * Creates a new DaydreamController from a gamepad
  42010. * @param vrGamepad the gamepad that the controller should be created from
  42011. */
  42012. constructor(vrGamepad: any);
  42013. /**
  42014. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42015. * @param scene scene in which to add meshes
  42016. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42017. */
  42018. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42019. /**
  42020. * Called once for each button that changed state since the last frame
  42021. * @param buttonIdx Which button index changed
  42022. * @param state New state of the button
  42023. * @param changes Which properties on the state changed since last frame
  42024. */
  42025. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42026. }
  42027. }
  42028. declare module BABYLON {
  42029. /**
  42030. * Gear VR Controller
  42031. */
  42032. export class GearVRController extends WebVRController {
  42033. /**
  42034. * Base Url for the controller model.
  42035. */
  42036. static MODEL_BASE_URL: string;
  42037. /**
  42038. * File name for the controller model.
  42039. */
  42040. static MODEL_FILENAME: string;
  42041. /**
  42042. * Gamepad Id prefix used to identify this controller.
  42043. */
  42044. static readonly GAMEPAD_ID_PREFIX: string;
  42045. private readonly _buttonIndexToObservableNameMap;
  42046. /**
  42047. * Creates a new GearVRController from a gamepad
  42048. * @param vrGamepad the gamepad that the controller should be created from
  42049. */
  42050. constructor(vrGamepad: any);
  42051. /**
  42052. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42053. * @param scene scene in which to add meshes
  42054. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42055. */
  42056. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42057. /**
  42058. * Called once for each button that changed state since the last frame
  42059. * @param buttonIdx Which button index changed
  42060. * @param state New state of the button
  42061. * @param changes Which properties on the state changed since last frame
  42062. */
  42063. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42064. }
  42065. }
  42066. declare module BABYLON {
  42067. /**
  42068. * Generic Controller
  42069. */
  42070. export class GenericController extends WebVRController {
  42071. /**
  42072. * Base Url for the controller model.
  42073. */
  42074. static readonly MODEL_BASE_URL: string;
  42075. /**
  42076. * File name for the controller model.
  42077. */
  42078. static readonly MODEL_FILENAME: string;
  42079. /**
  42080. * Creates a new GenericController from a gamepad
  42081. * @param vrGamepad the gamepad that the controller should be created from
  42082. */
  42083. constructor(vrGamepad: any);
  42084. /**
  42085. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42086. * @param scene scene in which to add meshes
  42087. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42088. */
  42089. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42090. /**
  42091. * Called once for each button that changed state since the last frame
  42092. * @param buttonIdx Which button index changed
  42093. * @param state New state of the button
  42094. * @param changes Which properties on the state changed since last frame
  42095. */
  42096. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42097. }
  42098. }
  42099. declare module BABYLON {
  42100. /**
  42101. * Oculus Touch Controller
  42102. */
  42103. export class OculusTouchController extends WebVRController {
  42104. /**
  42105. * Base Url for the controller model.
  42106. */
  42107. static MODEL_BASE_URL: string;
  42108. /**
  42109. * File name for the left controller model.
  42110. */
  42111. static MODEL_LEFT_FILENAME: string;
  42112. /**
  42113. * File name for the right controller model.
  42114. */
  42115. static MODEL_RIGHT_FILENAME: string;
  42116. /**
  42117. * Fired when the secondary trigger on this controller is modified
  42118. */
  42119. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42120. /**
  42121. * Fired when the thumb rest on this controller is modified
  42122. */
  42123. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42124. /**
  42125. * Creates a new OculusTouchController from a gamepad
  42126. * @param vrGamepad the gamepad that the controller should be created from
  42127. */
  42128. constructor(vrGamepad: any);
  42129. /**
  42130. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42131. * @param scene scene in which to add meshes
  42132. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42133. */
  42134. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42135. /**
  42136. * Fired when the A button on this controller is modified
  42137. */
  42138. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42139. /**
  42140. * Fired when the B button on this controller is modified
  42141. */
  42142. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42143. /**
  42144. * Fired when the X button on this controller is modified
  42145. */
  42146. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42147. /**
  42148. * Fired when the Y button on this controller is modified
  42149. */
  42150. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42151. /**
  42152. * Called once for each button that changed state since the last frame
  42153. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42154. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42155. * 2) secondary trigger (same)
  42156. * 3) A (right) X (left), touch, pressed = value
  42157. * 4) B / Y
  42158. * 5) thumb rest
  42159. * @param buttonIdx Which button index changed
  42160. * @param state New state of the button
  42161. * @param changes Which properties on the state changed since last frame
  42162. */
  42163. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42164. }
  42165. }
  42166. declare module BABYLON {
  42167. /**
  42168. * Vive Controller
  42169. */
  42170. export class ViveController extends WebVRController {
  42171. /**
  42172. * Base Url for the controller model.
  42173. */
  42174. static MODEL_BASE_URL: string;
  42175. /**
  42176. * File name for the controller model.
  42177. */
  42178. static MODEL_FILENAME: string;
  42179. /**
  42180. * Creates a new ViveController from a gamepad
  42181. * @param vrGamepad the gamepad that the controller should be created from
  42182. */
  42183. constructor(vrGamepad: any);
  42184. /**
  42185. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42186. * @param scene scene in which to add meshes
  42187. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42188. */
  42189. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42190. /**
  42191. * Fired when the left button on this controller is modified
  42192. */
  42193. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42194. /**
  42195. * Fired when the right button on this controller is modified
  42196. */
  42197. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42198. /**
  42199. * Fired when the menu button on this controller is modified
  42200. */
  42201. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42202. /**
  42203. * Called once for each button that changed state since the last frame
  42204. * Vive mapping:
  42205. * 0: touchpad
  42206. * 1: trigger
  42207. * 2: left AND right buttons
  42208. * 3: menu button
  42209. * @param buttonIdx Which button index changed
  42210. * @param state New state of the button
  42211. * @param changes Which properties on the state changed since last frame
  42212. */
  42213. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42214. }
  42215. }
  42216. declare module BABYLON {
  42217. /**
  42218. * Defines the WindowsMotionController object that the state of the windows motion controller
  42219. */
  42220. export class WindowsMotionController extends WebVRController {
  42221. /**
  42222. * The base url used to load the left and right controller models
  42223. */
  42224. static MODEL_BASE_URL: string;
  42225. /**
  42226. * The name of the left controller model file
  42227. */
  42228. static MODEL_LEFT_FILENAME: string;
  42229. /**
  42230. * The name of the right controller model file
  42231. */
  42232. static MODEL_RIGHT_FILENAME: string;
  42233. /**
  42234. * The controller name prefix for this controller type
  42235. */
  42236. static readonly GAMEPAD_ID_PREFIX: string;
  42237. /**
  42238. * The controller id pattern for this controller type
  42239. */
  42240. private static readonly GAMEPAD_ID_PATTERN;
  42241. private _loadedMeshInfo;
  42242. private readonly _mapping;
  42243. /**
  42244. * Fired when the trackpad on this controller is clicked
  42245. */
  42246. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42247. /**
  42248. * Fired when the trackpad on this controller is modified
  42249. */
  42250. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42251. /**
  42252. * The current x and y values of this controller's trackpad
  42253. */
  42254. trackpad: StickValues;
  42255. /**
  42256. * Creates a new WindowsMotionController from a gamepad
  42257. * @param vrGamepad the gamepad that the controller should be created from
  42258. */
  42259. constructor(vrGamepad: any);
  42260. /**
  42261. * Fired when the trigger on this controller is modified
  42262. */
  42263. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42264. /**
  42265. * Fired when the menu button on this controller is modified
  42266. */
  42267. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42268. /**
  42269. * Fired when the grip button on this controller is modified
  42270. */
  42271. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42272. /**
  42273. * Fired when the thumbstick button on this controller is modified
  42274. */
  42275. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42276. /**
  42277. * Fired when the touchpad button on this controller is modified
  42278. */
  42279. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42280. /**
  42281. * Fired when the touchpad values on this controller are modified
  42282. */
  42283. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42284. private _updateTrackpad;
  42285. /**
  42286. * Called once per frame by the engine.
  42287. */
  42288. update(): void;
  42289. /**
  42290. * Called once for each button that changed state since the last frame
  42291. * @param buttonIdx Which button index changed
  42292. * @param state New state of the button
  42293. * @param changes Which properties on the state changed since last frame
  42294. */
  42295. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42296. /**
  42297. * Moves the buttons on the controller mesh based on their current state
  42298. * @param buttonName the name of the button to move
  42299. * @param buttonValue the value of the button which determines the buttons new position
  42300. */
  42301. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42302. /**
  42303. * Moves the axis on the controller mesh based on its current state
  42304. * @param axis the index of the axis
  42305. * @param axisValue the value of the axis which determines the meshes new position
  42306. * @hidden
  42307. */
  42308. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42309. /**
  42310. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42311. * @param scene scene in which to add meshes
  42312. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42313. */
  42314. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42315. /**
  42316. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42317. * can be transformed by button presses and axes values, based on this._mapping.
  42318. *
  42319. * @param scene scene in which the meshes exist
  42320. * @param meshes list of meshes that make up the controller model to process
  42321. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42322. */
  42323. private processModel;
  42324. private createMeshInfo;
  42325. /**
  42326. * Gets the ray of the controller in the direction the controller is pointing
  42327. * @param length the length the resulting ray should be
  42328. * @returns a ray in the direction the controller is pointing
  42329. */
  42330. getForwardRay(length?: number): Ray;
  42331. /**
  42332. * Disposes of the controller
  42333. */
  42334. dispose(): void;
  42335. }
  42336. }
  42337. declare module BABYLON {
  42338. /**
  42339. * Single axis scale gizmo
  42340. */
  42341. export class AxisScaleGizmo extends Gizmo {
  42342. private _coloredMaterial;
  42343. /**
  42344. * Drag behavior responsible for the gizmos dragging interactions
  42345. */
  42346. dragBehavior: PointerDragBehavior;
  42347. private _pointerObserver;
  42348. /**
  42349. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42350. */
  42351. snapDistance: number;
  42352. /**
  42353. * Event that fires each time the gizmo snaps to a new location.
  42354. * * snapDistance is the the change in distance
  42355. */
  42356. onSnapObservable: Observable<{
  42357. snapDistance: number;
  42358. }>;
  42359. /**
  42360. * If the scaling operation should be done on all axis (default: false)
  42361. */
  42362. uniformScaling: boolean;
  42363. /**
  42364. * Creates an AxisScaleGizmo
  42365. * @param gizmoLayer The utility layer the gizmo will be added to
  42366. * @param dragAxis The axis which the gizmo will be able to scale on
  42367. * @param color The color of the gizmo
  42368. */
  42369. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42370. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42371. /**
  42372. * Disposes of the gizmo
  42373. */
  42374. dispose(): void;
  42375. /**
  42376. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42377. * @param mesh The mesh to replace the default mesh of the gizmo
  42378. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42379. */
  42380. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42381. }
  42382. }
  42383. declare module BABYLON {
  42384. /**
  42385. * Bounding box gizmo
  42386. */
  42387. export class BoundingBoxGizmo extends Gizmo {
  42388. private _lineBoundingBox;
  42389. private _rotateSpheresParent;
  42390. private _scaleBoxesParent;
  42391. private _boundingDimensions;
  42392. private _renderObserver;
  42393. private _pointerObserver;
  42394. private _scaleDragSpeed;
  42395. private _tmpQuaternion;
  42396. private _tmpVector;
  42397. private _tmpRotationMatrix;
  42398. /**
  42399. * 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)
  42400. */
  42401. ignoreChildren: boolean;
  42402. /**
  42403. * 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)
  42404. */
  42405. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42406. /**
  42407. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42408. */
  42409. rotationSphereSize: number;
  42410. /**
  42411. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42412. */
  42413. scaleBoxSize: number;
  42414. /**
  42415. * 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)
  42416. */
  42417. fixedDragMeshScreenSize: boolean;
  42418. /**
  42419. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42420. */
  42421. fixedDragMeshScreenSizeDistanceFactor: number;
  42422. /**
  42423. * Fired when a rotation sphere or scale box is dragged
  42424. */
  42425. onDragStartObservable: Observable<{}>;
  42426. /**
  42427. * Fired when a scale box is dragged
  42428. */
  42429. onScaleBoxDragObservable: Observable<{}>;
  42430. /**
  42431. * Fired when a scale box drag is ended
  42432. */
  42433. onScaleBoxDragEndObservable: Observable<{}>;
  42434. /**
  42435. * Fired when a rotation sphere is dragged
  42436. */
  42437. onRotationSphereDragObservable: Observable<{}>;
  42438. /**
  42439. * Fired when a rotation sphere drag is ended
  42440. */
  42441. onRotationSphereDragEndObservable: Observable<{}>;
  42442. /**
  42443. * 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)
  42444. */
  42445. scalePivot: Nullable<Vector3>;
  42446. /**
  42447. * Mesh used as a pivot to rotate the attached mesh
  42448. */
  42449. private _anchorMesh;
  42450. private _existingMeshScale;
  42451. private _dragMesh;
  42452. private pointerDragBehavior;
  42453. private coloredMaterial;
  42454. private hoverColoredMaterial;
  42455. /**
  42456. * Sets the color of the bounding box gizmo
  42457. * @param color the color to set
  42458. */
  42459. setColor(color: Color3): void;
  42460. /**
  42461. * Creates an BoundingBoxGizmo
  42462. * @param gizmoLayer The utility layer the gizmo will be added to
  42463. * @param color The color of the gizmo
  42464. */
  42465. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42466. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42467. private _selectNode;
  42468. /**
  42469. * Updates the bounding box information for the Gizmo
  42470. */
  42471. updateBoundingBox(): void;
  42472. private _updateRotationSpheres;
  42473. private _updateScaleBoxes;
  42474. /**
  42475. * Enables rotation on the specified axis and disables rotation on the others
  42476. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42477. */
  42478. setEnabledRotationAxis(axis: string): void;
  42479. /**
  42480. * Enables/disables scaling
  42481. * @param enable if scaling should be enabled
  42482. */
  42483. setEnabledScaling(enable: boolean): void;
  42484. private _updateDummy;
  42485. /**
  42486. * Enables a pointer drag behavior on the bounding box of the gizmo
  42487. */
  42488. enableDragBehavior(): void;
  42489. /**
  42490. * Disposes of the gizmo
  42491. */
  42492. dispose(): void;
  42493. /**
  42494. * 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)
  42495. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42496. * @returns the bounding box mesh with the passed in mesh as a child
  42497. */
  42498. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42499. /**
  42500. * CustomMeshes are not supported by this gizmo
  42501. * @param mesh The mesh to replace the default mesh of the gizmo
  42502. */
  42503. setCustomMesh(mesh: Mesh): void;
  42504. }
  42505. }
  42506. declare module BABYLON {
  42507. /**
  42508. * Single plane rotation gizmo
  42509. */
  42510. export class PlaneRotationGizmo extends Gizmo {
  42511. /**
  42512. * Drag behavior responsible for the gizmos dragging interactions
  42513. */
  42514. dragBehavior: PointerDragBehavior;
  42515. private _pointerObserver;
  42516. /**
  42517. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42518. */
  42519. snapDistance: number;
  42520. /**
  42521. * Event that fires each time the gizmo snaps to a new location.
  42522. * * snapDistance is the the change in distance
  42523. */
  42524. onSnapObservable: Observable<{
  42525. snapDistance: number;
  42526. }>;
  42527. /**
  42528. * Creates a PlaneRotationGizmo
  42529. * @param gizmoLayer The utility layer the gizmo will be added to
  42530. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42531. * @param color The color of the gizmo
  42532. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42533. */
  42534. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42535. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42536. /**
  42537. * Disposes of the gizmo
  42538. */
  42539. dispose(): void;
  42540. }
  42541. }
  42542. declare module BABYLON {
  42543. /**
  42544. * Gizmo that enables rotating a mesh along 3 axis
  42545. */
  42546. export class RotationGizmo extends Gizmo {
  42547. /**
  42548. * Internal gizmo used for interactions on the x axis
  42549. */
  42550. xGizmo: PlaneRotationGizmo;
  42551. /**
  42552. * Internal gizmo used for interactions on the y axis
  42553. */
  42554. yGizmo: PlaneRotationGizmo;
  42555. /**
  42556. * Internal gizmo used for interactions on the z axis
  42557. */
  42558. zGizmo: PlaneRotationGizmo;
  42559. /** Fires an event when any of it's sub gizmos are dragged */
  42560. onDragStartObservable: Observable<{}>;
  42561. /** Fires an event when any of it's sub gizmos are released from dragging */
  42562. onDragEndObservable: Observable<{}>;
  42563. attachedMesh: Nullable<AbstractMesh>;
  42564. /**
  42565. * Creates a RotationGizmo
  42566. * @param gizmoLayer The utility layer the gizmo will be added to
  42567. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42568. */
  42569. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42570. updateGizmoRotationToMatchAttachedMesh: boolean;
  42571. /**
  42572. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42573. */
  42574. snapDistance: number;
  42575. /**
  42576. * Ratio for the scale of the gizmo (Default: 1)
  42577. */
  42578. scaleRatio: number;
  42579. /**
  42580. * Disposes of the gizmo
  42581. */
  42582. dispose(): void;
  42583. /**
  42584. * CustomMeshes are not supported by this gizmo
  42585. * @param mesh The mesh to replace the default mesh of the gizmo
  42586. */
  42587. setCustomMesh(mesh: Mesh): void;
  42588. }
  42589. }
  42590. declare module BABYLON {
  42591. /**
  42592. * Gizmo that enables dragging a mesh along 3 axis
  42593. */
  42594. export class PositionGizmo extends Gizmo {
  42595. /**
  42596. * Internal gizmo used for interactions on the x axis
  42597. */
  42598. xGizmo: AxisDragGizmo;
  42599. /**
  42600. * Internal gizmo used for interactions on the y axis
  42601. */
  42602. yGizmo: AxisDragGizmo;
  42603. /**
  42604. * Internal gizmo used for interactions on the z axis
  42605. */
  42606. zGizmo: AxisDragGizmo;
  42607. /** Fires an event when any of it's sub gizmos are dragged */
  42608. onDragStartObservable: Observable<{}>;
  42609. /** Fires an event when any of it's sub gizmos are released from dragging */
  42610. onDragEndObservable: Observable<{}>;
  42611. attachedMesh: Nullable<AbstractMesh>;
  42612. /**
  42613. * Creates a PositionGizmo
  42614. * @param gizmoLayer The utility layer the gizmo will be added to
  42615. */
  42616. constructor(gizmoLayer?: UtilityLayerRenderer);
  42617. updateGizmoRotationToMatchAttachedMesh: boolean;
  42618. /**
  42619. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42620. */
  42621. snapDistance: number;
  42622. /**
  42623. * Ratio for the scale of the gizmo (Default: 1)
  42624. */
  42625. scaleRatio: number;
  42626. /**
  42627. * Disposes of the gizmo
  42628. */
  42629. dispose(): void;
  42630. /**
  42631. * CustomMeshes are not supported by this gizmo
  42632. * @param mesh The mesh to replace the default mesh of the gizmo
  42633. */
  42634. setCustomMesh(mesh: Mesh): void;
  42635. }
  42636. }
  42637. declare module BABYLON {
  42638. /**
  42639. * Class containing static functions to help procedurally build meshes
  42640. */
  42641. export class PolyhedronBuilder {
  42642. /**
  42643. * Creates a polyhedron mesh
  42644. * * 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
  42645. * * The parameter `size` (positive float, default 1) sets the polygon size
  42646. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42647. * * 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`
  42648. * * 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
  42649. * * 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)`)
  42650. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42651. * * 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
  42652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42653. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42655. * @param name defines the name of the mesh
  42656. * @param options defines the options used to create the mesh
  42657. * @param scene defines the hosting scene
  42658. * @returns the polyhedron mesh
  42659. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42660. */
  42661. static CreatePolyhedron(name: string, options: {
  42662. type?: number;
  42663. size?: number;
  42664. sizeX?: number;
  42665. sizeY?: number;
  42666. sizeZ?: number;
  42667. custom?: any;
  42668. faceUV?: Vector4[];
  42669. faceColors?: Color4[];
  42670. flat?: boolean;
  42671. updatable?: boolean;
  42672. sideOrientation?: number;
  42673. frontUVs?: Vector4;
  42674. backUVs?: Vector4;
  42675. }, scene?: Nullable<Scene>): Mesh;
  42676. }
  42677. }
  42678. declare module BABYLON {
  42679. /**
  42680. * Gizmo that enables scaling a mesh along 3 axis
  42681. */
  42682. export class ScaleGizmo extends Gizmo {
  42683. /**
  42684. * Internal gizmo used for interactions on the x axis
  42685. */
  42686. xGizmo: AxisScaleGizmo;
  42687. /**
  42688. * Internal gizmo used for interactions on the y axis
  42689. */
  42690. yGizmo: AxisScaleGizmo;
  42691. /**
  42692. * Internal gizmo used for interactions on the z axis
  42693. */
  42694. zGizmo: AxisScaleGizmo;
  42695. /**
  42696. * Internal gizmo used to scale all axis equally
  42697. */
  42698. uniformScaleGizmo: AxisScaleGizmo;
  42699. /** Fires an event when any of it's sub gizmos are dragged */
  42700. onDragStartObservable: Observable<{}>;
  42701. /** Fires an event when any of it's sub gizmos are released from dragging */
  42702. onDragEndObservable: Observable<{}>;
  42703. attachedMesh: Nullable<AbstractMesh>;
  42704. /**
  42705. * Creates a ScaleGizmo
  42706. * @param gizmoLayer The utility layer the gizmo will be added to
  42707. */
  42708. constructor(gizmoLayer?: UtilityLayerRenderer);
  42709. updateGizmoRotationToMatchAttachedMesh: boolean;
  42710. /**
  42711. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42712. */
  42713. snapDistance: number;
  42714. /**
  42715. * Ratio for the scale of the gizmo (Default: 1)
  42716. */
  42717. scaleRatio: number;
  42718. /**
  42719. * Disposes of the gizmo
  42720. */
  42721. dispose(): void;
  42722. }
  42723. }
  42724. declare module BABYLON {
  42725. /**
  42726. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42727. */
  42728. export class GizmoManager implements IDisposable {
  42729. private scene;
  42730. /**
  42731. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42732. */
  42733. gizmos: {
  42734. positionGizmo: Nullable<PositionGizmo>;
  42735. rotationGizmo: Nullable<RotationGizmo>;
  42736. scaleGizmo: Nullable<ScaleGizmo>;
  42737. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42738. };
  42739. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42740. clearGizmoOnEmptyPointerEvent: boolean;
  42741. /** Fires an event when the manager is attached to a mesh */
  42742. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42743. private _gizmosEnabled;
  42744. private _pointerObserver;
  42745. private _attachedMesh;
  42746. private _boundingBoxColor;
  42747. private _defaultUtilityLayer;
  42748. private _defaultKeepDepthUtilityLayer;
  42749. /**
  42750. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42751. */
  42752. boundingBoxDragBehavior: SixDofDragBehavior;
  42753. /**
  42754. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42755. */
  42756. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42757. /**
  42758. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42759. */
  42760. usePointerToAttachGizmos: boolean;
  42761. /**
  42762. * Instatiates a gizmo manager
  42763. * @param scene the scene to overlay the gizmos on top of
  42764. */
  42765. constructor(scene: Scene);
  42766. /**
  42767. * Attaches a set of gizmos to the specified mesh
  42768. * @param mesh The mesh the gizmo's should be attached to
  42769. */
  42770. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42771. /**
  42772. * If the position gizmo is enabled
  42773. */
  42774. positionGizmoEnabled: boolean;
  42775. /**
  42776. * If the rotation gizmo is enabled
  42777. */
  42778. rotationGizmoEnabled: boolean;
  42779. /**
  42780. * If the scale gizmo is enabled
  42781. */
  42782. scaleGizmoEnabled: boolean;
  42783. /**
  42784. * If the boundingBox gizmo is enabled
  42785. */
  42786. boundingBoxGizmoEnabled: boolean;
  42787. /**
  42788. * Disposes of the gizmo manager
  42789. */
  42790. dispose(): void;
  42791. }
  42792. }
  42793. declare module BABYLON {
  42794. /**
  42795. * A directional light is defined by a direction (what a surprise!).
  42796. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42797. * 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.
  42798. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42799. */
  42800. export class DirectionalLight extends ShadowLight {
  42801. private _shadowFrustumSize;
  42802. /**
  42803. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42804. */
  42805. /**
  42806. * Specifies a fix frustum size for the shadow generation.
  42807. */
  42808. shadowFrustumSize: number;
  42809. private _shadowOrthoScale;
  42810. /**
  42811. * Gets the shadow projection scale against the optimal computed one.
  42812. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42813. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42814. */
  42815. /**
  42816. * Sets the shadow projection scale against the optimal computed one.
  42817. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42818. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42819. */
  42820. shadowOrthoScale: number;
  42821. /**
  42822. * Automatically compute the projection matrix to best fit (including all the casters)
  42823. * on each frame.
  42824. */
  42825. autoUpdateExtends: boolean;
  42826. private _orthoLeft;
  42827. private _orthoRight;
  42828. private _orthoTop;
  42829. private _orthoBottom;
  42830. /**
  42831. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42832. * The directional light is emitted from everywhere in the given direction.
  42833. * It can cast shadows.
  42834. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42835. * @param name The friendly name of the light
  42836. * @param direction The direction of the light
  42837. * @param scene The scene the light belongs to
  42838. */
  42839. constructor(name: string, direction: Vector3, scene: Scene);
  42840. /**
  42841. * Returns the string "DirectionalLight".
  42842. * @return The class name
  42843. */
  42844. getClassName(): string;
  42845. /**
  42846. * Returns the integer 1.
  42847. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42848. */
  42849. getTypeID(): number;
  42850. /**
  42851. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42852. * Returns the DirectionalLight Shadow projection matrix.
  42853. */
  42854. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42855. /**
  42856. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42857. * Returns the DirectionalLight Shadow projection matrix.
  42858. */
  42859. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42860. /**
  42861. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42862. * Returns the DirectionalLight Shadow projection matrix.
  42863. */
  42864. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42865. protected _buildUniformLayout(): void;
  42866. /**
  42867. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42868. * @param effect The effect to update
  42869. * @param lightIndex The index of the light in the effect to update
  42870. * @returns The directional light
  42871. */
  42872. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42873. /**
  42874. * Gets the minZ used for shadow according to both the scene and the light.
  42875. *
  42876. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42877. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42878. * @param activeCamera The camera we are returning the min for
  42879. * @returns the depth min z
  42880. */
  42881. getDepthMinZ(activeCamera: Camera): number;
  42882. /**
  42883. * Gets the maxZ used for shadow according to both the scene and the light.
  42884. *
  42885. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42886. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42887. * @param activeCamera The camera we are returning the max for
  42888. * @returns the depth max z
  42889. */
  42890. getDepthMaxZ(activeCamera: Camera): number;
  42891. /**
  42892. * Prepares the list of defines specific to the light type.
  42893. * @param defines the list of defines
  42894. * @param lightIndex defines the index of the light for the effect
  42895. */
  42896. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42897. }
  42898. }
  42899. declare module BABYLON {
  42900. /**
  42901. * Class containing static functions to help procedurally build meshes
  42902. */
  42903. export class HemisphereBuilder {
  42904. /**
  42905. * Creates a hemisphere mesh
  42906. * @param name defines the name of the mesh
  42907. * @param options defines the options used to create the mesh
  42908. * @param scene defines the hosting scene
  42909. * @returns the hemisphere mesh
  42910. */
  42911. static CreateHemisphere(name: string, options: {
  42912. segments?: number;
  42913. diameter?: number;
  42914. sideOrientation?: number;
  42915. }, scene: any): Mesh;
  42916. }
  42917. }
  42918. declare module BABYLON {
  42919. /**
  42920. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42921. * These values define a cone of light starting from the position, emitting toward the direction.
  42922. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42923. * and the exponent defines the speed of the decay of the light with distance (reach).
  42924. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42925. */
  42926. export class SpotLight extends ShadowLight {
  42927. private _angle;
  42928. private _innerAngle;
  42929. private _cosHalfAngle;
  42930. private _lightAngleScale;
  42931. private _lightAngleOffset;
  42932. /**
  42933. * Gets the cone angle of the spot light in Radians.
  42934. */
  42935. /**
  42936. * Sets the cone angle of the spot light in Radians.
  42937. */
  42938. angle: number;
  42939. /**
  42940. * Only used in gltf falloff mode, this defines the angle where
  42941. * the directional falloff will start before cutting at angle which could be seen
  42942. * as outer angle.
  42943. */
  42944. /**
  42945. * Only used in gltf falloff mode, this defines the angle where
  42946. * the directional falloff will start before cutting at angle which could be seen
  42947. * as outer angle.
  42948. */
  42949. innerAngle: number;
  42950. private _shadowAngleScale;
  42951. /**
  42952. * Allows scaling the angle of the light for shadow generation only.
  42953. */
  42954. /**
  42955. * Allows scaling the angle of the light for shadow generation only.
  42956. */
  42957. shadowAngleScale: number;
  42958. /**
  42959. * The light decay speed with the distance from the emission spot.
  42960. */
  42961. exponent: number;
  42962. private _projectionTextureMatrix;
  42963. /**
  42964. * Allows reading the projecton texture
  42965. */
  42966. readonly projectionTextureMatrix: Matrix;
  42967. protected _projectionTextureLightNear: number;
  42968. /**
  42969. * Gets the near clip of the Spotlight for texture projection.
  42970. */
  42971. /**
  42972. * Sets the near clip of the Spotlight for texture projection.
  42973. */
  42974. projectionTextureLightNear: number;
  42975. protected _projectionTextureLightFar: number;
  42976. /**
  42977. * Gets the far clip of the Spotlight for texture projection.
  42978. */
  42979. /**
  42980. * Sets the far clip of the Spotlight for texture projection.
  42981. */
  42982. projectionTextureLightFar: number;
  42983. protected _projectionTextureUpDirection: Vector3;
  42984. /**
  42985. * Gets the Up vector of the Spotlight for texture projection.
  42986. */
  42987. /**
  42988. * Sets the Up vector of the Spotlight for texture projection.
  42989. */
  42990. projectionTextureUpDirection: Vector3;
  42991. private _projectionTexture;
  42992. /**
  42993. * Gets the projection texture of the light.
  42994. */
  42995. /**
  42996. * Sets the projection texture of the light.
  42997. */
  42998. projectionTexture: Nullable<BaseTexture>;
  42999. private _projectionTextureViewLightDirty;
  43000. private _projectionTextureProjectionLightDirty;
  43001. private _projectionTextureDirty;
  43002. private _projectionTextureViewTargetVector;
  43003. private _projectionTextureViewLightMatrix;
  43004. private _projectionTextureProjectionLightMatrix;
  43005. private _projectionTextureScalingMatrix;
  43006. /**
  43007. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43008. * It can cast shadows.
  43009. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43010. * @param name The light friendly name
  43011. * @param position The position of the spot light in the scene
  43012. * @param direction The direction of the light in the scene
  43013. * @param angle The cone angle of the light in Radians
  43014. * @param exponent The light decay speed with the distance from the emission spot
  43015. * @param scene The scene the lights belongs to
  43016. */
  43017. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43018. /**
  43019. * Returns the string "SpotLight".
  43020. * @returns the class name
  43021. */
  43022. getClassName(): string;
  43023. /**
  43024. * Returns the integer 2.
  43025. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43026. */
  43027. getTypeID(): number;
  43028. /**
  43029. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43030. */
  43031. protected _setDirection(value: Vector3): void;
  43032. /**
  43033. * Overrides the position setter to recompute the projection texture view light Matrix.
  43034. */
  43035. protected _setPosition(value: Vector3): void;
  43036. /**
  43037. * 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.
  43038. * Returns the SpotLight.
  43039. */
  43040. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43041. protected _computeProjectionTextureViewLightMatrix(): void;
  43042. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43043. /**
  43044. * Main function for light texture projection matrix computing.
  43045. */
  43046. protected _computeProjectionTextureMatrix(): void;
  43047. protected _buildUniformLayout(): void;
  43048. private _computeAngleValues;
  43049. /**
  43050. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43051. * @param effect The effect to update
  43052. * @param lightIndex The index of the light in the effect to update
  43053. * @returns The spot light
  43054. */
  43055. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43056. /**
  43057. * Disposes the light and the associated resources.
  43058. */
  43059. dispose(): void;
  43060. /**
  43061. * Prepares the list of defines specific to the light type.
  43062. * @param defines the list of defines
  43063. * @param lightIndex defines the index of the light for the effect
  43064. */
  43065. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43066. }
  43067. }
  43068. declare module BABYLON {
  43069. /**
  43070. * Gizmo that enables viewing a light
  43071. */
  43072. export class LightGizmo extends Gizmo {
  43073. private _lightMesh;
  43074. private _material;
  43075. /**
  43076. * Creates a LightGizmo
  43077. * @param gizmoLayer The utility layer the gizmo will be added to
  43078. */
  43079. constructor(gizmoLayer?: UtilityLayerRenderer);
  43080. private _light;
  43081. /**
  43082. * The light that the gizmo is attached to
  43083. */
  43084. light: Nullable<Light>;
  43085. /**
  43086. * @hidden
  43087. * Updates the gizmo to match the attached mesh's position/rotation
  43088. */
  43089. protected _update(): void;
  43090. private static _Scale;
  43091. /**
  43092. * Creates the lines for a light mesh
  43093. */
  43094. private static _createLightLines;
  43095. private static _CreateHemisphericLightMesh;
  43096. private static _CreatePointLightMesh;
  43097. private static _CreateSpotLightMesh;
  43098. private static _CreateDirectionalLightMesh;
  43099. }
  43100. }
  43101. declare module BABYLON {
  43102. /** @hidden */
  43103. export var backgroundFragmentDeclaration: {
  43104. name: string;
  43105. shader: string;
  43106. };
  43107. }
  43108. declare module BABYLON {
  43109. /** @hidden */
  43110. export var backgroundUboDeclaration: {
  43111. name: string;
  43112. shader: string;
  43113. };
  43114. }
  43115. declare module BABYLON {
  43116. /** @hidden */
  43117. export var backgroundPixelShader: {
  43118. name: string;
  43119. shader: string;
  43120. };
  43121. }
  43122. declare module BABYLON {
  43123. /** @hidden */
  43124. export var backgroundVertexDeclaration: {
  43125. name: string;
  43126. shader: string;
  43127. };
  43128. }
  43129. declare module BABYLON {
  43130. /** @hidden */
  43131. export var backgroundVertexShader: {
  43132. name: string;
  43133. shader: string;
  43134. };
  43135. }
  43136. declare module BABYLON {
  43137. /**
  43138. * Background material used to create an efficient environement around your scene.
  43139. */
  43140. export class BackgroundMaterial extends PushMaterial {
  43141. /**
  43142. * Standard reflectance value at parallel view angle.
  43143. */
  43144. static StandardReflectance0: number;
  43145. /**
  43146. * Standard reflectance value at grazing angle.
  43147. */
  43148. static StandardReflectance90: number;
  43149. protected _primaryColor: Color3;
  43150. /**
  43151. * Key light Color (multiply against the environement texture)
  43152. */
  43153. primaryColor: Color3;
  43154. protected __perceptualColor: Nullable<Color3>;
  43155. /**
  43156. * Experimental Internal Use Only.
  43157. *
  43158. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43159. * This acts as a helper to set the primary color to a more "human friendly" value.
  43160. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43161. * output color as close as possible from the chosen value.
  43162. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43163. * part of lighting setup.)
  43164. */
  43165. _perceptualColor: Nullable<Color3>;
  43166. protected _primaryColorShadowLevel: float;
  43167. /**
  43168. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43169. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43170. */
  43171. primaryColorShadowLevel: float;
  43172. protected _primaryColorHighlightLevel: float;
  43173. /**
  43174. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43175. * The primary color is used at the level chosen to define what the white area would look.
  43176. */
  43177. primaryColorHighlightLevel: float;
  43178. protected _reflectionTexture: Nullable<BaseTexture>;
  43179. /**
  43180. * Reflection Texture used in the material.
  43181. * Should be author in a specific way for the best result (refer to the documentation).
  43182. */
  43183. reflectionTexture: Nullable<BaseTexture>;
  43184. protected _reflectionBlur: float;
  43185. /**
  43186. * Reflection Texture level of blur.
  43187. *
  43188. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43189. * texture twice.
  43190. */
  43191. reflectionBlur: float;
  43192. protected _diffuseTexture: Nullable<BaseTexture>;
  43193. /**
  43194. * Diffuse Texture used in the material.
  43195. * Should be author in a specific way for the best result (refer to the documentation).
  43196. */
  43197. diffuseTexture: Nullable<BaseTexture>;
  43198. protected _shadowLights: Nullable<IShadowLight[]>;
  43199. /**
  43200. * Specify the list of lights casting shadow on the material.
  43201. * All scene shadow lights will be included if null.
  43202. */
  43203. shadowLights: Nullable<IShadowLight[]>;
  43204. protected _shadowLevel: float;
  43205. /**
  43206. * Helps adjusting the shadow to a softer level if required.
  43207. * 0 means black shadows and 1 means no shadows.
  43208. */
  43209. shadowLevel: float;
  43210. protected _sceneCenter: Vector3;
  43211. /**
  43212. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43213. * It is usually zero but might be interesting to modify according to your setup.
  43214. */
  43215. sceneCenter: Vector3;
  43216. protected _opacityFresnel: boolean;
  43217. /**
  43218. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43219. * This helps ensuring a nice transition when the camera goes under the ground.
  43220. */
  43221. opacityFresnel: boolean;
  43222. protected _reflectionFresnel: boolean;
  43223. /**
  43224. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43225. * This helps adding a mirror texture on the ground.
  43226. */
  43227. reflectionFresnel: boolean;
  43228. protected _reflectionFalloffDistance: number;
  43229. /**
  43230. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43231. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43232. */
  43233. reflectionFalloffDistance: number;
  43234. protected _reflectionAmount: number;
  43235. /**
  43236. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43237. */
  43238. reflectionAmount: number;
  43239. protected _reflectionReflectance0: number;
  43240. /**
  43241. * This specifies the weight of the reflection at grazing angle.
  43242. */
  43243. reflectionReflectance0: number;
  43244. protected _reflectionReflectance90: number;
  43245. /**
  43246. * This specifies the weight of the reflection at a perpendicular point of view.
  43247. */
  43248. reflectionReflectance90: number;
  43249. /**
  43250. * Sets the reflection reflectance fresnel values according to the default standard
  43251. * empirically know to work well :-)
  43252. */
  43253. reflectionStandardFresnelWeight: number;
  43254. protected _useRGBColor: boolean;
  43255. /**
  43256. * Helps to directly use the maps channels instead of their level.
  43257. */
  43258. useRGBColor: boolean;
  43259. protected _enableNoise: boolean;
  43260. /**
  43261. * This helps reducing the banding effect that could occur on the background.
  43262. */
  43263. enableNoise: boolean;
  43264. /**
  43265. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43266. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43267. * Recommended to be keep at 1.0 except for special cases.
  43268. */
  43269. fovMultiplier: number;
  43270. private _fovMultiplier;
  43271. /**
  43272. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43273. */
  43274. useEquirectangularFOV: boolean;
  43275. private _maxSimultaneousLights;
  43276. /**
  43277. * Number of Simultaneous lights allowed on the material.
  43278. */
  43279. maxSimultaneousLights: int;
  43280. /**
  43281. * Default configuration related to image processing available in the Background Material.
  43282. */
  43283. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43284. /**
  43285. * Keep track of the image processing observer to allow dispose and replace.
  43286. */
  43287. private _imageProcessingObserver;
  43288. /**
  43289. * Attaches a new image processing configuration to the PBR Material.
  43290. * @param configuration (if null the scene configuration will be use)
  43291. */
  43292. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43293. /**
  43294. * Gets the image processing configuration used either in this material.
  43295. */
  43296. /**
  43297. * Sets the Default image processing configuration used either in the this material.
  43298. *
  43299. * If sets to null, the scene one is in use.
  43300. */
  43301. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43302. /**
  43303. * Gets wether the color curves effect is enabled.
  43304. */
  43305. /**
  43306. * Sets wether the color curves effect is enabled.
  43307. */
  43308. cameraColorCurvesEnabled: boolean;
  43309. /**
  43310. * Gets wether the color grading effect is enabled.
  43311. */
  43312. /**
  43313. * Gets wether the color grading effect is enabled.
  43314. */
  43315. cameraColorGradingEnabled: boolean;
  43316. /**
  43317. * Gets wether tonemapping is enabled or not.
  43318. */
  43319. /**
  43320. * Sets wether tonemapping is enabled or not
  43321. */
  43322. cameraToneMappingEnabled: boolean;
  43323. /**
  43324. * The camera exposure used on this material.
  43325. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43326. * This corresponds to a photographic exposure.
  43327. */
  43328. /**
  43329. * The camera exposure used on this material.
  43330. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43331. * This corresponds to a photographic exposure.
  43332. */
  43333. cameraExposure: float;
  43334. /**
  43335. * Gets The camera contrast used on this material.
  43336. */
  43337. /**
  43338. * Sets The camera contrast used on this material.
  43339. */
  43340. cameraContrast: float;
  43341. /**
  43342. * Gets the Color Grading 2D Lookup Texture.
  43343. */
  43344. /**
  43345. * Sets the Color Grading 2D Lookup Texture.
  43346. */
  43347. cameraColorGradingTexture: Nullable<BaseTexture>;
  43348. /**
  43349. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43350. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43351. * 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;
  43352. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43353. */
  43354. /**
  43355. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43356. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43357. * 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;
  43358. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43359. */
  43360. cameraColorCurves: Nullable<ColorCurves>;
  43361. /**
  43362. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43363. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43364. */
  43365. switchToBGR: boolean;
  43366. private _renderTargets;
  43367. private _reflectionControls;
  43368. private _white;
  43369. private _primaryShadowColor;
  43370. private _primaryHighlightColor;
  43371. /**
  43372. * Instantiates a Background Material in the given scene
  43373. * @param name The friendly name of the material
  43374. * @param scene The scene to add the material to
  43375. */
  43376. constructor(name: string, scene: Scene);
  43377. /**
  43378. * Gets a boolean indicating that current material needs to register RTT
  43379. */
  43380. readonly hasRenderTargetTextures: boolean;
  43381. /**
  43382. * The entire material has been created in order to prevent overdraw.
  43383. * @returns false
  43384. */
  43385. needAlphaTesting(): boolean;
  43386. /**
  43387. * The entire material has been created in order to prevent overdraw.
  43388. * @returns true if blending is enable
  43389. */
  43390. needAlphaBlending(): boolean;
  43391. /**
  43392. * Checks wether the material is ready to be rendered for a given mesh.
  43393. * @param mesh The mesh to render
  43394. * @param subMesh The submesh to check against
  43395. * @param useInstances Specify wether or not the material is used with instances
  43396. * @returns true if all the dependencies are ready (Textures, Effects...)
  43397. */
  43398. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43399. /**
  43400. * Compute the primary color according to the chosen perceptual color.
  43401. */
  43402. private _computePrimaryColorFromPerceptualColor;
  43403. /**
  43404. * Compute the highlights and shadow colors according to their chosen levels.
  43405. */
  43406. private _computePrimaryColors;
  43407. /**
  43408. * Build the uniform buffer used in the material.
  43409. */
  43410. buildUniformLayout(): void;
  43411. /**
  43412. * Unbind the material.
  43413. */
  43414. unbind(): void;
  43415. /**
  43416. * Bind only the world matrix to the material.
  43417. * @param world The world matrix to bind.
  43418. */
  43419. bindOnlyWorldMatrix(world: Matrix): void;
  43420. /**
  43421. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43422. * @param world The world matrix to bind.
  43423. * @param subMesh The submesh to bind for.
  43424. */
  43425. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43426. /**
  43427. * Dispose the material.
  43428. * @param forceDisposeEffect Force disposal of the associated effect.
  43429. * @param forceDisposeTextures Force disposal of the associated textures.
  43430. */
  43431. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43432. /**
  43433. * Clones the material.
  43434. * @param name The cloned name.
  43435. * @returns The cloned material.
  43436. */
  43437. clone(name: string): BackgroundMaterial;
  43438. /**
  43439. * Serializes the current material to its JSON representation.
  43440. * @returns The JSON representation.
  43441. */
  43442. serialize(): any;
  43443. /**
  43444. * Gets the class name of the material
  43445. * @returns "BackgroundMaterial"
  43446. */
  43447. getClassName(): string;
  43448. /**
  43449. * Parse a JSON input to create back a background material.
  43450. * @param source The JSON data to parse
  43451. * @param scene The scene to create the parsed material in
  43452. * @param rootUrl The root url of the assets the material depends upon
  43453. * @returns the instantiated BackgroundMaterial.
  43454. */
  43455. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43456. }
  43457. }
  43458. declare module BABYLON {
  43459. /**
  43460. * Represents the different options available during the creation of
  43461. * a Environment helper.
  43462. *
  43463. * This can control the default ground, skybox and image processing setup of your scene.
  43464. */
  43465. export interface IEnvironmentHelperOptions {
  43466. /**
  43467. * Specifies wether or not to create a ground.
  43468. * True by default.
  43469. */
  43470. createGround: boolean;
  43471. /**
  43472. * Specifies the ground size.
  43473. * 15 by default.
  43474. */
  43475. groundSize: number;
  43476. /**
  43477. * The texture used on the ground for the main color.
  43478. * Comes from the BabylonJS CDN by default.
  43479. *
  43480. * Remarks: Can be either a texture or a url.
  43481. */
  43482. groundTexture: string | BaseTexture;
  43483. /**
  43484. * The color mixed in the ground texture by default.
  43485. * BabylonJS clearColor by default.
  43486. */
  43487. groundColor: Color3;
  43488. /**
  43489. * Specifies the ground opacity.
  43490. * 1 by default.
  43491. */
  43492. groundOpacity: number;
  43493. /**
  43494. * Enables the ground to receive shadows.
  43495. * True by default.
  43496. */
  43497. enableGroundShadow: boolean;
  43498. /**
  43499. * Helps preventing the shadow to be fully black on the ground.
  43500. * 0.5 by default.
  43501. */
  43502. groundShadowLevel: number;
  43503. /**
  43504. * Creates a mirror texture attach to the ground.
  43505. * false by default.
  43506. */
  43507. enableGroundMirror: boolean;
  43508. /**
  43509. * Specifies the ground mirror size ratio.
  43510. * 0.3 by default as the default kernel is 64.
  43511. */
  43512. groundMirrorSizeRatio: number;
  43513. /**
  43514. * Specifies the ground mirror blur kernel size.
  43515. * 64 by default.
  43516. */
  43517. groundMirrorBlurKernel: number;
  43518. /**
  43519. * Specifies the ground mirror visibility amount.
  43520. * 1 by default
  43521. */
  43522. groundMirrorAmount: number;
  43523. /**
  43524. * Specifies the ground mirror reflectance weight.
  43525. * This uses the standard weight of the background material to setup the fresnel effect
  43526. * of the mirror.
  43527. * 1 by default.
  43528. */
  43529. groundMirrorFresnelWeight: number;
  43530. /**
  43531. * Specifies the ground mirror Falloff distance.
  43532. * This can helps reducing the size of the reflection.
  43533. * 0 by Default.
  43534. */
  43535. groundMirrorFallOffDistance: number;
  43536. /**
  43537. * Specifies the ground mirror texture type.
  43538. * Unsigned Int by Default.
  43539. */
  43540. groundMirrorTextureType: number;
  43541. /**
  43542. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43543. * the shown objects.
  43544. */
  43545. groundYBias: number;
  43546. /**
  43547. * Specifies wether or not to create a skybox.
  43548. * True by default.
  43549. */
  43550. createSkybox: boolean;
  43551. /**
  43552. * Specifies the skybox size.
  43553. * 20 by default.
  43554. */
  43555. skyboxSize: number;
  43556. /**
  43557. * The texture used on the skybox for the main color.
  43558. * Comes from the BabylonJS CDN by default.
  43559. *
  43560. * Remarks: Can be either a texture or a url.
  43561. */
  43562. skyboxTexture: string | BaseTexture;
  43563. /**
  43564. * The color mixed in the skybox texture by default.
  43565. * BabylonJS clearColor by default.
  43566. */
  43567. skyboxColor: Color3;
  43568. /**
  43569. * The background rotation around the Y axis of the scene.
  43570. * This helps aligning the key lights of your scene with the background.
  43571. * 0 by default.
  43572. */
  43573. backgroundYRotation: number;
  43574. /**
  43575. * Compute automatically the size of the elements to best fit with the scene.
  43576. */
  43577. sizeAuto: boolean;
  43578. /**
  43579. * Default position of the rootMesh if autoSize is not true.
  43580. */
  43581. rootPosition: Vector3;
  43582. /**
  43583. * Sets up the image processing in the scene.
  43584. * true by default.
  43585. */
  43586. setupImageProcessing: boolean;
  43587. /**
  43588. * The texture used as your environment texture in the scene.
  43589. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43590. *
  43591. * Remarks: Can be either a texture or a url.
  43592. */
  43593. environmentTexture: string | BaseTexture;
  43594. /**
  43595. * The value of the exposure to apply to the scene.
  43596. * 0.6 by default if setupImageProcessing is true.
  43597. */
  43598. cameraExposure: number;
  43599. /**
  43600. * The value of the contrast to apply to the scene.
  43601. * 1.6 by default if setupImageProcessing is true.
  43602. */
  43603. cameraContrast: number;
  43604. /**
  43605. * Specifies wether or not tonemapping should be enabled in the scene.
  43606. * true by default if setupImageProcessing is true.
  43607. */
  43608. toneMappingEnabled: boolean;
  43609. }
  43610. /**
  43611. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43612. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43613. * It also helps with the default setup of your imageProcessing configuration.
  43614. */
  43615. export class EnvironmentHelper {
  43616. /**
  43617. * Default ground texture URL.
  43618. */
  43619. private static _groundTextureCDNUrl;
  43620. /**
  43621. * Default skybox texture URL.
  43622. */
  43623. private static _skyboxTextureCDNUrl;
  43624. /**
  43625. * Default environment texture URL.
  43626. */
  43627. private static _environmentTextureCDNUrl;
  43628. /**
  43629. * Creates the default options for the helper.
  43630. */
  43631. private static _getDefaultOptions;
  43632. private _rootMesh;
  43633. /**
  43634. * Gets the root mesh created by the helper.
  43635. */
  43636. readonly rootMesh: Mesh;
  43637. private _skybox;
  43638. /**
  43639. * Gets the skybox created by the helper.
  43640. */
  43641. readonly skybox: Nullable<Mesh>;
  43642. private _skyboxTexture;
  43643. /**
  43644. * Gets the skybox texture created by the helper.
  43645. */
  43646. readonly skyboxTexture: Nullable<BaseTexture>;
  43647. private _skyboxMaterial;
  43648. /**
  43649. * Gets the skybox material created by the helper.
  43650. */
  43651. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43652. private _ground;
  43653. /**
  43654. * Gets the ground mesh created by the helper.
  43655. */
  43656. readonly ground: Nullable<Mesh>;
  43657. private _groundTexture;
  43658. /**
  43659. * Gets the ground texture created by the helper.
  43660. */
  43661. readonly groundTexture: Nullable<BaseTexture>;
  43662. private _groundMirror;
  43663. /**
  43664. * Gets the ground mirror created by the helper.
  43665. */
  43666. readonly groundMirror: Nullable<MirrorTexture>;
  43667. /**
  43668. * Gets the ground mirror render list to helps pushing the meshes
  43669. * you wish in the ground reflection.
  43670. */
  43671. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43672. private _groundMaterial;
  43673. /**
  43674. * Gets the ground material created by the helper.
  43675. */
  43676. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43677. /**
  43678. * Stores the creation options.
  43679. */
  43680. private readonly _scene;
  43681. private _options;
  43682. /**
  43683. * This observable will be notified with any error during the creation of the environment,
  43684. * mainly texture creation errors.
  43685. */
  43686. onErrorObservable: Observable<{
  43687. message?: string;
  43688. exception?: any;
  43689. }>;
  43690. /**
  43691. * constructor
  43692. * @param options Defines the options we want to customize the helper
  43693. * @param scene The scene to add the material to
  43694. */
  43695. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43696. /**
  43697. * Updates the background according to the new options
  43698. * @param options
  43699. */
  43700. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43701. /**
  43702. * Sets the primary color of all the available elements.
  43703. * @param color the main color to affect to the ground and the background
  43704. */
  43705. setMainColor(color: Color3): void;
  43706. /**
  43707. * Setup the image processing according to the specified options.
  43708. */
  43709. private _setupImageProcessing;
  43710. /**
  43711. * Setup the environment texture according to the specified options.
  43712. */
  43713. private _setupEnvironmentTexture;
  43714. /**
  43715. * Setup the background according to the specified options.
  43716. */
  43717. private _setupBackground;
  43718. /**
  43719. * Get the scene sizes according to the setup.
  43720. */
  43721. private _getSceneSize;
  43722. /**
  43723. * Setup the ground according to the specified options.
  43724. */
  43725. private _setupGround;
  43726. /**
  43727. * Setup the ground material according to the specified options.
  43728. */
  43729. private _setupGroundMaterial;
  43730. /**
  43731. * Setup the ground diffuse texture according to the specified options.
  43732. */
  43733. private _setupGroundDiffuseTexture;
  43734. /**
  43735. * Setup the ground mirror texture according to the specified options.
  43736. */
  43737. private _setupGroundMirrorTexture;
  43738. /**
  43739. * Setup the ground to receive the mirror texture.
  43740. */
  43741. private _setupMirrorInGroundMaterial;
  43742. /**
  43743. * Setup the skybox according to the specified options.
  43744. */
  43745. private _setupSkybox;
  43746. /**
  43747. * Setup the skybox material according to the specified options.
  43748. */
  43749. private _setupSkyboxMaterial;
  43750. /**
  43751. * Setup the skybox reflection texture according to the specified options.
  43752. */
  43753. private _setupSkyboxReflectionTexture;
  43754. private _errorHandler;
  43755. /**
  43756. * Dispose all the elements created by the Helper.
  43757. */
  43758. dispose(): void;
  43759. }
  43760. }
  43761. declare module BABYLON {
  43762. /**
  43763. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43764. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43765. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43766. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43767. */
  43768. export class PhotoDome extends TransformNode {
  43769. private _useDirectMapping;
  43770. /**
  43771. * The texture being displayed on the sphere
  43772. */
  43773. protected _photoTexture: Texture;
  43774. /**
  43775. * Gets or sets the texture being displayed on the sphere
  43776. */
  43777. photoTexture: Texture;
  43778. /**
  43779. * Observable raised when an error occured while loading the 360 image
  43780. */
  43781. onLoadErrorObservable: Observable<string>;
  43782. /**
  43783. * The skybox material
  43784. */
  43785. protected _material: BackgroundMaterial;
  43786. /**
  43787. * The surface used for the skybox
  43788. */
  43789. protected _mesh: Mesh;
  43790. /**
  43791. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43792. * Also see the options.resolution property.
  43793. */
  43794. fovMultiplier: number;
  43795. /**
  43796. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43797. * @param name Element's name, child elements will append suffixes for their own names.
  43798. * @param urlsOfPhoto defines the url of the photo to display
  43799. * @param options defines an object containing optional or exposed sub element properties
  43800. * @param onError defines a callback called when an error occured while loading the texture
  43801. */
  43802. constructor(name: string, urlOfPhoto: string, options: {
  43803. resolution?: number;
  43804. size?: number;
  43805. useDirectMapping?: boolean;
  43806. faceForward?: boolean;
  43807. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43808. /**
  43809. * Releases resources associated with this node.
  43810. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43811. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43812. */
  43813. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43814. }
  43815. }
  43816. declare module BABYLON {
  43817. /** @hidden */
  43818. export var rgbdDecodePixelShader: {
  43819. name: string;
  43820. shader: string;
  43821. };
  43822. }
  43823. declare module BABYLON {
  43824. /**
  43825. * Class used to host texture specific utilities
  43826. */
  43827. export class BRDFTextureTools {
  43828. /**
  43829. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43830. * @param texture the texture to expand.
  43831. */
  43832. private static _ExpandDefaultBRDFTexture;
  43833. /**
  43834. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43835. * @param scene defines the hosting scene
  43836. * @returns the environment BRDF texture
  43837. */
  43838. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43839. private static _environmentBRDFBase64Texture;
  43840. }
  43841. }
  43842. declare module BABYLON {
  43843. /**
  43844. * @hidden
  43845. */
  43846. export interface IMaterialClearCoatDefines {
  43847. CLEARCOAT: boolean;
  43848. CLEARCOAT_DEFAULTIOR: boolean;
  43849. CLEARCOAT_TEXTURE: boolean;
  43850. CLEARCOAT_TEXTUREDIRECTUV: number;
  43851. CLEARCOAT_BUMP: boolean;
  43852. CLEARCOAT_BUMPDIRECTUV: number;
  43853. CLEARCOAT_TINT: boolean;
  43854. CLEARCOAT_TINT_TEXTURE: boolean;
  43855. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43856. /** @hidden */
  43857. _areTexturesDirty: boolean;
  43858. }
  43859. /**
  43860. * Define the code related to the clear coat parameters of the pbr material.
  43861. */
  43862. export class PBRClearCoatConfiguration {
  43863. /**
  43864. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43865. * The default fits with a polyurethane material.
  43866. */
  43867. private static readonly _DefaultIndiceOfRefraction;
  43868. private _isEnabled;
  43869. /**
  43870. * Defines if the clear coat is enabled in the material.
  43871. */
  43872. isEnabled: boolean;
  43873. /**
  43874. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43875. */
  43876. intensity: number;
  43877. /**
  43878. * Defines the clear coat layer roughness.
  43879. */
  43880. roughness: number;
  43881. private _indiceOfRefraction;
  43882. /**
  43883. * Defines the indice of refraction of the clear coat.
  43884. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43885. * The default fits with a polyurethane material.
  43886. * Changing the default value is more performance intensive.
  43887. */
  43888. indiceOfRefraction: number;
  43889. private _texture;
  43890. /**
  43891. * Stores the clear coat values in a texture.
  43892. */
  43893. texture: Nullable<BaseTexture>;
  43894. private _bumpTexture;
  43895. /**
  43896. * Define the clear coat specific bump texture.
  43897. */
  43898. bumpTexture: Nullable<BaseTexture>;
  43899. private _isTintEnabled;
  43900. /**
  43901. * Defines if the clear coat tint is enabled in the material.
  43902. */
  43903. isTintEnabled: boolean;
  43904. /**
  43905. * Defines the clear coat tint of the material.
  43906. * This is only use if tint is enabled
  43907. */
  43908. tintColor: Color3;
  43909. /**
  43910. * Defines the distance at which the tint color should be found in the
  43911. * clear coat media.
  43912. * This is only use if tint is enabled
  43913. */
  43914. tintColorAtDistance: number;
  43915. /**
  43916. * Defines the clear coat layer thickness.
  43917. * This is only use if tint is enabled
  43918. */
  43919. tintThickness: number;
  43920. private _tintTexture;
  43921. /**
  43922. * Stores the clear tint values in a texture.
  43923. * rgb is tint
  43924. * a is a thickness factor
  43925. */
  43926. tintTexture: Nullable<BaseTexture>;
  43927. /** @hidden */
  43928. private _internalMarkAllSubMeshesAsTexturesDirty;
  43929. /** @hidden */
  43930. _markAllSubMeshesAsTexturesDirty(): void;
  43931. /**
  43932. * Instantiate a new istance of clear coat configuration.
  43933. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43934. */
  43935. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43936. /**
  43937. * Gets wehter the submesh is ready to be used or not.
  43938. * @param defines the list of "defines" to update.
  43939. * @param scene defines the scene the material belongs to.
  43940. * @param engine defines the engine the material belongs to.
  43941. * @param disableBumpMap defines wether the material disables bump or not.
  43942. * @returns - boolean indicating that the submesh is ready or not.
  43943. */
  43944. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43945. /**
  43946. * Checks to see if a texture is used in the material.
  43947. * @param defines the list of "defines" to update.
  43948. * @param scene defines the scene to the material belongs to.
  43949. */
  43950. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43951. /**
  43952. * Binds the material data.
  43953. * @param uniformBuffer defines the Uniform buffer to fill in.
  43954. * @param scene defines the scene the material belongs to.
  43955. * @param engine defines the engine the material belongs to.
  43956. * @param disableBumpMap defines wether the material disables bump or not.
  43957. * @param isFrozen defines wether the material is frozen or not.
  43958. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43959. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43960. */
  43961. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43962. /**
  43963. * Checks to see if a texture is used in the material.
  43964. * @param texture - Base texture to use.
  43965. * @returns - Boolean specifying if a texture is used in the material.
  43966. */
  43967. hasTexture(texture: BaseTexture): boolean;
  43968. /**
  43969. * Returns an array of the actively used textures.
  43970. * @param activeTextures Array of BaseTextures
  43971. */
  43972. getActiveTextures(activeTextures: BaseTexture[]): void;
  43973. /**
  43974. * Returns the animatable textures.
  43975. * @param animatables Array of animatable textures.
  43976. */
  43977. getAnimatables(animatables: IAnimatable[]): void;
  43978. /**
  43979. * Disposes the resources of the material.
  43980. * @param forceDisposeTextures - Forces the disposal of all textures.
  43981. */
  43982. dispose(forceDisposeTextures?: boolean): void;
  43983. /**
  43984. * Get the current class name of the texture useful for serialization or dynamic coding.
  43985. * @returns "PBRClearCoatConfiguration"
  43986. */
  43987. getClassName(): string;
  43988. /**
  43989. * Add fallbacks to the effect fallbacks list.
  43990. * @param defines defines the Base texture to use.
  43991. * @param fallbacks defines the current fallback list.
  43992. * @param currentRank defines the current fallback rank.
  43993. * @returns the new fallback rank.
  43994. */
  43995. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43996. /**
  43997. * Add the required uniforms to the current list.
  43998. * @param uniforms defines the current uniform list.
  43999. */
  44000. static AddUniforms(uniforms: string[]): void;
  44001. /**
  44002. * Add the required samplers to the current list.
  44003. * @param samplers defines the current sampler list.
  44004. */
  44005. static AddSamplers(samplers: string[]): void;
  44006. /**
  44007. * Add the required uniforms to the current buffer.
  44008. * @param uniformBuffer defines the current uniform buffer.
  44009. */
  44010. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44011. /**
  44012. * Makes a duplicate of the current configuration into another one.
  44013. * @param clearCoatConfiguration define the config where to copy the info
  44014. */
  44015. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44016. /**
  44017. * Serializes this clear coat configuration.
  44018. * @returns - An object with the serialized config.
  44019. */
  44020. serialize(): any;
  44021. /**
  44022. * Parses a Clear Coat Configuration from a serialized object.
  44023. * @param source - Serialized object.
  44024. */
  44025. parse(source: any): void;
  44026. }
  44027. }
  44028. declare module BABYLON {
  44029. /**
  44030. * @hidden
  44031. */
  44032. export interface IMaterialAnisotropicDefines {
  44033. ANISOTROPIC: boolean;
  44034. ANISOTROPIC_TEXTURE: boolean;
  44035. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44036. MAINUV1: boolean;
  44037. _areTexturesDirty: boolean;
  44038. _needUVs: boolean;
  44039. }
  44040. /**
  44041. * Define the code related to the anisotropic parameters of the pbr material.
  44042. */
  44043. export class PBRAnisotropicConfiguration {
  44044. private _isEnabled;
  44045. /**
  44046. * Defines if the anisotropy is enabled in the material.
  44047. */
  44048. isEnabled: boolean;
  44049. /**
  44050. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44051. */
  44052. intensity: number;
  44053. /**
  44054. * Defines if the effect is along the tangents, bitangents or in between.
  44055. * By default, the effect is "strectching" the highlights along the tangents.
  44056. */
  44057. direction: Vector2;
  44058. private _texture;
  44059. /**
  44060. * Stores the anisotropy values in a texture.
  44061. * rg is direction (like normal from -1 to 1)
  44062. * b is a intensity
  44063. */
  44064. texture: Nullable<BaseTexture>;
  44065. /** @hidden */
  44066. private _internalMarkAllSubMeshesAsTexturesDirty;
  44067. /** @hidden */
  44068. _markAllSubMeshesAsTexturesDirty(): void;
  44069. /**
  44070. * Instantiate a new istance of anisotropy configuration.
  44071. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44072. */
  44073. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44074. /**
  44075. * Specifies that the submesh is ready to be used.
  44076. * @param defines the list of "defines" to update.
  44077. * @param scene defines the scene the material belongs to.
  44078. * @returns - boolean indicating that the submesh is ready or not.
  44079. */
  44080. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44081. /**
  44082. * Checks to see if a texture is used in the material.
  44083. * @param defines the list of "defines" to update.
  44084. * @param mesh the mesh we are preparing the defines for.
  44085. * @param scene defines the scene the material belongs to.
  44086. */
  44087. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44088. /**
  44089. * Binds the material data.
  44090. * @param uniformBuffer defines the Uniform buffer to fill in.
  44091. * @param scene defines the scene the material belongs to.
  44092. * @param isFrozen defines wether the material is frozen or not.
  44093. */
  44094. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44095. /**
  44096. * Checks to see if a texture is used in the material.
  44097. * @param texture - Base texture to use.
  44098. * @returns - Boolean specifying if a texture is used in the material.
  44099. */
  44100. hasTexture(texture: BaseTexture): boolean;
  44101. /**
  44102. * Returns an array of the actively used textures.
  44103. * @param activeTextures Array of BaseTextures
  44104. */
  44105. getActiveTextures(activeTextures: BaseTexture[]): void;
  44106. /**
  44107. * Returns the animatable textures.
  44108. * @param animatables Array of animatable textures.
  44109. */
  44110. getAnimatables(animatables: IAnimatable[]): void;
  44111. /**
  44112. * Disposes the resources of the material.
  44113. * @param forceDisposeTextures - Forces the disposal of all textures.
  44114. */
  44115. dispose(forceDisposeTextures?: boolean): void;
  44116. /**
  44117. * Get the current class name of the texture useful for serialization or dynamic coding.
  44118. * @returns "PBRAnisotropicConfiguration"
  44119. */
  44120. getClassName(): string;
  44121. /**
  44122. * Add fallbacks to the effect fallbacks list.
  44123. * @param defines defines the Base texture to use.
  44124. * @param fallbacks defines the current fallback list.
  44125. * @param currentRank defines the current fallback rank.
  44126. * @returns the new fallback rank.
  44127. */
  44128. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44129. /**
  44130. * Add the required uniforms to the current list.
  44131. * @param uniforms defines the current uniform list.
  44132. */
  44133. static AddUniforms(uniforms: string[]): void;
  44134. /**
  44135. * Add the required uniforms to the current buffer.
  44136. * @param uniformBuffer defines the current uniform buffer.
  44137. */
  44138. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44139. /**
  44140. * Add the required samplers to the current list.
  44141. * @param samplers defines the current sampler list.
  44142. */
  44143. static AddSamplers(samplers: string[]): void;
  44144. /**
  44145. * Makes a duplicate of the current configuration into another one.
  44146. * @param anisotropicConfiguration define the config where to copy the info
  44147. */
  44148. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44149. /**
  44150. * Serializes this anisotropy configuration.
  44151. * @returns - An object with the serialized config.
  44152. */
  44153. serialize(): any;
  44154. /**
  44155. * Parses a anisotropy Configuration from a serialized object.
  44156. * @param source - Serialized object.
  44157. */
  44158. parse(source: any): void;
  44159. }
  44160. }
  44161. declare module BABYLON {
  44162. /**
  44163. * @hidden
  44164. */
  44165. export interface IMaterialBRDFDefines {
  44166. BRDF_V_HEIGHT_CORRELATED: boolean;
  44167. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44168. /** @hidden */
  44169. _areMiscDirty: boolean;
  44170. }
  44171. /**
  44172. * Define the code related to the BRDF parameters of the pbr material.
  44173. */
  44174. export class PBRBRDFConfiguration {
  44175. /**
  44176. * Default value used for the energy conservation.
  44177. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44178. */
  44179. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44180. /**
  44181. * Default value used for the Smith Visibility Height Correlated mode.
  44182. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44183. */
  44184. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44185. private _useEnergyConservation;
  44186. /**
  44187. * Defines if the material uses energy conservation.
  44188. */
  44189. useEnergyConservation: boolean;
  44190. private _useSmithVisibilityHeightCorrelated;
  44191. /**
  44192. * LEGACY Mode set to false
  44193. * Defines if the material uses height smith correlated visibility term.
  44194. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44195. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44196. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44197. * Not relying on height correlated will also disable energy conservation.
  44198. */
  44199. useSmithVisibilityHeightCorrelated: boolean;
  44200. /** @hidden */
  44201. private _internalMarkAllSubMeshesAsMiscDirty;
  44202. /** @hidden */
  44203. _markAllSubMeshesAsMiscDirty(): void;
  44204. /**
  44205. * Instantiate a new istance of clear coat configuration.
  44206. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44207. */
  44208. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44209. /**
  44210. * Checks to see if a texture is used in the material.
  44211. * @param defines the list of "defines" to update.
  44212. */
  44213. prepareDefines(defines: IMaterialBRDFDefines): void;
  44214. /**
  44215. * Get the current class name of the texture useful for serialization or dynamic coding.
  44216. * @returns "PBRClearCoatConfiguration"
  44217. */
  44218. getClassName(): string;
  44219. /**
  44220. * Makes a duplicate of the current configuration into another one.
  44221. * @param brdfConfiguration define the config where to copy the info
  44222. */
  44223. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44224. /**
  44225. * Serializes this BRDF configuration.
  44226. * @returns - An object with the serialized config.
  44227. */
  44228. serialize(): any;
  44229. /**
  44230. * Parses a BRDF Configuration from a serialized object.
  44231. * @param source - Serialized object.
  44232. */
  44233. parse(source: any): void;
  44234. }
  44235. }
  44236. declare module BABYLON {
  44237. /**
  44238. * @hidden
  44239. */
  44240. export interface IMaterialSheenDefines {
  44241. SHEEN: boolean;
  44242. SHEEN_TEXTURE: boolean;
  44243. SHEEN_TEXTUREDIRECTUV: number;
  44244. SHEEN_LINKWITHALBEDO: boolean;
  44245. /** @hidden */
  44246. _areTexturesDirty: boolean;
  44247. }
  44248. /**
  44249. * Define the code related to the Sheen parameters of the pbr material.
  44250. */
  44251. export class PBRSheenConfiguration {
  44252. private _isEnabled;
  44253. /**
  44254. * Defines if the material uses sheen.
  44255. */
  44256. isEnabled: boolean;
  44257. private _linkSheenWithAlbedo;
  44258. /**
  44259. * Defines if the sheen is linked to the sheen color.
  44260. */
  44261. linkSheenWithAlbedo: boolean;
  44262. /**
  44263. * Defines the sheen intensity.
  44264. */
  44265. intensity: number;
  44266. /**
  44267. * Defines the sheen color.
  44268. */
  44269. color: Color3;
  44270. private _texture;
  44271. /**
  44272. * Stores the sheen tint values in a texture.
  44273. * rgb is tint
  44274. * a is a intensity
  44275. */
  44276. texture: Nullable<BaseTexture>;
  44277. /** @hidden */
  44278. private _internalMarkAllSubMeshesAsTexturesDirty;
  44279. /** @hidden */
  44280. _markAllSubMeshesAsTexturesDirty(): void;
  44281. /**
  44282. * Instantiate a new istance of clear coat configuration.
  44283. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44284. */
  44285. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44286. /**
  44287. * Specifies that the submesh is ready to be used.
  44288. * @param defines the list of "defines" to update.
  44289. * @param scene defines the scene the material belongs to.
  44290. * @returns - boolean indicating that the submesh is ready or not.
  44291. */
  44292. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44293. /**
  44294. * Checks to see if a texture is used in the material.
  44295. * @param defines the list of "defines" to update.
  44296. * @param scene defines the scene the material belongs to.
  44297. */
  44298. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44299. /**
  44300. * Binds the material data.
  44301. * @param uniformBuffer defines the Uniform buffer to fill in.
  44302. * @param scene defines the scene the material belongs to.
  44303. * @param isFrozen defines wether the material is frozen or not.
  44304. */
  44305. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44306. /**
  44307. * Checks to see if a texture is used in the material.
  44308. * @param texture - Base texture to use.
  44309. * @returns - Boolean specifying if a texture is used in the material.
  44310. */
  44311. hasTexture(texture: BaseTexture): boolean;
  44312. /**
  44313. * Returns an array of the actively used textures.
  44314. * @param activeTextures Array of BaseTextures
  44315. */
  44316. getActiveTextures(activeTextures: BaseTexture[]): void;
  44317. /**
  44318. * Returns the animatable textures.
  44319. * @param animatables Array of animatable textures.
  44320. */
  44321. getAnimatables(animatables: IAnimatable[]): void;
  44322. /**
  44323. * Disposes the resources of the material.
  44324. * @param forceDisposeTextures - Forces the disposal of all textures.
  44325. */
  44326. dispose(forceDisposeTextures?: boolean): void;
  44327. /**
  44328. * Get the current class name of the texture useful for serialization or dynamic coding.
  44329. * @returns "PBRSheenConfiguration"
  44330. */
  44331. getClassName(): string;
  44332. /**
  44333. * Add fallbacks to the effect fallbacks list.
  44334. * @param defines defines the Base texture to use.
  44335. * @param fallbacks defines the current fallback list.
  44336. * @param currentRank defines the current fallback rank.
  44337. * @returns the new fallback rank.
  44338. */
  44339. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44340. /**
  44341. * Add the required uniforms to the current list.
  44342. * @param uniforms defines the current uniform list.
  44343. */
  44344. static AddUniforms(uniforms: string[]): void;
  44345. /**
  44346. * Add the required uniforms to the current buffer.
  44347. * @param uniformBuffer defines the current uniform buffer.
  44348. */
  44349. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44350. /**
  44351. * Add the required samplers to the current list.
  44352. * @param samplers defines the current sampler list.
  44353. */
  44354. static AddSamplers(samplers: string[]): void;
  44355. /**
  44356. * Makes a duplicate of the current configuration into another one.
  44357. * @param sheenConfiguration define the config where to copy the info
  44358. */
  44359. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44360. /**
  44361. * Serializes this BRDF configuration.
  44362. * @returns - An object with the serialized config.
  44363. */
  44364. serialize(): any;
  44365. /**
  44366. * Parses a Sheen Configuration from a serialized object.
  44367. * @param source - Serialized object.
  44368. */
  44369. parse(source: any): void;
  44370. }
  44371. }
  44372. declare module BABYLON {
  44373. /**
  44374. * @hidden
  44375. */
  44376. export interface IMaterialSubSurfaceDefines {
  44377. SUBSURFACE: boolean;
  44378. SS_REFRACTION: boolean;
  44379. SS_TRANSLUCENCY: boolean;
  44380. SS_SCATERRING: boolean;
  44381. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44382. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44383. SS_REFRACTIONMAP_3D: boolean;
  44384. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44385. SS_LODINREFRACTIONALPHA: boolean;
  44386. SS_GAMMAREFRACTION: boolean;
  44387. SS_RGBDREFRACTION: boolean;
  44388. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44389. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44390. /** @hidden */
  44391. _areTexturesDirty: boolean;
  44392. }
  44393. /**
  44394. * Define the code related to the sub surface parameters of the pbr material.
  44395. */
  44396. export class PBRSubSurfaceConfiguration {
  44397. private _isRefractionEnabled;
  44398. /**
  44399. * Defines if the refraction is enabled in the material.
  44400. */
  44401. isRefractionEnabled: boolean;
  44402. private _isTranslucencyEnabled;
  44403. /**
  44404. * Defines if the translucency is enabled in the material.
  44405. */
  44406. isTranslucencyEnabled: boolean;
  44407. private _isScatteringEnabled;
  44408. /**
  44409. * Defines the refraction intensity of the material.
  44410. * The refraction when enabled replaces the Diffuse part of the material.
  44411. * The intensity helps transitionning between diffuse and refraction.
  44412. */
  44413. refractionIntensity: number;
  44414. /**
  44415. * Defines the translucency intensity of the material.
  44416. * When translucency has been enabled, this defines how much of the "translucency"
  44417. * is addded to the diffuse part of the material.
  44418. */
  44419. translucencyIntensity: number;
  44420. /**
  44421. * Defines the scattering intensity of the material.
  44422. * When scattering has been enabled, this defines how much of the "scattered light"
  44423. * is addded to the diffuse part of the material.
  44424. */
  44425. scatteringIntensity: number;
  44426. private _thicknessTexture;
  44427. /**
  44428. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44429. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44430. * 0 would mean minimumThickness
  44431. * 1 would mean maximumThickness
  44432. * The other channels might be use as a mask to vary the different effects intensity.
  44433. */
  44434. thicknessTexture: Nullable<BaseTexture>;
  44435. private _refractionTexture;
  44436. /**
  44437. * Defines the texture to use for refraction.
  44438. */
  44439. refractionTexture: Nullable<BaseTexture>;
  44440. private _indexOfRefraction;
  44441. /**
  44442. * Defines the indice of refraction used in the material.
  44443. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44444. */
  44445. indexOfRefraction: number;
  44446. private _invertRefractionY;
  44447. /**
  44448. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44449. */
  44450. invertRefractionY: boolean;
  44451. private _linkRefractionWithTransparency;
  44452. /**
  44453. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44454. * Materials half opaque for instance using refraction could benefit from this control.
  44455. */
  44456. linkRefractionWithTransparency: boolean;
  44457. /**
  44458. * Defines the minimum thickness stored in the thickness map.
  44459. * If no thickness map is defined, this value will be used to simulate thickness.
  44460. */
  44461. minimumThickness: number;
  44462. /**
  44463. * Defines the maximum thickness stored in the thickness map.
  44464. */
  44465. maximumThickness: number;
  44466. /**
  44467. * Defines the volume tint of the material.
  44468. * This is used for both translucency and scattering.
  44469. */
  44470. tintColor: Color3;
  44471. /**
  44472. * Defines the distance at which the tint color should be found in the media.
  44473. * This is used for refraction only.
  44474. */
  44475. tintColorAtDistance: number;
  44476. /**
  44477. * Defines how far each channel transmit through the media.
  44478. * It is defined as a color to simplify it selection.
  44479. */
  44480. diffusionDistance: Color3;
  44481. private _useMaskFromThicknessTexture;
  44482. /**
  44483. * Stores the intensity of the different subsurface effects in the thickness texture.
  44484. * * the green channel is the translucency intensity.
  44485. * * the blue channel is the scattering intensity.
  44486. * * the alpha channel is the refraction intensity.
  44487. */
  44488. useMaskFromThicknessTexture: boolean;
  44489. /** @hidden */
  44490. private _internalMarkAllSubMeshesAsTexturesDirty;
  44491. /** @hidden */
  44492. _markAllSubMeshesAsTexturesDirty(): void;
  44493. /**
  44494. * Instantiate a new istance of sub surface configuration.
  44495. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44496. */
  44497. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44498. /**
  44499. * Gets wehter the submesh is ready to be used or not.
  44500. * @param defines the list of "defines" to update.
  44501. * @param scene defines the scene the material belongs to.
  44502. * @returns - boolean indicating that the submesh is ready or not.
  44503. */
  44504. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44505. /**
  44506. * Checks to see if a texture is used in the material.
  44507. * @param defines the list of "defines" to update.
  44508. * @param scene defines the scene to the material belongs to.
  44509. */
  44510. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44511. /**
  44512. * Binds the material data.
  44513. * @param uniformBuffer defines the Uniform buffer to fill in.
  44514. * @param scene defines the scene the material belongs to.
  44515. * @param engine defines the engine the material belongs to.
  44516. * @param isFrozen defines wether the material is frozen or not.
  44517. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44518. */
  44519. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44520. /**
  44521. * Unbinds the material from the mesh.
  44522. * @param activeEffect defines the effect that should be unbound from.
  44523. * @returns true if unbound, otherwise false
  44524. */
  44525. unbind(activeEffect: Effect): boolean;
  44526. /**
  44527. * Returns the texture used for refraction or null if none is used.
  44528. * @param scene defines the scene the material belongs to.
  44529. * @returns - Refraction texture if present. If no refraction texture and refraction
  44530. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44531. */
  44532. private _getRefractionTexture;
  44533. /**
  44534. * Returns true if alpha blending should be disabled.
  44535. */
  44536. readonly disableAlphaBlending: boolean;
  44537. /**
  44538. * Fills the list of render target textures.
  44539. * @param renderTargets the list of render targets to update
  44540. */
  44541. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44542. /**
  44543. * Checks to see if a texture is used in the material.
  44544. * @param texture - Base texture to use.
  44545. * @returns - Boolean specifying if a texture is used in the material.
  44546. */
  44547. hasTexture(texture: BaseTexture): boolean;
  44548. /**
  44549. * Gets a boolean indicating that current material needs to register RTT
  44550. * @returns true if this uses a render target otherwise false.
  44551. */
  44552. hasRenderTargetTextures(): boolean;
  44553. /**
  44554. * Returns an array of the actively used textures.
  44555. * @param activeTextures Array of BaseTextures
  44556. */
  44557. getActiveTextures(activeTextures: BaseTexture[]): void;
  44558. /**
  44559. * Returns the animatable textures.
  44560. * @param animatables Array of animatable textures.
  44561. */
  44562. getAnimatables(animatables: IAnimatable[]): void;
  44563. /**
  44564. * Disposes the resources of the material.
  44565. * @param forceDisposeTextures - Forces the disposal of all textures.
  44566. */
  44567. dispose(forceDisposeTextures?: boolean): void;
  44568. /**
  44569. * Get the current class name of the texture useful for serialization or dynamic coding.
  44570. * @returns "PBRSubSurfaceConfiguration"
  44571. */
  44572. getClassName(): string;
  44573. /**
  44574. * Add fallbacks to the effect fallbacks list.
  44575. * @param defines defines the Base texture to use.
  44576. * @param fallbacks defines the current fallback list.
  44577. * @param currentRank defines the current fallback rank.
  44578. * @returns the new fallback rank.
  44579. */
  44580. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44581. /**
  44582. * Add the required uniforms to the current list.
  44583. * @param uniforms defines the current uniform list.
  44584. */
  44585. static AddUniforms(uniforms: string[]): void;
  44586. /**
  44587. * Add the required samplers to the current list.
  44588. * @param samplers defines the current sampler list.
  44589. */
  44590. static AddSamplers(samplers: string[]): void;
  44591. /**
  44592. * Add the required uniforms to the current buffer.
  44593. * @param uniformBuffer defines the current uniform buffer.
  44594. */
  44595. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44596. /**
  44597. * Makes a duplicate of the current configuration into another one.
  44598. * @param configuration define the config where to copy the info
  44599. */
  44600. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44601. /**
  44602. * Serializes this Sub Surface configuration.
  44603. * @returns - An object with the serialized config.
  44604. */
  44605. serialize(): any;
  44606. /**
  44607. * Parses a Sub Surface Configuration from a serialized object.
  44608. * @param source - Serialized object.
  44609. */
  44610. parse(source: any): void;
  44611. }
  44612. }
  44613. declare module BABYLON {
  44614. /** @hidden */
  44615. export var pbrFragmentDeclaration: {
  44616. name: string;
  44617. shader: string;
  44618. };
  44619. }
  44620. declare module BABYLON {
  44621. /** @hidden */
  44622. export var pbrUboDeclaration: {
  44623. name: string;
  44624. shader: string;
  44625. };
  44626. }
  44627. declare module BABYLON {
  44628. /** @hidden */
  44629. export var pbrFragmentExtraDeclaration: {
  44630. name: string;
  44631. shader: string;
  44632. };
  44633. }
  44634. declare module BABYLON {
  44635. /** @hidden */
  44636. export var pbrFragmentSamplersDeclaration: {
  44637. name: string;
  44638. shader: string;
  44639. };
  44640. }
  44641. declare module BABYLON {
  44642. /** @hidden */
  44643. export var pbrHelperFunctions: {
  44644. name: string;
  44645. shader: string;
  44646. };
  44647. }
  44648. declare module BABYLON {
  44649. /** @hidden */
  44650. export var harmonicsFunctions: {
  44651. name: string;
  44652. shader: string;
  44653. };
  44654. }
  44655. declare module BABYLON {
  44656. /** @hidden */
  44657. export var pbrDirectLightingSetupFunctions: {
  44658. name: string;
  44659. shader: string;
  44660. };
  44661. }
  44662. declare module BABYLON {
  44663. /** @hidden */
  44664. export var pbrDirectLightingFalloffFunctions: {
  44665. name: string;
  44666. shader: string;
  44667. };
  44668. }
  44669. declare module BABYLON {
  44670. /** @hidden */
  44671. export var pbrBRDFFunctions: {
  44672. name: string;
  44673. shader: string;
  44674. };
  44675. }
  44676. declare module BABYLON {
  44677. /** @hidden */
  44678. export var pbrDirectLightingFunctions: {
  44679. name: string;
  44680. shader: string;
  44681. };
  44682. }
  44683. declare module BABYLON {
  44684. /** @hidden */
  44685. export var pbrIBLFunctions: {
  44686. name: string;
  44687. shader: string;
  44688. };
  44689. }
  44690. declare module BABYLON {
  44691. /** @hidden */
  44692. export var pbrDebug: {
  44693. name: string;
  44694. shader: string;
  44695. };
  44696. }
  44697. declare module BABYLON {
  44698. /** @hidden */
  44699. export var pbrPixelShader: {
  44700. name: string;
  44701. shader: string;
  44702. };
  44703. }
  44704. declare module BABYLON {
  44705. /** @hidden */
  44706. export var pbrVertexDeclaration: {
  44707. name: string;
  44708. shader: string;
  44709. };
  44710. }
  44711. declare module BABYLON {
  44712. /** @hidden */
  44713. export var pbrVertexShader: {
  44714. name: string;
  44715. shader: string;
  44716. };
  44717. }
  44718. declare module BABYLON {
  44719. /**
  44720. * Manages the defines for the PBR Material.
  44721. * @hidden
  44722. */
  44723. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44724. PBR: boolean;
  44725. MAINUV1: boolean;
  44726. MAINUV2: boolean;
  44727. UV1: boolean;
  44728. UV2: boolean;
  44729. ALBEDO: boolean;
  44730. ALBEDODIRECTUV: number;
  44731. VERTEXCOLOR: boolean;
  44732. AMBIENT: boolean;
  44733. AMBIENTDIRECTUV: number;
  44734. AMBIENTINGRAYSCALE: boolean;
  44735. OPACITY: boolean;
  44736. VERTEXALPHA: boolean;
  44737. OPACITYDIRECTUV: number;
  44738. OPACITYRGB: boolean;
  44739. ALPHATEST: boolean;
  44740. DEPTHPREPASS: boolean;
  44741. ALPHABLEND: boolean;
  44742. ALPHAFROMALBEDO: boolean;
  44743. ALPHATESTVALUE: string;
  44744. SPECULAROVERALPHA: boolean;
  44745. RADIANCEOVERALPHA: boolean;
  44746. ALPHAFRESNEL: boolean;
  44747. LINEARALPHAFRESNEL: boolean;
  44748. PREMULTIPLYALPHA: boolean;
  44749. EMISSIVE: boolean;
  44750. EMISSIVEDIRECTUV: number;
  44751. REFLECTIVITY: boolean;
  44752. REFLECTIVITYDIRECTUV: number;
  44753. SPECULARTERM: boolean;
  44754. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44755. MICROSURFACEAUTOMATIC: boolean;
  44756. LODBASEDMICROSFURACE: boolean;
  44757. MICROSURFACEMAP: boolean;
  44758. MICROSURFACEMAPDIRECTUV: number;
  44759. METALLICWORKFLOW: boolean;
  44760. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44761. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44762. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44763. AOSTOREINMETALMAPRED: boolean;
  44764. ENVIRONMENTBRDF: boolean;
  44765. ENVIRONMENTBRDF_RGBD: boolean;
  44766. NORMAL: boolean;
  44767. TANGENT: boolean;
  44768. BUMP: boolean;
  44769. BUMPDIRECTUV: number;
  44770. OBJECTSPACE_NORMALMAP: boolean;
  44771. PARALLAX: boolean;
  44772. PARALLAXOCCLUSION: boolean;
  44773. NORMALXYSCALE: boolean;
  44774. LIGHTMAP: boolean;
  44775. LIGHTMAPDIRECTUV: number;
  44776. USELIGHTMAPASSHADOWMAP: boolean;
  44777. GAMMALIGHTMAP: boolean;
  44778. REFLECTION: boolean;
  44779. REFLECTIONMAP_3D: boolean;
  44780. REFLECTIONMAP_SPHERICAL: boolean;
  44781. REFLECTIONMAP_PLANAR: boolean;
  44782. REFLECTIONMAP_CUBIC: boolean;
  44783. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44784. REFLECTIONMAP_PROJECTION: boolean;
  44785. REFLECTIONMAP_SKYBOX: boolean;
  44786. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44787. REFLECTIONMAP_EXPLICIT: boolean;
  44788. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44789. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44790. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44791. INVERTCUBICMAP: boolean;
  44792. USESPHERICALFROMREFLECTIONMAP: boolean;
  44793. USESPHERICALINVERTEX: boolean;
  44794. REFLECTIONMAP_OPPOSITEZ: boolean;
  44795. LODINREFLECTIONALPHA: boolean;
  44796. GAMMAREFLECTION: boolean;
  44797. RGBDREFLECTION: boolean;
  44798. RADIANCEOCCLUSION: boolean;
  44799. HORIZONOCCLUSION: boolean;
  44800. INSTANCES: boolean;
  44801. NUM_BONE_INFLUENCERS: number;
  44802. BonesPerMesh: number;
  44803. BONETEXTURE: boolean;
  44804. NONUNIFORMSCALING: boolean;
  44805. MORPHTARGETS: boolean;
  44806. MORPHTARGETS_NORMAL: boolean;
  44807. MORPHTARGETS_TANGENT: boolean;
  44808. NUM_MORPH_INFLUENCERS: number;
  44809. IMAGEPROCESSING: boolean;
  44810. VIGNETTE: boolean;
  44811. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44812. VIGNETTEBLENDMODEOPAQUE: boolean;
  44813. TONEMAPPING: boolean;
  44814. TONEMAPPING_ACES: boolean;
  44815. CONTRAST: boolean;
  44816. COLORCURVES: boolean;
  44817. COLORGRADING: boolean;
  44818. COLORGRADING3D: boolean;
  44819. SAMPLER3DGREENDEPTH: boolean;
  44820. SAMPLER3DBGRMAP: boolean;
  44821. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44822. EXPOSURE: boolean;
  44823. MULTIVIEW: boolean;
  44824. USEPHYSICALLIGHTFALLOFF: boolean;
  44825. USEGLTFLIGHTFALLOFF: boolean;
  44826. TWOSIDEDLIGHTING: boolean;
  44827. SHADOWFLOAT: boolean;
  44828. CLIPPLANE: boolean;
  44829. CLIPPLANE2: boolean;
  44830. CLIPPLANE3: boolean;
  44831. CLIPPLANE4: boolean;
  44832. POINTSIZE: boolean;
  44833. FOG: boolean;
  44834. LOGARITHMICDEPTH: boolean;
  44835. FORCENORMALFORWARD: boolean;
  44836. SPECULARAA: boolean;
  44837. CLEARCOAT: boolean;
  44838. CLEARCOAT_DEFAULTIOR: boolean;
  44839. CLEARCOAT_TEXTURE: boolean;
  44840. CLEARCOAT_TEXTUREDIRECTUV: number;
  44841. CLEARCOAT_BUMP: boolean;
  44842. CLEARCOAT_BUMPDIRECTUV: number;
  44843. CLEARCOAT_TINT: boolean;
  44844. CLEARCOAT_TINT_TEXTURE: boolean;
  44845. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44846. ANISOTROPIC: boolean;
  44847. ANISOTROPIC_TEXTURE: boolean;
  44848. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44849. BRDF_V_HEIGHT_CORRELATED: boolean;
  44850. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44851. SHEEN: boolean;
  44852. SHEEN_TEXTURE: boolean;
  44853. SHEEN_TEXTUREDIRECTUV: number;
  44854. SHEEN_LINKWITHALBEDO: boolean;
  44855. SUBSURFACE: boolean;
  44856. SS_REFRACTION: boolean;
  44857. SS_TRANSLUCENCY: boolean;
  44858. SS_SCATERRING: boolean;
  44859. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44860. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44861. SS_REFRACTIONMAP_3D: boolean;
  44862. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44863. SS_LODINREFRACTIONALPHA: boolean;
  44864. SS_GAMMAREFRACTION: boolean;
  44865. SS_RGBDREFRACTION: boolean;
  44866. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44867. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44868. UNLIT: boolean;
  44869. DEBUGMODE: number;
  44870. /**
  44871. * Initializes the PBR Material defines.
  44872. */
  44873. constructor();
  44874. /**
  44875. * Resets the PBR Material defines.
  44876. */
  44877. reset(): void;
  44878. }
  44879. /**
  44880. * The Physically based material base class of BJS.
  44881. *
  44882. * This offers the main features of a standard PBR material.
  44883. * For more information, please refer to the documentation :
  44884. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44885. */
  44886. export abstract class PBRBaseMaterial extends PushMaterial {
  44887. /**
  44888. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44889. */
  44890. static readonly PBRMATERIAL_OPAQUE: number;
  44891. /**
  44892. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44893. */
  44894. static readonly PBRMATERIAL_ALPHATEST: number;
  44895. /**
  44896. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44897. */
  44898. static readonly PBRMATERIAL_ALPHABLEND: number;
  44899. /**
  44900. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44901. * They are also discarded below the alpha cutoff threshold to improve performances.
  44902. */
  44903. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44904. /**
  44905. * Defines the default value of how much AO map is occluding the analytical lights
  44906. * (point spot...).
  44907. */
  44908. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44909. /**
  44910. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44911. */
  44912. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44913. /**
  44914. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44915. * to enhance interoperability with other engines.
  44916. */
  44917. static readonly LIGHTFALLOFF_GLTF: number;
  44918. /**
  44919. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44920. * to enhance interoperability with other materials.
  44921. */
  44922. static readonly LIGHTFALLOFF_STANDARD: number;
  44923. /**
  44924. * Intensity of the direct lights e.g. the four lights available in your scene.
  44925. * This impacts both the direct diffuse and specular highlights.
  44926. */
  44927. protected _directIntensity: number;
  44928. /**
  44929. * Intensity of the emissive part of the material.
  44930. * This helps controlling the emissive effect without modifying the emissive color.
  44931. */
  44932. protected _emissiveIntensity: number;
  44933. /**
  44934. * Intensity of the environment e.g. how much the environment will light the object
  44935. * either through harmonics for rough material or through the refelction for shiny ones.
  44936. */
  44937. protected _environmentIntensity: number;
  44938. /**
  44939. * This is a special control allowing the reduction of the specular highlights coming from the
  44940. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44941. */
  44942. protected _specularIntensity: number;
  44943. /**
  44944. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44945. */
  44946. private _lightingInfos;
  44947. /**
  44948. * Debug Control allowing disabling the bump map on this material.
  44949. */
  44950. protected _disableBumpMap: boolean;
  44951. /**
  44952. * AKA Diffuse Texture in standard nomenclature.
  44953. */
  44954. protected _albedoTexture: Nullable<BaseTexture>;
  44955. /**
  44956. * AKA Occlusion Texture in other nomenclature.
  44957. */
  44958. protected _ambientTexture: Nullable<BaseTexture>;
  44959. /**
  44960. * AKA Occlusion Texture Intensity in other nomenclature.
  44961. */
  44962. protected _ambientTextureStrength: number;
  44963. /**
  44964. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44965. * 1 means it completely occludes it
  44966. * 0 mean it has no impact
  44967. */
  44968. protected _ambientTextureImpactOnAnalyticalLights: number;
  44969. /**
  44970. * Stores the alpha values in a texture.
  44971. */
  44972. protected _opacityTexture: Nullable<BaseTexture>;
  44973. /**
  44974. * Stores the reflection values in a texture.
  44975. */
  44976. protected _reflectionTexture: Nullable<BaseTexture>;
  44977. /**
  44978. * Stores the emissive values in a texture.
  44979. */
  44980. protected _emissiveTexture: Nullable<BaseTexture>;
  44981. /**
  44982. * AKA Specular texture in other nomenclature.
  44983. */
  44984. protected _reflectivityTexture: Nullable<BaseTexture>;
  44985. /**
  44986. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44987. */
  44988. protected _metallicTexture: Nullable<BaseTexture>;
  44989. /**
  44990. * Specifies the metallic scalar of the metallic/roughness workflow.
  44991. * Can also be used to scale the metalness values of the metallic texture.
  44992. */
  44993. protected _metallic: Nullable<number>;
  44994. /**
  44995. * Specifies the roughness scalar of the metallic/roughness workflow.
  44996. * Can also be used to scale the roughness values of the metallic texture.
  44997. */
  44998. protected _roughness: Nullable<number>;
  44999. /**
  45000. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45001. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45002. */
  45003. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45004. /**
  45005. * Stores surface normal data used to displace a mesh in a texture.
  45006. */
  45007. protected _bumpTexture: Nullable<BaseTexture>;
  45008. /**
  45009. * Stores the pre-calculated light information of a mesh in a texture.
  45010. */
  45011. protected _lightmapTexture: Nullable<BaseTexture>;
  45012. /**
  45013. * The color of a material in ambient lighting.
  45014. */
  45015. protected _ambientColor: Color3;
  45016. /**
  45017. * AKA Diffuse Color in other nomenclature.
  45018. */
  45019. protected _albedoColor: Color3;
  45020. /**
  45021. * AKA Specular Color in other nomenclature.
  45022. */
  45023. protected _reflectivityColor: Color3;
  45024. /**
  45025. * The color applied when light is reflected from a material.
  45026. */
  45027. protected _reflectionColor: Color3;
  45028. /**
  45029. * The color applied when light is emitted from a material.
  45030. */
  45031. protected _emissiveColor: Color3;
  45032. /**
  45033. * AKA Glossiness in other nomenclature.
  45034. */
  45035. protected _microSurface: number;
  45036. /**
  45037. * Specifies that the material will use the light map as a show map.
  45038. */
  45039. protected _useLightmapAsShadowmap: boolean;
  45040. /**
  45041. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45042. * makes the reflect vector face the model (under horizon).
  45043. */
  45044. protected _useHorizonOcclusion: boolean;
  45045. /**
  45046. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45047. * too much the area relying on ambient texture to define their ambient occlusion.
  45048. */
  45049. protected _useRadianceOcclusion: boolean;
  45050. /**
  45051. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45052. */
  45053. protected _useAlphaFromAlbedoTexture: boolean;
  45054. /**
  45055. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45056. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45057. */
  45058. protected _useSpecularOverAlpha: boolean;
  45059. /**
  45060. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45061. */
  45062. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45063. /**
  45064. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45065. */
  45066. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45067. /**
  45068. * Specifies if the metallic texture contains the roughness information in its green channel.
  45069. */
  45070. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45071. /**
  45072. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45073. */
  45074. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45075. /**
  45076. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45077. */
  45078. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45079. /**
  45080. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45081. */
  45082. protected _useAmbientInGrayScale: boolean;
  45083. /**
  45084. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45085. * The material will try to infer what glossiness each pixel should be.
  45086. */
  45087. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45088. /**
  45089. * Defines the falloff type used in this material.
  45090. * It by default is Physical.
  45091. */
  45092. protected _lightFalloff: number;
  45093. /**
  45094. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45095. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45096. */
  45097. protected _useRadianceOverAlpha: boolean;
  45098. /**
  45099. * Allows using an object space normal map (instead of tangent space).
  45100. */
  45101. protected _useObjectSpaceNormalMap: boolean;
  45102. /**
  45103. * Allows using the bump map in parallax mode.
  45104. */
  45105. protected _useParallax: boolean;
  45106. /**
  45107. * Allows using the bump map in parallax occlusion mode.
  45108. */
  45109. protected _useParallaxOcclusion: boolean;
  45110. /**
  45111. * Controls the scale bias of the parallax mode.
  45112. */
  45113. protected _parallaxScaleBias: number;
  45114. /**
  45115. * If sets to true, disables all the lights affecting the material.
  45116. */
  45117. protected _disableLighting: boolean;
  45118. /**
  45119. * Number of Simultaneous lights allowed on the material.
  45120. */
  45121. protected _maxSimultaneousLights: number;
  45122. /**
  45123. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45124. */
  45125. protected _invertNormalMapX: boolean;
  45126. /**
  45127. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45128. */
  45129. protected _invertNormalMapY: boolean;
  45130. /**
  45131. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45132. */
  45133. protected _twoSidedLighting: boolean;
  45134. /**
  45135. * Defines the alpha limits in alpha test mode.
  45136. */
  45137. protected _alphaCutOff: number;
  45138. /**
  45139. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45140. */
  45141. protected _forceAlphaTest: boolean;
  45142. /**
  45143. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45144. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45145. */
  45146. protected _useAlphaFresnel: boolean;
  45147. /**
  45148. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45149. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45150. */
  45151. protected _useLinearAlphaFresnel: boolean;
  45152. /**
  45153. * The transparency mode of the material.
  45154. */
  45155. protected _transparencyMode: Nullable<number>;
  45156. /**
  45157. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45158. * from cos thetav and roughness:
  45159. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45160. */
  45161. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45162. /**
  45163. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45164. */
  45165. protected _forceIrradianceInFragment: boolean;
  45166. /**
  45167. * Force normal to face away from face.
  45168. */
  45169. protected _forceNormalForward: boolean;
  45170. /**
  45171. * Enables specular anti aliasing in the PBR shader.
  45172. * It will both interacts on the Geometry for analytical and IBL lighting.
  45173. * It also prefilter the roughness map based on the bump values.
  45174. */
  45175. protected _enableSpecularAntiAliasing: boolean;
  45176. /**
  45177. * Default configuration related to image processing available in the PBR Material.
  45178. */
  45179. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45180. /**
  45181. * Keep track of the image processing observer to allow dispose and replace.
  45182. */
  45183. private _imageProcessingObserver;
  45184. /**
  45185. * Attaches a new image processing configuration to the PBR Material.
  45186. * @param configuration
  45187. */
  45188. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45189. /**
  45190. * Stores the available render targets.
  45191. */
  45192. private _renderTargets;
  45193. /**
  45194. * Sets the global ambient color for the material used in lighting calculations.
  45195. */
  45196. private _globalAmbientColor;
  45197. /**
  45198. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45199. */
  45200. private _useLogarithmicDepth;
  45201. /**
  45202. * If set to true, no lighting calculations will be applied.
  45203. */
  45204. private _unlit;
  45205. private _debugMode;
  45206. /**
  45207. * @hidden
  45208. * This is reserved for the inspector.
  45209. * Defines the material debug mode.
  45210. * It helps seeing only some components of the material while troubleshooting.
  45211. */
  45212. debugMode: number;
  45213. /**
  45214. * @hidden
  45215. * This is reserved for the inspector.
  45216. * Specify from where on screen the debug mode should start.
  45217. * The value goes from -1 (full screen) to 1 (not visible)
  45218. * It helps with side by side comparison against the final render
  45219. * This defaults to -1
  45220. */
  45221. private debugLimit;
  45222. /**
  45223. * @hidden
  45224. * This is reserved for the inspector.
  45225. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45226. * You can use the factor to better multiply the final value.
  45227. */
  45228. private debugFactor;
  45229. /**
  45230. * Defines the clear coat layer parameters for the material.
  45231. */
  45232. readonly clearCoat: PBRClearCoatConfiguration;
  45233. /**
  45234. * Defines the anisotropic parameters for the material.
  45235. */
  45236. readonly anisotropy: PBRAnisotropicConfiguration;
  45237. /**
  45238. * Defines the BRDF parameters for the material.
  45239. */
  45240. readonly brdf: PBRBRDFConfiguration;
  45241. /**
  45242. * Defines the Sheen parameters for the material.
  45243. */
  45244. readonly sheen: PBRSheenConfiguration;
  45245. /**
  45246. * Defines the SubSurface parameters for the material.
  45247. */
  45248. readonly subSurface: PBRSubSurfaceConfiguration;
  45249. /**
  45250. * Custom callback helping to override the default shader used in the material.
  45251. */
  45252. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45253. /**
  45254. * Instantiates a new PBRMaterial instance.
  45255. *
  45256. * @param name The material name
  45257. * @param scene The scene the material will be use in.
  45258. */
  45259. constructor(name: string, scene: Scene);
  45260. /**
  45261. * Gets a boolean indicating that current material needs to register RTT
  45262. */
  45263. readonly hasRenderTargetTextures: boolean;
  45264. /**
  45265. * Gets the name of the material class.
  45266. */
  45267. getClassName(): string;
  45268. /**
  45269. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45270. */
  45271. /**
  45272. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45273. */
  45274. useLogarithmicDepth: boolean;
  45275. /**
  45276. * Gets the current transparency mode.
  45277. */
  45278. /**
  45279. * Sets the transparency mode of the material.
  45280. *
  45281. * | Value | Type | Description |
  45282. * | ----- | ----------------------------------- | ----------- |
  45283. * | 0 | OPAQUE | |
  45284. * | 1 | ALPHATEST | |
  45285. * | 2 | ALPHABLEND | |
  45286. * | 3 | ALPHATESTANDBLEND | |
  45287. *
  45288. */
  45289. transparencyMode: Nullable<number>;
  45290. /**
  45291. * Returns true if alpha blending should be disabled.
  45292. */
  45293. private readonly _disableAlphaBlending;
  45294. /**
  45295. * Specifies whether or not this material should be rendered in alpha blend mode.
  45296. */
  45297. needAlphaBlending(): boolean;
  45298. /**
  45299. * Specifies if the mesh will require alpha blending.
  45300. * @param mesh - BJS mesh.
  45301. */
  45302. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45303. /**
  45304. * Specifies whether or not this material should be rendered in alpha test mode.
  45305. */
  45306. needAlphaTesting(): boolean;
  45307. /**
  45308. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45309. */
  45310. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45311. /**
  45312. * Gets the texture used for the alpha test.
  45313. */
  45314. getAlphaTestTexture(): Nullable<BaseTexture>;
  45315. /**
  45316. * Specifies that the submesh is ready to be used.
  45317. * @param mesh - BJS mesh.
  45318. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45319. * @param useInstances - Specifies that instances should be used.
  45320. * @returns - boolean indicating that the submesh is ready or not.
  45321. */
  45322. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45323. /**
  45324. * Specifies if the material uses metallic roughness workflow.
  45325. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45326. */
  45327. isMetallicWorkflow(): boolean;
  45328. private _prepareEffect;
  45329. private _prepareDefines;
  45330. /**
  45331. * Force shader compilation
  45332. */
  45333. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45334. clipPlane: boolean;
  45335. }>): void;
  45336. /**
  45337. * Initializes the uniform buffer layout for the shader.
  45338. */
  45339. buildUniformLayout(): void;
  45340. /**
  45341. * Unbinds the material from the mesh
  45342. */
  45343. unbind(): void;
  45344. /**
  45345. * Binds the submesh data.
  45346. * @param world - The world matrix.
  45347. * @param mesh - The BJS mesh.
  45348. * @param subMesh - A submesh of the BJS mesh.
  45349. */
  45350. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45351. /**
  45352. * Returns the animatable textures.
  45353. * @returns - Array of animatable textures.
  45354. */
  45355. getAnimatables(): IAnimatable[];
  45356. /**
  45357. * Returns the texture used for reflections.
  45358. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45359. */
  45360. private _getReflectionTexture;
  45361. /**
  45362. * Returns an array of the actively used textures.
  45363. * @returns - Array of BaseTextures
  45364. */
  45365. getActiveTextures(): BaseTexture[];
  45366. /**
  45367. * Checks to see if a texture is used in the material.
  45368. * @param texture - Base texture to use.
  45369. * @returns - Boolean specifying if a texture is used in the material.
  45370. */
  45371. hasTexture(texture: BaseTexture): boolean;
  45372. /**
  45373. * Disposes the resources of the material.
  45374. * @param forceDisposeEffect - Forces the disposal of effects.
  45375. * @param forceDisposeTextures - Forces the disposal of all textures.
  45376. */
  45377. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45378. }
  45379. }
  45380. declare module BABYLON {
  45381. /**
  45382. * The Physically based material of BJS.
  45383. *
  45384. * This offers the main features of a standard PBR material.
  45385. * For more information, please refer to the documentation :
  45386. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45387. */
  45388. export class PBRMaterial extends PBRBaseMaterial {
  45389. /**
  45390. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45391. */
  45392. static readonly PBRMATERIAL_OPAQUE: number;
  45393. /**
  45394. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45395. */
  45396. static readonly PBRMATERIAL_ALPHATEST: number;
  45397. /**
  45398. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45399. */
  45400. static readonly PBRMATERIAL_ALPHABLEND: number;
  45401. /**
  45402. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45403. * They are also discarded below the alpha cutoff threshold to improve performances.
  45404. */
  45405. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45406. /**
  45407. * Defines the default value of how much AO map is occluding the analytical lights
  45408. * (point spot...).
  45409. */
  45410. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45411. /**
  45412. * Intensity of the direct lights e.g. the four lights available in your scene.
  45413. * This impacts both the direct diffuse and specular highlights.
  45414. */
  45415. directIntensity: number;
  45416. /**
  45417. * Intensity of the emissive part of the material.
  45418. * This helps controlling the emissive effect without modifying the emissive color.
  45419. */
  45420. emissiveIntensity: number;
  45421. /**
  45422. * Intensity of the environment e.g. how much the environment will light the object
  45423. * either through harmonics for rough material or through the refelction for shiny ones.
  45424. */
  45425. environmentIntensity: number;
  45426. /**
  45427. * This is a special control allowing the reduction of the specular highlights coming from the
  45428. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45429. */
  45430. specularIntensity: number;
  45431. /**
  45432. * Debug Control allowing disabling the bump map on this material.
  45433. */
  45434. disableBumpMap: boolean;
  45435. /**
  45436. * AKA Diffuse Texture in standard nomenclature.
  45437. */
  45438. albedoTexture: BaseTexture;
  45439. /**
  45440. * AKA Occlusion Texture in other nomenclature.
  45441. */
  45442. ambientTexture: BaseTexture;
  45443. /**
  45444. * AKA Occlusion Texture Intensity in other nomenclature.
  45445. */
  45446. ambientTextureStrength: number;
  45447. /**
  45448. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45449. * 1 means it completely occludes it
  45450. * 0 mean it has no impact
  45451. */
  45452. ambientTextureImpactOnAnalyticalLights: number;
  45453. /**
  45454. * Stores the alpha values in a texture.
  45455. */
  45456. opacityTexture: BaseTexture;
  45457. /**
  45458. * Stores the reflection values in a texture.
  45459. */
  45460. reflectionTexture: Nullable<BaseTexture>;
  45461. /**
  45462. * Stores the emissive values in a texture.
  45463. */
  45464. emissiveTexture: BaseTexture;
  45465. /**
  45466. * AKA Specular texture in other nomenclature.
  45467. */
  45468. reflectivityTexture: BaseTexture;
  45469. /**
  45470. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45471. */
  45472. metallicTexture: BaseTexture;
  45473. /**
  45474. * Specifies the metallic scalar of the metallic/roughness workflow.
  45475. * Can also be used to scale the metalness values of the metallic texture.
  45476. */
  45477. metallic: Nullable<number>;
  45478. /**
  45479. * Specifies the roughness scalar of the metallic/roughness workflow.
  45480. * Can also be used to scale the roughness values of the metallic texture.
  45481. */
  45482. roughness: Nullable<number>;
  45483. /**
  45484. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45485. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45486. */
  45487. microSurfaceTexture: BaseTexture;
  45488. /**
  45489. * Stores surface normal data used to displace a mesh in a texture.
  45490. */
  45491. bumpTexture: BaseTexture;
  45492. /**
  45493. * Stores the pre-calculated light information of a mesh in a texture.
  45494. */
  45495. lightmapTexture: BaseTexture;
  45496. /**
  45497. * Stores the refracted light information in a texture.
  45498. */
  45499. refractionTexture: Nullable<BaseTexture>;
  45500. /**
  45501. * The color of a material in ambient lighting.
  45502. */
  45503. ambientColor: Color3;
  45504. /**
  45505. * AKA Diffuse Color in other nomenclature.
  45506. */
  45507. albedoColor: Color3;
  45508. /**
  45509. * AKA Specular Color in other nomenclature.
  45510. */
  45511. reflectivityColor: Color3;
  45512. /**
  45513. * The color reflected from the material.
  45514. */
  45515. reflectionColor: Color3;
  45516. /**
  45517. * The color emitted from the material.
  45518. */
  45519. emissiveColor: Color3;
  45520. /**
  45521. * AKA Glossiness in other nomenclature.
  45522. */
  45523. microSurface: number;
  45524. /**
  45525. * source material index of refraction (IOR)' / 'destination material IOR.
  45526. */
  45527. indexOfRefraction: number;
  45528. /**
  45529. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45530. */
  45531. invertRefractionY: boolean;
  45532. /**
  45533. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45534. * Materials half opaque for instance using refraction could benefit from this control.
  45535. */
  45536. linkRefractionWithTransparency: boolean;
  45537. /**
  45538. * If true, the light map contains occlusion information instead of lighting info.
  45539. */
  45540. useLightmapAsShadowmap: boolean;
  45541. /**
  45542. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45543. */
  45544. useAlphaFromAlbedoTexture: boolean;
  45545. /**
  45546. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45547. */
  45548. forceAlphaTest: boolean;
  45549. /**
  45550. * Defines the alpha limits in alpha test mode.
  45551. */
  45552. alphaCutOff: number;
  45553. /**
  45554. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45555. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45556. */
  45557. useSpecularOverAlpha: boolean;
  45558. /**
  45559. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45560. */
  45561. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45562. /**
  45563. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45564. */
  45565. useRoughnessFromMetallicTextureAlpha: boolean;
  45566. /**
  45567. * Specifies if the metallic texture contains the roughness information in its green channel.
  45568. */
  45569. useRoughnessFromMetallicTextureGreen: boolean;
  45570. /**
  45571. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45572. */
  45573. useMetallnessFromMetallicTextureBlue: boolean;
  45574. /**
  45575. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45576. */
  45577. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45578. /**
  45579. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45580. */
  45581. useAmbientInGrayScale: boolean;
  45582. /**
  45583. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45584. * The material will try to infer what glossiness each pixel should be.
  45585. */
  45586. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45587. /**
  45588. * BJS is using an harcoded light falloff based on a manually sets up range.
  45589. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45590. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45591. */
  45592. /**
  45593. * BJS is using an harcoded light falloff based on a manually sets up range.
  45594. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45595. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45596. */
  45597. usePhysicalLightFalloff: boolean;
  45598. /**
  45599. * In order to support the falloff compatibility with gltf, a special mode has been added
  45600. * to reproduce the gltf light falloff.
  45601. */
  45602. /**
  45603. * In order to support the falloff compatibility with gltf, a special mode has been added
  45604. * to reproduce the gltf light falloff.
  45605. */
  45606. useGLTFLightFalloff: boolean;
  45607. /**
  45608. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45609. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45610. */
  45611. useRadianceOverAlpha: boolean;
  45612. /**
  45613. * Allows using an object space normal map (instead of tangent space).
  45614. */
  45615. useObjectSpaceNormalMap: boolean;
  45616. /**
  45617. * Allows using the bump map in parallax mode.
  45618. */
  45619. useParallax: boolean;
  45620. /**
  45621. * Allows using the bump map in parallax occlusion mode.
  45622. */
  45623. useParallaxOcclusion: boolean;
  45624. /**
  45625. * Controls the scale bias of the parallax mode.
  45626. */
  45627. parallaxScaleBias: number;
  45628. /**
  45629. * If sets to true, disables all the lights affecting the material.
  45630. */
  45631. disableLighting: boolean;
  45632. /**
  45633. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45634. */
  45635. forceIrradianceInFragment: boolean;
  45636. /**
  45637. * Number of Simultaneous lights allowed on the material.
  45638. */
  45639. maxSimultaneousLights: number;
  45640. /**
  45641. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45642. */
  45643. invertNormalMapX: boolean;
  45644. /**
  45645. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45646. */
  45647. invertNormalMapY: boolean;
  45648. /**
  45649. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45650. */
  45651. twoSidedLighting: boolean;
  45652. /**
  45653. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45654. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45655. */
  45656. useAlphaFresnel: boolean;
  45657. /**
  45658. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45659. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45660. */
  45661. useLinearAlphaFresnel: boolean;
  45662. /**
  45663. * Let user defines the brdf lookup texture used for IBL.
  45664. * A default 8bit version is embedded but you could point at :
  45665. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45666. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45667. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45668. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45669. */
  45670. environmentBRDFTexture: Nullable<BaseTexture>;
  45671. /**
  45672. * Force normal to face away from face.
  45673. */
  45674. forceNormalForward: boolean;
  45675. /**
  45676. * Enables specular anti aliasing in the PBR shader.
  45677. * It will both interacts on the Geometry for analytical and IBL lighting.
  45678. * It also prefilter the roughness map based on the bump values.
  45679. */
  45680. enableSpecularAntiAliasing: boolean;
  45681. /**
  45682. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45683. * makes the reflect vector face the model (under horizon).
  45684. */
  45685. useHorizonOcclusion: boolean;
  45686. /**
  45687. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45688. * too much the area relying on ambient texture to define their ambient occlusion.
  45689. */
  45690. useRadianceOcclusion: boolean;
  45691. /**
  45692. * If set to true, no lighting calculations will be applied.
  45693. */
  45694. unlit: boolean;
  45695. /**
  45696. * Gets the image processing configuration used either in this material.
  45697. */
  45698. /**
  45699. * Sets the Default image processing configuration used either in the this material.
  45700. *
  45701. * If sets to null, the scene one is in use.
  45702. */
  45703. imageProcessingConfiguration: ImageProcessingConfiguration;
  45704. /**
  45705. * Gets wether the color curves effect is enabled.
  45706. */
  45707. /**
  45708. * Sets wether the color curves effect is enabled.
  45709. */
  45710. cameraColorCurvesEnabled: boolean;
  45711. /**
  45712. * Gets wether the color grading effect is enabled.
  45713. */
  45714. /**
  45715. * Gets wether the color grading effect is enabled.
  45716. */
  45717. cameraColorGradingEnabled: boolean;
  45718. /**
  45719. * Gets wether tonemapping is enabled or not.
  45720. */
  45721. /**
  45722. * Sets wether tonemapping is enabled or not
  45723. */
  45724. cameraToneMappingEnabled: boolean;
  45725. /**
  45726. * The camera exposure used on this material.
  45727. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45728. * This corresponds to a photographic exposure.
  45729. */
  45730. /**
  45731. * The camera exposure used on this material.
  45732. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45733. * This corresponds to a photographic exposure.
  45734. */
  45735. cameraExposure: number;
  45736. /**
  45737. * Gets The camera contrast used on this material.
  45738. */
  45739. /**
  45740. * Sets The camera contrast used on this material.
  45741. */
  45742. cameraContrast: number;
  45743. /**
  45744. * Gets the Color Grading 2D Lookup Texture.
  45745. */
  45746. /**
  45747. * Sets the Color Grading 2D Lookup Texture.
  45748. */
  45749. cameraColorGradingTexture: Nullable<BaseTexture>;
  45750. /**
  45751. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45752. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45753. * 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;
  45754. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45755. */
  45756. /**
  45757. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45758. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45759. * 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;
  45760. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45761. */
  45762. cameraColorCurves: Nullable<ColorCurves>;
  45763. /**
  45764. * Instantiates a new PBRMaterial instance.
  45765. *
  45766. * @param name The material name
  45767. * @param scene The scene the material will be use in.
  45768. */
  45769. constructor(name: string, scene: Scene);
  45770. /**
  45771. * Returns the name of this material class.
  45772. */
  45773. getClassName(): string;
  45774. /**
  45775. * Makes a duplicate of the current material.
  45776. * @param name - name to use for the new material.
  45777. */
  45778. clone(name: string): PBRMaterial;
  45779. /**
  45780. * Serializes this PBR Material.
  45781. * @returns - An object with the serialized material.
  45782. */
  45783. serialize(): any;
  45784. /**
  45785. * Parses a PBR Material from a serialized object.
  45786. * @param source - Serialized object.
  45787. * @param scene - BJS scene instance.
  45788. * @param rootUrl - url for the scene object
  45789. * @returns - PBRMaterial
  45790. */
  45791. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45792. }
  45793. }
  45794. declare module BABYLON {
  45795. /**
  45796. * Direct draw surface info
  45797. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45798. */
  45799. export interface DDSInfo {
  45800. /**
  45801. * Width of the texture
  45802. */
  45803. width: number;
  45804. /**
  45805. * Width of the texture
  45806. */
  45807. height: number;
  45808. /**
  45809. * Number of Mipmaps for the texture
  45810. * @see https://en.wikipedia.org/wiki/Mipmap
  45811. */
  45812. mipmapCount: number;
  45813. /**
  45814. * If the textures format is a known fourCC format
  45815. * @see https://www.fourcc.org/
  45816. */
  45817. isFourCC: boolean;
  45818. /**
  45819. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45820. */
  45821. isRGB: boolean;
  45822. /**
  45823. * If the texture is a lumincance format
  45824. */
  45825. isLuminance: boolean;
  45826. /**
  45827. * If this is a cube texture
  45828. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45829. */
  45830. isCube: boolean;
  45831. /**
  45832. * If the texture is a compressed format eg. FOURCC_DXT1
  45833. */
  45834. isCompressed: boolean;
  45835. /**
  45836. * The dxgiFormat of the texture
  45837. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45838. */
  45839. dxgiFormat: number;
  45840. /**
  45841. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45842. */
  45843. textureType: number;
  45844. /**
  45845. * Sphericle polynomial created for the dds texture
  45846. */
  45847. sphericalPolynomial?: SphericalPolynomial;
  45848. }
  45849. /**
  45850. * Class used to provide DDS decompression tools
  45851. */
  45852. export class DDSTools {
  45853. /**
  45854. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45855. */
  45856. static StoreLODInAlphaChannel: boolean;
  45857. /**
  45858. * Gets DDS information from an array buffer
  45859. * @param arrayBuffer defines the array buffer to read data from
  45860. * @returns the DDS information
  45861. */
  45862. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45863. private static _FloatView;
  45864. private static _Int32View;
  45865. private static _ToHalfFloat;
  45866. private static _FromHalfFloat;
  45867. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45868. private static _GetHalfFloatRGBAArrayBuffer;
  45869. private static _GetFloatRGBAArrayBuffer;
  45870. private static _GetFloatAsUIntRGBAArrayBuffer;
  45871. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45872. private static _GetRGBAArrayBuffer;
  45873. private static _ExtractLongWordOrder;
  45874. private static _GetRGBArrayBuffer;
  45875. private static _GetLuminanceArrayBuffer;
  45876. /**
  45877. * Uploads DDS Levels to a Babylon Texture
  45878. * @hidden
  45879. */
  45880. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45881. }
  45882. interface Engine {
  45883. /**
  45884. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45885. * @param rootUrl defines the url where the file to load is located
  45886. * @param scene defines the current scene
  45887. * @param lodScale defines scale to apply to the mip map selection
  45888. * @param lodOffset defines offset to apply to the mip map selection
  45889. * @param onLoad defines an optional callback raised when the texture is loaded
  45890. * @param onError defines an optional callback raised if there is an issue to load the texture
  45891. * @param format defines the format of the data
  45892. * @param forcedExtension defines the extension to use to pick the right loader
  45893. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45894. * @returns the cube texture as an InternalTexture
  45895. */
  45896. 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;
  45897. }
  45898. }
  45899. declare module BABYLON {
  45900. /**
  45901. * Implementation of the DDS Texture Loader.
  45902. * @hidden
  45903. */
  45904. export class _DDSTextureLoader implements IInternalTextureLoader {
  45905. /**
  45906. * Defines wether the loader supports cascade loading the different faces.
  45907. */
  45908. readonly supportCascades: boolean;
  45909. /**
  45910. * This returns if the loader support the current file information.
  45911. * @param extension defines the file extension of the file being loaded
  45912. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45913. * @param fallback defines the fallback internal texture if any
  45914. * @param isBase64 defines whether the texture is encoded as a base64
  45915. * @param isBuffer defines whether the texture data are stored as a buffer
  45916. * @returns true if the loader can load the specified file
  45917. */
  45918. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45919. /**
  45920. * Transform the url before loading if required.
  45921. * @param rootUrl the url of the texture
  45922. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45923. * @returns the transformed texture
  45924. */
  45925. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45926. /**
  45927. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45928. * @param rootUrl the url of the texture
  45929. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45930. * @returns the fallback texture
  45931. */
  45932. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45933. /**
  45934. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45935. * @param data contains the texture data
  45936. * @param texture defines the BabylonJS internal texture
  45937. * @param createPolynomials will be true if polynomials have been requested
  45938. * @param onLoad defines the callback to trigger once the texture is ready
  45939. * @param onError defines the callback to trigger in case of error
  45940. */
  45941. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45942. /**
  45943. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45944. * @param data contains the texture data
  45945. * @param texture defines the BabylonJS internal texture
  45946. * @param callback defines the method to call once ready to upload
  45947. */
  45948. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45949. }
  45950. }
  45951. declare module BABYLON {
  45952. /** @hidden */
  45953. export var rgbdEncodePixelShader: {
  45954. name: string;
  45955. shader: string;
  45956. };
  45957. }
  45958. declare module BABYLON {
  45959. /**
  45960. * Raw texture data and descriptor sufficient for WebGL texture upload
  45961. */
  45962. export interface EnvironmentTextureInfo {
  45963. /**
  45964. * Version of the environment map
  45965. */
  45966. version: number;
  45967. /**
  45968. * Width of image
  45969. */
  45970. width: number;
  45971. /**
  45972. * Irradiance information stored in the file.
  45973. */
  45974. irradiance: any;
  45975. /**
  45976. * Specular information stored in the file.
  45977. */
  45978. specular: any;
  45979. }
  45980. /**
  45981. * Sets of helpers addressing the serialization and deserialization of environment texture
  45982. * stored in a BabylonJS env file.
  45983. * Those files are usually stored as .env files.
  45984. */
  45985. export class EnvironmentTextureTools {
  45986. /**
  45987. * Magic number identifying the env file.
  45988. */
  45989. private static _MagicBytes;
  45990. /**
  45991. * Gets the environment info from an env file.
  45992. * @param data The array buffer containing the .env bytes.
  45993. * @returns the environment file info (the json header) if successfully parsed.
  45994. */
  45995. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45996. /**
  45997. * Creates an environment texture from a loaded cube texture.
  45998. * @param texture defines the cube texture to convert in env file
  45999. * @return a promise containing the environment data if succesfull.
  46000. */
  46001. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46002. /**
  46003. * Creates a JSON representation of the spherical data.
  46004. * @param texture defines the texture containing the polynomials
  46005. * @return the JSON representation of the spherical info
  46006. */
  46007. private static _CreateEnvTextureIrradiance;
  46008. /**
  46009. * Uploads the texture info contained in the env file to the GPU.
  46010. * @param texture defines the internal texture to upload to
  46011. * @param arrayBuffer defines the buffer cotaining the data to load
  46012. * @param info defines the texture info retrieved through the GetEnvInfo method
  46013. * @returns a promise
  46014. */
  46015. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46016. /**
  46017. * Uploads the levels of image data to the GPU.
  46018. * @param texture defines the internal texture to upload to
  46019. * @param imageData defines the array buffer views of image data [mipmap][face]
  46020. * @returns a promise
  46021. */
  46022. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46023. /**
  46024. * Uploads spherical polynomials information to the texture.
  46025. * @param texture defines the texture we are trying to upload the information to
  46026. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46027. */
  46028. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46029. /** @hidden */
  46030. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46031. }
  46032. }
  46033. declare module BABYLON {
  46034. /**
  46035. * Implementation of the ENV Texture Loader.
  46036. * @hidden
  46037. */
  46038. export class _ENVTextureLoader implements IInternalTextureLoader {
  46039. /**
  46040. * Defines wether the loader supports cascade loading the different faces.
  46041. */
  46042. readonly supportCascades: boolean;
  46043. /**
  46044. * This returns if the loader support the current file information.
  46045. * @param extension defines the file extension of the file being loaded
  46046. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46047. * @param fallback defines the fallback internal texture if any
  46048. * @param isBase64 defines whether the texture is encoded as a base64
  46049. * @param isBuffer defines whether the texture data are stored as a buffer
  46050. * @returns true if the loader can load the specified file
  46051. */
  46052. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46053. /**
  46054. * Transform the url before loading if required.
  46055. * @param rootUrl the url of the texture
  46056. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46057. * @returns the transformed texture
  46058. */
  46059. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46060. /**
  46061. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46062. * @param rootUrl the url of the texture
  46063. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46064. * @returns the fallback texture
  46065. */
  46066. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46067. /**
  46068. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46069. * @param data contains the texture data
  46070. * @param texture defines the BabylonJS internal texture
  46071. * @param createPolynomials will be true if polynomials have been requested
  46072. * @param onLoad defines the callback to trigger once the texture is ready
  46073. * @param onError defines the callback to trigger in case of error
  46074. */
  46075. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46076. /**
  46077. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46078. * @param data contains the texture data
  46079. * @param texture defines the BabylonJS internal texture
  46080. * @param callback defines the method to call once ready to upload
  46081. */
  46082. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46083. }
  46084. }
  46085. declare module BABYLON {
  46086. /**
  46087. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46088. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46089. */
  46090. export class KhronosTextureContainer {
  46091. /** contents of the KTX container file */
  46092. arrayBuffer: any;
  46093. private static HEADER_LEN;
  46094. private static COMPRESSED_2D;
  46095. private static COMPRESSED_3D;
  46096. private static TEX_2D;
  46097. private static TEX_3D;
  46098. /**
  46099. * Gets the openGL type
  46100. */
  46101. glType: number;
  46102. /**
  46103. * Gets the openGL type size
  46104. */
  46105. glTypeSize: number;
  46106. /**
  46107. * Gets the openGL format
  46108. */
  46109. glFormat: number;
  46110. /**
  46111. * Gets the openGL internal format
  46112. */
  46113. glInternalFormat: number;
  46114. /**
  46115. * Gets the base internal format
  46116. */
  46117. glBaseInternalFormat: number;
  46118. /**
  46119. * Gets image width in pixel
  46120. */
  46121. pixelWidth: number;
  46122. /**
  46123. * Gets image height in pixel
  46124. */
  46125. pixelHeight: number;
  46126. /**
  46127. * Gets image depth in pixels
  46128. */
  46129. pixelDepth: number;
  46130. /**
  46131. * Gets the number of array elements
  46132. */
  46133. numberOfArrayElements: number;
  46134. /**
  46135. * Gets the number of faces
  46136. */
  46137. numberOfFaces: number;
  46138. /**
  46139. * Gets the number of mipmap levels
  46140. */
  46141. numberOfMipmapLevels: number;
  46142. /**
  46143. * Gets the bytes of key value data
  46144. */
  46145. bytesOfKeyValueData: number;
  46146. /**
  46147. * Gets the load type
  46148. */
  46149. loadType: number;
  46150. /**
  46151. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46152. */
  46153. isInvalid: boolean;
  46154. /**
  46155. * Creates a new KhronosTextureContainer
  46156. * @param arrayBuffer contents of the KTX container file
  46157. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46158. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46159. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46160. */
  46161. constructor(
  46162. /** contents of the KTX container file */
  46163. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46164. /**
  46165. * Uploads KTX content to a Babylon Texture.
  46166. * It is assumed that the texture has already been created & is currently bound
  46167. * @hidden
  46168. */
  46169. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46170. private _upload2DCompressedLevels;
  46171. }
  46172. }
  46173. declare module BABYLON {
  46174. /**
  46175. * Implementation of the KTX Texture Loader.
  46176. * @hidden
  46177. */
  46178. export class _KTXTextureLoader implements IInternalTextureLoader {
  46179. /**
  46180. * Defines wether the loader supports cascade loading the different faces.
  46181. */
  46182. readonly supportCascades: boolean;
  46183. /**
  46184. * This returns if the loader support the current file information.
  46185. * @param extension defines the file extension of the file being loaded
  46186. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46187. * @param fallback defines the fallback internal texture if any
  46188. * @param isBase64 defines whether the texture is encoded as a base64
  46189. * @param isBuffer defines whether the texture data are stored as a buffer
  46190. * @returns true if the loader can load the specified file
  46191. */
  46192. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46193. /**
  46194. * Transform the url before loading if required.
  46195. * @param rootUrl the url of the texture
  46196. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46197. * @returns the transformed texture
  46198. */
  46199. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46200. /**
  46201. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46202. * @param rootUrl the url of the texture
  46203. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46204. * @returns the fallback texture
  46205. */
  46206. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46207. /**
  46208. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46209. * @param data contains the texture data
  46210. * @param texture defines the BabylonJS internal texture
  46211. * @param createPolynomials will be true if polynomials have been requested
  46212. * @param onLoad defines the callback to trigger once the texture is ready
  46213. * @param onError defines the callback to trigger in case of error
  46214. */
  46215. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46216. /**
  46217. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46218. * @param data contains the texture data
  46219. * @param texture defines the BabylonJS internal texture
  46220. * @param callback defines the method to call once ready to upload
  46221. */
  46222. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46223. }
  46224. }
  46225. declare module BABYLON {
  46226. /** @hidden */
  46227. export var _forceSceneHelpersToBundle: boolean;
  46228. interface Scene {
  46229. /**
  46230. * Creates a default light for the scene.
  46231. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46232. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46233. */
  46234. createDefaultLight(replace?: boolean): void;
  46235. /**
  46236. * Creates a default camera for the scene.
  46237. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46238. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46239. * @param replace has default false, when true replaces the active camera in the scene
  46240. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46241. */
  46242. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46243. /**
  46244. * Creates a default camera and a default light.
  46245. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46246. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46247. * @param replace has the default false, when true replaces the active camera/light in the scene
  46248. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46249. */
  46250. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46251. /**
  46252. * Creates a new sky box
  46253. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46254. * @param environmentTexture defines the texture to use as environment texture
  46255. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46256. * @param scale defines the overall scale of the skybox
  46257. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46258. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46259. * @returns a new mesh holding the sky box
  46260. */
  46261. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46262. /**
  46263. * Creates a new environment
  46264. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46265. * @param options defines the options you can use to configure the environment
  46266. * @returns the new EnvironmentHelper
  46267. */
  46268. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46269. /**
  46270. * Creates a new VREXperienceHelper
  46271. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46272. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46273. * @returns a new VREXperienceHelper
  46274. */
  46275. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46276. /**
  46277. * Creates a new XREXperienceHelper
  46278. * @see http://doc.babylonjs.com/how_to/webxr
  46279. * @returns a promise for a new XREXperienceHelper
  46280. */
  46281. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46282. }
  46283. }
  46284. declare module BABYLON {
  46285. /**
  46286. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46287. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46288. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46289. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46290. */
  46291. export class VideoDome extends TransformNode {
  46292. /**
  46293. * Define the video source as a Monoscopic panoramic 360 video.
  46294. */
  46295. static readonly MODE_MONOSCOPIC: number;
  46296. /**
  46297. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46298. */
  46299. static readonly MODE_TOPBOTTOM: number;
  46300. /**
  46301. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46302. */
  46303. static readonly MODE_SIDEBYSIDE: number;
  46304. private _useDirectMapping;
  46305. /**
  46306. * The video texture being displayed on the sphere
  46307. */
  46308. protected _videoTexture: VideoTexture;
  46309. /**
  46310. * Gets the video texture being displayed on the sphere
  46311. */
  46312. readonly videoTexture: VideoTexture;
  46313. /**
  46314. * The skybox material
  46315. */
  46316. protected _material: BackgroundMaterial;
  46317. /**
  46318. * The surface used for the skybox
  46319. */
  46320. protected _mesh: Mesh;
  46321. /**
  46322. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46323. * Also see the options.resolution property.
  46324. */
  46325. fovMultiplier: number;
  46326. private _videoMode;
  46327. /**
  46328. * Gets or set the current video mode for the video. It can be:
  46329. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46330. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46331. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46332. */
  46333. videoMode: number;
  46334. /**
  46335. * Oberserver used in Stereoscopic VR Mode.
  46336. */
  46337. private _onBeforeCameraRenderObserver;
  46338. /**
  46339. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46340. * @param name Element's name, child elements will append suffixes for their own names.
  46341. * @param urlsOrVideo defines the url(s) or the video element to use
  46342. * @param options An object containing optional or exposed sub element properties
  46343. */
  46344. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46345. resolution?: number;
  46346. clickToPlay?: boolean;
  46347. autoPlay?: boolean;
  46348. loop?: boolean;
  46349. size?: number;
  46350. poster?: string;
  46351. faceForward?: boolean;
  46352. useDirectMapping?: boolean;
  46353. }, scene: Scene);
  46354. private _changeVideoMode;
  46355. /**
  46356. * Releases resources associated with this node.
  46357. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46358. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46359. */
  46360. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46361. }
  46362. }
  46363. declare module BABYLON {
  46364. /**
  46365. * This class can be used to get instrumentation data from a Babylon engine
  46366. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46367. */
  46368. export class EngineInstrumentation implements IDisposable {
  46369. /**
  46370. * Define the instrumented engine.
  46371. */
  46372. engine: Engine;
  46373. private _captureGPUFrameTime;
  46374. private _gpuFrameTimeToken;
  46375. private _gpuFrameTime;
  46376. private _captureShaderCompilationTime;
  46377. private _shaderCompilationTime;
  46378. private _onBeginFrameObserver;
  46379. private _onEndFrameObserver;
  46380. private _onBeforeShaderCompilationObserver;
  46381. private _onAfterShaderCompilationObserver;
  46382. /**
  46383. * Gets the perf counter used for GPU frame time
  46384. */
  46385. readonly gpuFrameTimeCounter: PerfCounter;
  46386. /**
  46387. * Gets the GPU frame time capture status
  46388. */
  46389. /**
  46390. * Enable or disable the GPU frame time capture
  46391. */
  46392. captureGPUFrameTime: boolean;
  46393. /**
  46394. * Gets the perf counter used for shader compilation time
  46395. */
  46396. readonly shaderCompilationTimeCounter: PerfCounter;
  46397. /**
  46398. * Gets the shader compilation time capture status
  46399. */
  46400. /**
  46401. * Enable or disable the shader compilation time capture
  46402. */
  46403. captureShaderCompilationTime: boolean;
  46404. /**
  46405. * Instantiates a new engine instrumentation.
  46406. * This class can be used to get instrumentation data from a Babylon engine
  46407. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46408. * @param engine Defines the engine to instrument
  46409. */
  46410. constructor(
  46411. /**
  46412. * Define the instrumented engine.
  46413. */
  46414. engine: Engine);
  46415. /**
  46416. * Dispose and release associated resources.
  46417. */
  46418. dispose(): void;
  46419. }
  46420. }
  46421. declare module BABYLON {
  46422. /**
  46423. * This class can be used to get instrumentation data from a Babylon engine
  46424. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46425. */
  46426. export class SceneInstrumentation implements IDisposable {
  46427. /**
  46428. * Defines the scene to instrument
  46429. */
  46430. scene: Scene;
  46431. private _captureActiveMeshesEvaluationTime;
  46432. private _activeMeshesEvaluationTime;
  46433. private _captureRenderTargetsRenderTime;
  46434. private _renderTargetsRenderTime;
  46435. private _captureFrameTime;
  46436. private _frameTime;
  46437. private _captureRenderTime;
  46438. private _renderTime;
  46439. private _captureInterFrameTime;
  46440. private _interFrameTime;
  46441. private _captureParticlesRenderTime;
  46442. private _particlesRenderTime;
  46443. private _captureSpritesRenderTime;
  46444. private _spritesRenderTime;
  46445. private _capturePhysicsTime;
  46446. private _physicsTime;
  46447. private _captureAnimationsTime;
  46448. private _animationsTime;
  46449. private _captureCameraRenderTime;
  46450. private _cameraRenderTime;
  46451. private _onBeforeActiveMeshesEvaluationObserver;
  46452. private _onAfterActiveMeshesEvaluationObserver;
  46453. private _onBeforeRenderTargetsRenderObserver;
  46454. private _onAfterRenderTargetsRenderObserver;
  46455. private _onAfterRenderObserver;
  46456. private _onBeforeDrawPhaseObserver;
  46457. private _onAfterDrawPhaseObserver;
  46458. private _onBeforeAnimationsObserver;
  46459. private _onBeforeParticlesRenderingObserver;
  46460. private _onAfterParticlesRenderingObserver;
  46461. private _onBeforeSpritesRenderingObserver;
  46462. private _onAfterSpritesRenderingObserver;
  46463. private _onBeforePhysicsObserver;
  46464. private _onAfterPhysicsObserver;
  46465. private _onAfterAnimationsObserver;
  46466. private _onBeforeCameraRenderObserver;
  46467. private _onAfterCameraRenderObserver;
  46468. /**
  46469. * Gets the perf counter used for active meshes evaluation time
  46470. */
  46471. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46472. /**
  46473. * Gets the active meshes evaluation time capture status
  46474. */
  46475. /**
  46476. * Enable or disable the active meshes evaluation time capture
  46477. */
  46478. captureActiveMeshesEvaluationTime: boolean;
  46479. /**
  46480. * Gets the perf counter used for render targets render time
  46481. */
  46482. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46483. /**
  46484. * Gets the render targets render time capture status
  46485. */
  46486. /**
  46487. * Enable or disable the render targets render time capture
  46488. */
  46489. captureRenderTargetsRenderTime: boolean;
  46490. /**
  46491. * Gets the perf counter used for particles render time
  46492. */
  46493. readonly particlesRenderTimeCounter: PerfCounter;
  46494. /**
  46495. * Gets the particles render time capture status
  46496. */
  46497. /**
  46498. * Enable or disable the particles render time capture
  46499. */
  46500. captureParticlesRenderTime: boolean;
  46501. /**
  46502. * Gets the perf counter used for sprites render time
  46503. */
  46504. readonly spritesRenderTimeCounter: PerfCounter;
  46505. /**
  46506. * Gets the sprites render time capture status
  46507. */
  46508. /**
  46509. * Enable or disable the sprites render time capture
  46510. */
  46511. captureSpritesRenderTime: boolean;
  46512. /**
  46513. * Gets the perf counter used for physics time
  46514. */
  46515. readonly physicsTimeCounter: PerfCounter;
  46516. /**
  46517. * Gets the physics time capture status
  46518. */
  46519. /**
  46520. * Enable or disable the physics time capture
  46521. */
  46522. capturePhysicsTime: boolean;
  46523. /**
  46524. * Gets the perf counter used for animations time
  46525. */
  46526. readonly animationsTimeCounter: PerfCounter;
  46527. /**
  46528. * Gets the animations time capture status
  46529. */
  46530. /**
  46531. * Enable or disable the animations time capture
  46532. */
  46533. captureAnimationsTime: boolean;
  46534. /**
  46535. * Gets the perf counter used for frame time capture
  46536. */
  46537. readonly frameTimeCounter: PerfCounter;
  46538. /**
  46539. * Gets the frame time capture status
  46540. */
  46541. /**
  46542. * Enable or disable the frame time capture
  46543. */
  46544. captureFrameTime: boolean;
  46545. /**
  46546. * Gets the perf counter used for inter-frames time capture
  46547. */
  46548. readonly interFrameTimeCounter: PerfCounter;
  46549. /**
  46550. * Gets the inter-frames time capture status
  46551. */
  46552. /**
  46553. * Enable or disable the inter-frames time capture
  46554. */
  46555. captureInterFrameTime: boolean;
  46556. /**
  46557. * Gets the perf counter used for render time capture
  46558. */
  46559. readonly renderTimeCounter: PerfCounter;
  46560. /**
  46561. * Gets the render time capture status
  46562. */
  46563. /**
  46564. * Enable or disable the render time capture
  46565. */
  46566. captureRenderTime: boolean;
  46567. /**
  46568. * Gets the perf counter used for camera render time capture
  46569. */
  46570. readonly cameraRenderTimeCounter: PerfCounter;
  46571. /**
  46572. * Gets the camera render time capture status
  46573. */
  46574. /**
  46575. * Enable or disable the camera render time capture
  46576. */
  46577. captureCameraRenderTime: boolean;
  46578. /**
  46579. * Gets the perf counter used for draw calls
  46580. */
  46581. readonly drawCallsCounter: PerfCounter;
  46582. /**
  46583. * Instantiates a new scene instrumentation.
  46584. * This class can be used to get instrumentation data from a Babylon engine
  46585. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46586. * @param scene Defines the scene to instrument
  46587. */
  46588. constructor(
  46589. /**
  46590. * Defines the scene to instrument
  46591. */
  46592. scene: Scene);
  46593. /**
  46594. * Dispose and release associated resources.
  46595. */
  46596. dispose(): void;
  46597. }
  46598. }
  46599. declare module BABYLON {
  46600. /** @hidden */
  46601. export var glowMapGenerationPixelShader: {
  46602. name: string;
  46603. shader: string;
  46604. };
  46605. }
  46606. declare module BABYLON {
  46607. /** @hidden */
  46608. export var glowMapGenerationVertexShader: {
  46609. name: string;
  46610. shader: string;
  46611. };
  46612. }
  46613. declare module BABYLON {
  46614. /**
  46615. * Effect layer options. This helps customizing the behaviour
  46616. * of the effect layer.
  46617. */
  46618. export interface IEffectLayerOptions {
  46619. /**
  46620. * Multiplication factor apply to the canvas size to compute the render target size
  46621. * used to generated the objects (the smaller the faster).
  46622. */
  46623. mainTextureRatio: number;
  46624. /**
  46625. * Enforces a fixed size texture to ensure effect stability across devices.
  46626. */
  46627. mainTextureFixedSize?: number;
  46628. /**
  46629. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46630. */
  46631. alphaBlendingMode: number;
  46632. /**
  46633. * The camera attached to the layer.
  46634. */
  46635. camera: Nullable<Camera>;
  46636. /**
  46637. * The rendering group to draw the layer in.
  46638. */
  46639. renderingGroupId: number;
  46640. }
  46641. /**
  46642. * The effect layer Helps adding post process effect blended with the main pass.
  46643. *
  46644. * This can be for instance use to generate glow or higlight effects on the scene.
  46645. *
  46646. * The effect layer class can not be used directly and is intented to inherited from to be
  46647. * customized per effects.
  46648. */
  46649. export abstract class EffectLayer {
  46650. private _vertexBuffers;
  46651. private _indexBuffer;
  46652. private _cachedDefines;
  46653. private _effectLayerMapGenerationEffect;
  46654. private _effectLayerOptions;
  46655. private _mergeEffect;
  46656. protected _scene: Scene;
  46657. protected _engine: Engine;
  46658. protected _maxSize: number;
  46659. protected _mainTextureDesiredSize: ISize;
  46660. protected _mainTexture: RenderTargetTexture;
  46661. protected _shouldRender: boolean;
  46662. protected _postProcesses: PostProcess[];
  46663. protected _textures: BaseTexture[];
  46664. protected _emissiveTextureAndColor: {
  46665. texture: Nullable<BaseTexture>;
  46666. color: Color4;
  46667. };
  46668. /**
  46669. * The name of the layer
  46670. */
  46671. name: string;
  46672. /**
  46673. * The clear color of the texture used to generate the glow map.
  46674. */
  46675. neutralColor: Color4;
  46676. /**
  46677. * Specifies wether the highlight layer is enabled or not.
  46678. */
  46679. isEnabled: boolean;
  46680. /**
  46681. * Gets the camera attached to the layer.
  46682. */
  46683. readonly camera: Nullable<Camera>;
  46684. /**
  46685. * Gets the rendering group id the layer should render in.
  46686. */
  46687. readonly renderingGroupId: number;
  46688. /**
  46689. * An event triggered when the effect layer has been disposed.
  46690. */
  46691. onDisposeObservable: Observable<EffectLayer>;
  46692. /**
  46693. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46694. */
  46695. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46696. /**
  46697. * An event triggered when the generated texture is being merged in the scene.
  46698. */
  46699. onBeforeComposeObservable: Observable<EffectLayer>;
  46700. /**
  46701. * An event triggered when the generated texture has been merged in the scene.
  46702. */
  46703. onAfterComposeObservable: Observable<EffectLayer>;
  46704. /**
  46705. * An event triggered when the efffect layer changes its size.
  46706. */
  46707. onSizeChangedObservable: Observable<EffectLayer>;
  46708. /** @hidden */
  46709. static _SceneComponentInitialization: (scene: Scene) => void;
  46710. /**
  46711. * Instantiates a new effect Layer and references it in the scene.
  46712. * @param name The name of the layer
  46713. * @param scene The scene to use the layer in
  46714. */
  46715. constructor(
  46716. /** The Friendly of the effect in the scene */
  46717. name: string, scene: Scene);
  46718. /**
  46719. * Get the effect name of the layer.
  46720. * @return The effect name
  46721. */
  46722. abstract getEffectName(): string;
  46723. /**
  46724. * Checks for the readiness of the element composing the layer.
  46725. * @param subMesh the mesh to check for
  46726. * @param useInstances specify wether or not to use instances to render the mesh
  46727. * @return true if ready otherwise, false
  46728. */
  46729. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46730. /**
  46731. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46732. * @returns true if the effect requires stencil during the main canvas render pass.
  46733. */
  46734. abstract needStencil(): boolean;
  46735. /**
  46736. * Create the merge effect. This is the shader use to blit the information back
  46737. * to the main canvas at the end of the scene rendering.
  46738. * @returns The effect containing the shader used to merge the effect on the main canvas
  46739. */
  46740. protected abstract _createMergeEffect(): Effect;
  46741. /**
  46742. * Creates the render target textures and post processes used in the effect layer.
  46743. */
  46744. protected abstract _createTextureAndPostProcesses(): void;
  46745. /**
  46746. * Implementation specific of rendering the generating effect on the main canvas.
  46747. * @param effect The effect used to render through
  46748. */
  46749. protected abstract _internalRender(effect: Effect): void;
  46750. /**
  46751. * Sets the required values for both the emissive texture and and the main color.
  46752. */
  46753. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46754. /**
  46755. * Free any resources and references associated to a mesh.
  46756. * Internal use
  46757. * @param mesh The mesh to free.
  46758. */
  46759. abstract _disposeMesh(mesh: Mesh): void;
  46760. /**
  46761. * Serializes this layer (Glow or Highlight for example)
  46762. * @returns a serialized layer object
  46763. */
  46764. abstract serialize?(): any;
  46765. /**
  46766. * Initializes the effect layer with the required options.
  46767. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46768. */
  46769. protected _init(options: Partial<IEffectLayerOptions>): void;
  46770. /**
  46771. * Generates the index buffer of the full screen quad blending to the main canvas.
  46772. */
  46773. private _generateIndexBuffer;
  46774. /**
  46775. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46776. */
  46777. private _genrateVertexBuffer;
  46778. /**
  46779. * Sets the main texture desired size which is the closest power of two
  46780. * of the engine canvas size.
  46781. */
  46782. private _setMainTextureSize;
  46783. /**
  46784. * Creates the main texture for the effect layer.
  46785. */
  46786. protected _createMainTexture(): void;
  46787. /**
  46788. * Adds specific effects defines.
  46789. * @param defines The defines to add specifics to.
  46790. */
  46791. protected _addCustomEffectDefines(defines: string[]): void;
  46792. /**
  46793. * Checks for the readiness of the element composing the layer.
  46794. * @param subMesh the mesh to check for
  46795. * @param useInstances specify wether or not to use instances to render the mesh
  46796. * @param emissiveTexture the associated emissive texture used to generate the glow
  46797. * @return true if ready otherwise, false
  46798. */
  46799. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46800. /**
  46801. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46802. */
  46803. render(): void;
  46804. /**
  46805. * Determine if a given mesh will be used in the current effect.
  46806. * @param mesh mesh to test
  46807. * @returns true if the mesh will be used
  46808. */
  46809. hasMesh(mesh: AbstractMesh): boolean;
  46810. /**
  46811. * Returns true if the layer contains information to display, otherwise false.
  46812. * @returns true if the glow layer should be rendered
  46813. */
  46814. shouldRender(): boolean;
  46815. /**
  46816. * Returns true if the mesh should render, otherwise false.
  46817. * @param mesh The mesh to render
  46818. * @returns true if it should render otherwise false
  46819. */
  46820. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46821. /**
  46822. * Returns true if the mesh can be rendered, otherwise false.
  46823. * @param mesh The mesh to render
  46824. * @param material The material used on the mesh
  46825. * @returns true if it can be rendered otherwise false
  46826. */
  46827. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46828. /**
  46829. * Returns true if the mesh should render, otherwise false.
  46830. * @param mesh The mesh to render
  46831. * @returns true if it should render otherwise false
  46832. */
  46833. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46834. /**
  46835. * Renders the submesh passed in parameter to the generation map.
  46836. */
  46837. protected _renderSubMesh(subMesh: SubMesh): void;
  46838. /**
  46839. * Rebuild the required buffers.
  46840. * @hidden Internal use only.
  46841. */
  46842. _rebuild(): void;
  46843. /**
  46844. * Dispose only the render target textures and post process.
  46845. */
  46846. private _disposeTextureAndPostProcesses;
  46847. /**
  46848. * Dispose the highlight layer and free resources.
  46849. */
  46850. dispose(): void;
  46851. /**
  46852. * Gets the class name of the effect layer
  46853. * @returns the string with the class name of the effect layer
  46854. */
  46855. getClassName(): string;
  46856. /**
  46857. * Creates an effect layer from parsed effect layer data
  46858. * @param parsedEffectLayer defines effect layer data
  46859. * @param scene defines the current scene
  46860. * @param rootUrl defines the root URL containing the effect layer information
  46861. * @returns a parsed effect Layer
  46862. */
  46863. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46864. }
  46865. }
  46866. declare module BABYLON {
  46867. interface AbstractScene {
  46868. /**
  46869. * The list of effect layers (highlights/glow) added to the scene
  46870. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46871. * @see http://doc.babylonjs.com/how_to/glow_layer
  46872. */
  46873. effectLayers: Array<EffectLayer>;
  46874. /**
  46875. * Removes the given effect layer from this scene.
  46876. * @param toRemove defines the effect layer to remove
  46877. * @returns the index of the removed effect layer
  46878. */
  46879. removeEffectLayer(toRemove: EffectLayer): number;
  46880. /**
  46881. * Adds the given effect layer to this scene
  46882. * @param newEffectLayer defines the effect layer to add
  46883. */
  46884. addEffectLayer(newEffectLayer: EffectLayer): void;
  46885. }
  46886. /**
  46887. * Defines the layer scene component responsible to manage any effect layers
  46888. * in a given scene.
  46889. */
  46890. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46891. /**
  46892. * The component name helpfull to identify the component in the list of scene components.
  46893. */
  46894. readonly name: string;
  46895. /**
  46896. * The scene the component belongs to.
  46897. */
  46898. scene: Scene;
  46899. private _engine;
  46900. private _renderEffects;
  46901. private _needStencil;
  46902. private _previousStencilState;
  46903. /**
  46904. * Creates a new instance of the component for the given scene
  46905. * @param scene Defines the scene to register the component in
  46906. */
  46907. constructor(scene: Scene);
  46908. /**
  46909. * Registers the component in a given scene
  46910. */
  46911. register(): void;
  46912. /**
  46913. * Rebuilds the elements related to this component in case of
  46914. * context lost for instance.
  46915. */
  46916. rebuild(): void;
  46917. /**
  46918. * Serializes the component data to the specified json object
  46919. * @param serializationObject The object to serialize to
  46920. */
  46921. serialize(serializationObject: any): void;
  46922. /**
  46923. * Adds all the element from the container to the scene
  46924. * @param container the container holding the elements
  46925. */
  46926. addFromContainer(container: AbstractScene): void;
  46927. /**
  46928. * Removes all the elements in the container from the scene
  46929. * @param container contains the elements to remove
  46930. * @param dispose if the removed element should be disposed (default: false)
  46931. */
  46932. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46933. /**
  46934. * Disposes the component and the associated ressources.
  46935. */
  46936. dispose(): void;
  46937. private _isReadyForMesh;
  46938. private _renderMainTexture;
  46939. private _setStencil;
  46940. private _setStencilBack;
  46941. private _draw;
  46942. private _drawCamera;
  46943. private _drawRenderingGroup;
  46944. }
  46945. }
  46946. declare module BABYLON {
  46947. /** @hidden */
  46948. export var glowMapMergePixelShader: {
  46949. name: string;
  46950. shader: string;
  46951. };
  46952. }
  46953. declare module BABYLON {
  46954. /** @hidden */
  46955. export var glowMapMergeVertexShader: {
  46956. name: string;
  46957. shader: string;
  46958. };
  46959. }
  46960. declare module BABYLON {
  46961. interface AbstractScene {
  46962. /**
  46963. * Return a the first highlight layer of the scene with a given name.
  46964. * @param name The name of the highlight layer to look for.
  46965. * @return The highlight layer if found otherwise null.
  46966. */
  46967. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46968. }
  46969. /**
  46970. * Glow layer options. This helps customizing the behaviour
  46971. * of the glow layer.
  46972. */
  46973. export interface IGlowLayerOptions {
  46974. /**
  46975. * Multiplication factor apply to the canvas size to compute the render target size
  46976. * used to generated the glowing objects (the smaller the faster).
  46977. */
  46978. mainTextureRatio: number;
  46979. /**
  46980. * Enforces a fixed size texture to ensure resize independant blur.
  46981. */
  46982. mainTextureFixedSize?: number;
  46983. /**
  46984. * How big is the kernel of the blur texture.
  46985. */
  46986. blurKernelSize: number;
  46987. /**
  46988. * The camera attached to the layer.
  46989. */
  46990. camera: Nullable<Camera>;
  46991. /**
  46992. * Enable MSAA by chosing the number of samples.
  46993. */
  46994. mainTextureSamples?: number;
  46995. /**
  46996. * The rendering group to draw the layer in.
  46997. */
  46998. renderingGroupId: number;
  46999. }
  47000. /**
  47001. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47002. *
  47003. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47004. * glowy meshes to your scene.
  47005. *
  47006. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47007. */
  47008. export class GlowLayer extends EffectLayer {
  47009. /**
  47010. * Effect Name of the layer.
  47011. */
  47012. static readonly EffectName: string;
  47013. /**
  47014. * The default blur kernel size used for the glow.
  47015. */
  47016. static DefaultBlurKernelSize: number;
  47017. /**
  47018. * The default texture size ratio used for the glow.
  47019. */
  47020. static DefaultTextureRatio: number;
  47021. /**
  47022. * Sets the kernel size of the blur.
  47023. */
  47024. /**
  47025. * Gets the kernel size of the blur.
  47026. */
  47027. blurKernelSize: number;
  47028. /**
  47029. * Sets the glow intensity.
  47030. */
  47031. /**
  47032. * Gets the glow intensity.
  47033. */
  47034. intensity: number;
  47035. private _options;
  47036. private _intensity;
  47037. private _horizontalBlurPostprocess1;
  47038. private _verticalBlurPostprocess1;
  47039. private _horizontalBlurPostprocess2;
  47040. private _verticalBlurPostprocess2;
  47041. private _blurTexture1;
  47042. private _blurTexture2;
  47043. private _postProcesses1;
  47044. private _postProcesses2;
  47045. private _includedOnlyMeshes;
  47046. private _excludedMeshes;
  47047. /**
  47048. * Callback used to let the user override the color selection on a per mesh basis
  47049. */
  47050. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47051. /**
  47052. * Callback used to let the user override the texture selection on a per mesh basis
  47053. */
  47054. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47055. /**
  47056. * Instantiates a new glow Layer and references it to the scene.
  47057. * @param name The name of the layer
  47058. * @param scene The scene to use the layer in
  47059. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47060. */
  47061. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47062. /**
  47063. * Get the effect name of the layer.
  47064. * @return The effect name
  47065. */
  47066. getEffectName(): string;
  47067. /**
  47068. * Create the merge effect. This is the shader use to blit the information back
  47069. * to the main canvas at the end of the scene rendering.
  47070. */
  47071. protected _createMergeEffect(): Effect;
  47072. /**
  47073. * Creates the render target textures and post processes used in the glow layer.
  47074. */
  47075. protected _createTextureAndPostProcesses(): void;
  47076. /**
  47077. * Checks for the readiness of the element composing the layer.
  47078. * @param subMesh the mesh to check for
  47079. * @param useInstances specify wether or not to use instances to render the mesh
  47080. * @param emissiveTexture the associated emissive texture used to generate the glow
  47081. * @return true if ready otherwise, false
  47082. */
  47083. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47084. /**
  47085. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47086. */
  47087. needStencil(): boolean;
  47088. /**
  47089. * Returns true if the mesh can be rendered, otherwise false.
  47090. * @param mesh The mesh to render
  47091. * @param material The material used on the mesh
  47092. * @returns true if it can be rendered otherwise false
  47093. */
  47094. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47095. /**
  47096. * Implementation specific of rendering the generating effect on the main canvas.
  47097. * @param effect The effect used to render through
  47098. */
  47099. protected _internalRender(effect: Effect): void;
  47100. /**
  47101. * Sets the required values for both the emissive texture and and the main color.
  47102. */
  47103. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47104. /**
  47105. * Returns true if the mesh should render, otherwise false.
  47106. * @param mesh The mesh to render
  47107. * @returns true if it should render otherwise false
  47108. */
  47109. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47110. /**
  47111. * Adds specific effects defines.
  47112. * @param defines The defines to add specifics to.
  47113. */
  47114. protected _addCustomEffectDefines(defines: string[]): void;
  47115. /**
  47116. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47117. * @param mesh The mesh to exclude from the glow layer
  47118. */
  47119. addExcludedMesh(mesh: Mesh): void;
  47120. /**
  47121. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47122. * @param mesh The mesh to remove
  47123. */
  47124. removeExcludedMesh(mesh: Mesh): void;
  47125. /**
  47126. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47127. * @param mesh The mesh to include in the glow layer
  47128. */
  47129. addIncludedOnlyMesh(mesh: Mesh): void;
  47130. /**
  47131. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47132. * @param mesh The mesh to remove
  47133. */
  47134. removeIncludedOnlyMesh(mesh: Mesh): void;
  47135. /**
  47136. * Determine if a given mesh will be used in the glow layer
  47137. * @param mesh The mesh to test
  47138. * @returns true if the mesh will be highlighted by the current glow layer
  47139. */
  47140. hasMesh(mesh: AbstractMesh): boolean;
  47141. /**
  47142. * Free any resources and references associated to a mesh.
  47143. * Internal use
  47144. * @param mesh The mesh to free.
  47145. * @hidden
  47146. */
  47147. _disposeMesh(mesh: Mesh): void;
  47148. /**
  47149. * Gets the class name of the effect layer
  47150. * @returns the string with the class name of the effect layer
  47151. */
  47152. getClassName(): string;
  47153. /**
  47154. * Serializes this glow layer
  47155. * @returns a serialized glow layer object
  47156. */
  47157. serialize(): any;
  47158. /**
  47159. * Creates a Glow Layer from parsed glow layer data
  47160. * @param parsedGlowLayer defines glow layer data
  47161. * @param scene defines the current scene
  47162. * @param rootUrl defines the root URL containing the glow layer information
  47163. * @returns a parsed Glow Layer
  47164. */
  47165. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47166. }
  47167. }
  47168. declare module BABYLON {
  47169. /** @hidden */
  47170. export var glowBlurPostProcessPixelShader: {
  47171. name: string;
  47172. shader: string;
  47173. };
  47174. }
  47175. declare module BABYLON {
  47176. interface AbstractScene {
  47177. /**
  47178. * Return a the first highlight layer of the scene with a given name.
  47179. * @param name The name of the highlight layer to look for.
  47180. * @return The highlight layer if found otherwise null.
  47181. */
  47182. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47183. }
  47184. /**
  47185. * Highlight layer options. This helps customizing the behaviour
  47186. * of the highlight layer.
  47187. */
  47188. export interface IHighlightLayerOptions {
  47189. /**
  47190. * Multiplication factor apply to the canvas size to compute the render target size
  47191. * used to generated the glowing objects (the smaller the faster).
  47192. */
  47193. mainTextureRatio: number;
  47194. /**
  47195. * Enforces a fixed size texture to ensure resize independant blur.
  47196. */
  47197. mainTextureFixedSize?: number;
  47198. /**
  47199. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47200. * of the picture to blur (the smaller the faster).
  47201. */
  47202. blurTextureSizeRatio: number;
  47203. /**
  47204. * How big in texel of the blur texture is the vertical blur.
  47205. */
  47206. blurVerticalSize: number;
  47207. /**
  47208. * How big in texel of the blur texture is the horizontal blur.
  47209. */
  47210. blurHorizontalSize: number;
  47211. /**
  47212. * Alpha blending mode used to apply the blur. Default is combine.
  47213. */
  47214. alphaBlendingMode: number;
  47215. /**
  47216. * The camera attached to the layer.
  47217. */
  47218. camera: Nullable<Camera>;
  47219. /**
  47220. * Should we display highlight as a solid stroke?
  47221. */
  47222. isStroke?: boolean;
  47223. /**
  47224. * The rendering group to draw the layer in.
  47225. */
  47226. renderingGroupId: number;
  47227. }
  47228. /**
  47229. * The highlight layer Helps adding a glow effect around a mesh.
  47230. *
  47231. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47232. * glowy meshes to your scene.
  47233. *
  47234. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47235. */
  47236. export class HighlightLayer extends EffectLayer {
  47237. name: string;
  47238. /**
  47239. * Effect Name of the highlight layer.
  47240. */
  47241. static readonly EffectName: string;
  47242. /**
  47243. * The neutral color used during the preparation of the glow effect.
  47244. * This is black by default as the blend operation is a blend operation.
  47245. */
  47246. static NeutralColor: Color4;
  47247. /**
  47248. * Stencil value used for glowing meshes.
  47249. */
  47250. static GlowingMeshStencilReference: number;
  47251. /**
  47252. * Stencil value used for the other meshes in the scene.
  47253. */
  47254. static NormalMeshStencilReference: number;
  47255. /**
  47256. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47257. */
  47258. innerGlow: boolean;
  47259. /**
  47260. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47261. */
  47262. outerGlow: boolean;
  47263. /**
  47264. * Specifies the horizontal size of the blur.
  47265. */
  47266. /**
  47267. * Gets the horizontal size of the blur.
  47268. */
  47269. blurHorizontalSize: number;
  47270. /**
  47271. * Specifies the vertical size of the blur.
  47272. */
  47273. /**
  47274. * Gets the vertical size of the blur.
  47275. */
  47276. blurVerticalSize: number;
  47277. /**
  47278. * An event triggered when the highlight layer is being blurred.
  47279. */
  47280. onBeforeBlurObservable: Observable<HighlightLayer>;
  47281. /**
  47282. * An event triggered when the highlight layer has been blurred.
  47283. */
  47284. onAfterBlurObservable: Observable<HighlightLayer>;
  47285. private _instanceGlowingMeshStencilReference;
  47286. private _options;
  47287. private _downSamplePostprocess;
  47288. private _horizontalBlurPostprocess;
  47289. private _verticalBlurPostprocess;
  47290. private _blurTexture;
  47291. private _meshes;
  47292. private _excludedMeshes;
  47293. /**
  47294. * Instantiates a new highlight Layer and references it to the scene..
  47295. * @param name The name of the layer
  47296. * @param scene The scene to use the layer in
  47297. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47298. */
  47299. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47300. /**
  47301. * Get the effect name of the layer.
  47302. * @return The effect name
  47303. */
  47304. getEffectName(): string;
  47305. /**
  47306. * Create the merge effect. This is the shader use to blit the information back
  47307. * to the main canvas at the end of the scene rendering.
  47308. */
  47309. protected _createMergeEffect(): Effect;
  47310. /**
  47311. * Creates the render target textures and post processes used in the highlight layer.
  47312. */
  47313. protected _createTextureAndPostProcesses(): void;
  47314. /**
  47315. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47316. */
  47317. needStencil(): boolean;
  47318. /**
  47319. * Checks for the readiness of the element composing the layer.
  47320. * @param subMesh the mesh to check for
  47321. * @param useInstances specify wether or not to use instances to render the mesh
  47322. * @param emissiveTexture the associated emissive texture used to generate the glow
  47323. * @return true if ready otherwise, false
  47324. */
  47325. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47326. /**
  47327. * Implementation specific of rendering the generating effect on the main canvas.
  47328. * @param effect The effect used to render through
  47329. */
  47330. protected _internalRender(effect: Effect): void;
  47331. /**
  47332. * Returns true if the layer contains information to display, otherwise false.
  47333. */
  47334. shouldRender(): boolean;
  47335. /**
  47336. * Returns true if the mesh should render, otherwise false.
  47337. * @param mesh The mesh to render
  47338. * @returns true if it should render otherwise false
  47339. */
  47340. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47341. /**
  47342. * Sets the required values for both the emissive texture and and the main color.
  47343. */
  47344. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47345. /**
  47346. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47347. * @param mesh The mesh to exclude from the highlight layer
  47348. */
  47349. addExcludedMesh(mesh: Mesh): void;
  47350. /**
  47351. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47352. * @param mesh The mesh to highlight
  47353. */
  47354. removeExcludedMesh(mesh: Mesh): void;
  47355. /**
  47356. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47357. * @param mesh mesh to test
  47358. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47359. */
  47360. hasMesh(mesh: AbstractMesh): boolean;
  47361. /**
  47362. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47363. * @param mesh The mesh to highlight
  47364. * @param color The color of the highlight
  47365. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47366. */
  47367. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47368. /**
  47369. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47370. * @param mesh The mesh to highlight
  47371. */
  47372. removeMesh(mesh: Mesh): void;
  47373. /**
  47374. * Force the stencil to the normal expected value for none glowing parts
  47375. */
  47376. private _defaultStencilReference;
  47377. /**
  47378. * Free any resources and references associated to a mesh.
  47379. * Internal use
  47380. * @param mesh The mesh to free.
  47381. * @hidden
  47382. */
  47383. _disposeMesh(mesh: Mesh): void;
  47384. /**
  47385. * Dispose the highlight layer and free resources.
  47386. */
  47387. dispose(): void;
  47388. /**
  47389. * Gets the class name of the effect layer
  47390. * @returns the string with the class name of the effect layer
  47391. */
  47392. getClassName(): string;
  47393. /**
  47394. * Serializes this Highlight layer
  47395. * @returns a serialized Highlight layer object
  47396. */
  47397. serialize(): any;
  47398. /**
  47399. * Creates a Highlight layer from parsed Highlight layer data
  47400. * @param parsedHightlightLayer defines the Highlight layer data
  47401. * @param scene defines the current scene
  47402. * @param rootUrl defines the root URL containing the Highlight layer information
  47403. * @returns a parsed Highlight layer
  47404. */
  47405. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47406. }
  47407. }
  47408. declare module BABYLON {
  47409. /** @hidden */
  47410. export var lensFlarePixelShader: {
  47411. name: string;
  47412. shader: string;
  47413. };
  47414. }
  47415. declare module BABYLON {
  47416. /** @hidden */
  47417. export var lensFlareVertexShader: {
  47418. name: string;
  47419. shader: string;
  47420. };
  47421. }
  47422. declare module BABYLON {
  47423. /**
  47424. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47425. * It is usually composed of several `lensFlare`.
  47426. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47427. */
  47428. export class LensFlareSystem {
  47429. /**
  47430. * Define the name of the lens flare system
  47431. */
  47432. name: string;
  47433. /**
  47434. * List of lens flares used in this system.
  47435. */
  47436. lensFlares: LensFlare[];
  47437. /**
  47438. * Define a limit from the border the lens flare can be visible.
  47439. */
  47440. borderLimit: number;
  47441. /**
  47442. * Define a viewport border we do not want to see the lens flare in.
  47443. */
  47444. viewportBorder: number;
  47445. /**
  47446. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47447. */
  47448. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47449. /**
  47450. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47451. */
  47452. layerMask: number;
  47453. /**
  47454. * Define the id of the lens flare system in the scene.
  47455. * (equal to name by default)
  47456. */
  47457. id: string;
  47458. private _scene;
  47459. private _emitter;
  47460. private _vertexBuffers;
  47461. private _indexBuffer;
  47462. private _effect;
  47463. private _positionX;
  47464. private _positionY;
  47465. private _isEnabled;
  47466. /** @hidden */
  47467. static _SceneComponentInitialization: (scene: Scene) => void;
  47468. /**
  47469. * Instantiates a lens flare system.
  47470. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47471. * It is usually composed of several `lensFlare`.
  47472. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47473. * @param name Define the name of the lens flare system in the scene
  47474. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47475. * @param scene Define the scene the lens flare system belongs to
  47476. */
  47477. constructor(
  47478. /**
  47479. * Define the name of the lens flare system
  47480. */
  47481. name: string, emitter: any, scene: Scene);
  47482. /**
  47483. * Define if the lens flare system is enabled.
  47484. */
  47485. isEnabled: boolean;
  47486. /**
  47487. * Get the scene the effects belongs to.
  47488. * @returns the scene holding the lens flare system
  47489. */
  47490. getScene(): Scene;
  47491. /**
  47492. * Get the emitter of the lens flare system.
  47493. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47494. * @returns the emitter of the lens flare system
  47495. */
  47496. getEmitter(): any;
  47497. /**
  47498. * Set the emitter of the lens flare system.
  47499. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47500. * @param newEmitter Define the new emitter of the system
  47501. */
  47502. setEmitter(newEmitter: any): void;
  47503. /**
  47504. * Get the lens flare system emitter position.
  47505. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47506. * @returns the position
  47507. */
  47508. getEmitterPosition(): Vector3;
  47509. /**
  47510. * @hidden
  47511. */
  47512. computeEffectivePosition(globalViewport: Viewport): boolean;
  47513. /** @hidden */
  47514. _isVisible(): boolean;
  47515. /**
  47516. * @hidden
  47517. */
  47518. render(): boolean;
  47519. /**
  47520. * Dispose and release the lens flare with its associated resources.
  47521. */
  47522. dispose(): void;
  47523. /**
  47524. * Parse a lens flare system from a JSON repressentation
  47525. * @param parsedLensFlareSystem Define the JSON to parse
  47526. * @param scene Define the scene the parsed system should be instantiated in
  47527. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47528. * @returns the parsed system
  47529. */
  47530. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47531. /**
  47532. * Serialize the current Lens Flare System into a JSON representation.
  47533. * @returns the serialized JSON
  47534. */
  47535. serialize(): any;
  47536. }
  47537. }
  47538. declare module BABYLON {
  47539. /**
  47540. * This represents one of the lens effect in a `lensFlareSystem`.
  47541. * It controls one of the indiviual texture used in the effect.
  47542. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47543. */
  47544. export class LensFlare {
  47545. /**
  47546. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47547. */
  47548. size: number;
  47549. /**
  47550. * 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.
  47551. */
  47552. position: number;
  47553. /**
  47554. * Define the lens color.
  47555. */
  47556. color: Color3;
  47557. /**
  47558. * Define the lens texture.
  47559. */
  47560. texture: Nullable<Texture>;
  47561. /**
  47562. * Define the alpha mode to render this particular lens.
  47563. */
  47564. alphaMode: number;
  47565. private _system;
  47566. /**
  47567. * Creates a new Lens Flare.
  47568. * This represents one of the lens effect in a `lensFlareSystem`.
  47569. * It controls one of the indiviual texture used in the effect.
  47570. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47571. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47572. * @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.
  47573. * @param color Define the lens color
  47574. * @param imgUrl Define the lens texture url
  47575. * @param system Define the `lensFlareSystem` this flare is part of
  47576. * @returns The newly created Lens Flare
  47577. */
  47578. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47579. /**
  47580. * Instantiates a new Lens Flare.
  47581. * This represents one of the lens effect in a `lensFlareSystem`.
  47582. * It controls one of the indiviual texture used in the effect.
  47583. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47584. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47585. * @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.
  47586. * @param color Define the lens color
  47587. * @param imgUrl Define the lens texture url
  47588. * @param system Define the `lensFlareSystem` this flare is part of
  47589. */
  47590. constructor(
  47591. /**
  47592. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47593. */
  47594. size: number,
  47595. /**
  47596. * 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.
  47597. */
  47598. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47599. /**
  47600. * Dispose and release the lens flare with its associated resources.
  47601. */
  47602. dispose(): void;
  47603. }
  47604. }
  47605. declare module BABYLON {
  47606. interface AbstractScene {
  47607. /**
  47608. * The list of lens flare system added to the scene
  47609. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47610. */
  47611. lensFlareSystems: Array<LensFlareSystem>;
  47612. /**
  47613. * Removes the given lens flare system from this scene.
  47614. * @param toRemove The lens flare system to remove
  47615. * @returns The index of the removed lens flare system
  47616. */
  47617. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47618. /**
  47619. * Adds the given lens flare system to this scene
  47620. * @param newLensFlareSystem The lens flare system to add
  47621. */
  47622. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47623. /**
  47624. * Gets a lens flare system using its name
  47625. * @param name defines the name to look for
  47626. * @returns the lens flare system or null if not found
  47627. */
  47628. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47629. /**
  47630. * Gets a lens flare system using its id
  47631. * @param id defines the id to look for
  47632. * @returns the lens flare system or null if not found
  47633. */
  47634. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47635. }
  47636. /**
  47637. * Defines the lens flare scene component responsible to manage any lens flares
  47638. * in a given scene.
  47639. */
  47640. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47641. /**
  47642. * The component name helpfull to identify the component in the list of scene components.
  47643. */
  47644. readonly name: string;
  47645. /**
  47646. * The scene the component belongs to.
  47647. */
  47648. scene: Scene;
  47649. /**
  47650. * Creates a new instance of the component for the given scene
  47651. * @param scene Defines the scene to register the component in
  47652. */
  47653. constructor(scene: Scene);
  47654. /**
  47655. * Registers the component in a given scene
  47656. */
  47657. register(): void;
  47658. /**
  47659. * Rebuilds the elements related to this component in case of
  47660. * context lost for instance.
  47661. */
  47662. rebuild(): void;
  47663. /**
  47664. * Adds all the element from the container to the scene
  47665. * @param container the container holding the elements
  47666. */
  47667. addFromContainer(container: AbstractScene): void;
  47668. /**
  47669. * Removes all the elements in the container from the scene
  47670. * @param container contains the elements to remove
  47671. * @param dispose if the removed element should be disposed (default: false)
  47672. */
  47673. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47674. /**
  47675. * Serializes the component data to the specified json object
  47676. * @param serializationObject The object to serialize to
  47677. */
  47678. serialize(serializationObject: any): void;
  47679. /**
  47680. * Disposes the component and the associated ressources.
  47681. */
  47682. dispose(): void;
  47683. private _draw;
  47684. }
  47685. }
  47686. declare module BABYLON {
  47687. /**
  47688. * Defines the shadow generator component responsible to manage any shadow generators
  47689. * in a given scene.
  47690. */
  47691. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47692. /**
  47693. * The component name helpfull to identify the component in the list of scene components.
  47694. */
  47695. readonly name: string;
  47696. /**
  47697. * The scene the component belongs to.
  47698. */
  47699. scene: Scene;
  47700. /**
  47701. * Creates a new instance of the component for the given scene
  47702. * @param scene Defines the scene to register the component in
  47703. */
  47704. constructor(scene: Scene);
  47705. /**
  47706. * Registers the component in a given scene
  47707. */
  47708. register(): void;
  47709. /**
  47710. * Rebuilds the elements related to this component in case of
  47711. * context lost for instance.
  47712. */
  47713. rebuild(): void;
  47714. /**
  47715. * Serializes the component data to the specified json object
  47716. * @param serializationObject The object to serialize to
  47717. */
  47718. serialize(serializationObject: any): void;
  47719. /**
  47720. * Adds all the element from the container to the scene
  47721. * @param container the container holding the elements
  47722. */
  47723. addFromContainer(container: AbstractScene): void;
  47724. /**
  47725. * Removes all the elements in the container from the scene
  47726. * @param container contains the elements to remove
  47727. * @param dispose if the removed element should be disposed (default: false)
  47728. */
  47729. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47730. /**
  47731. * Rebuilds the elements related to this component in case of
  47732. * context lost for instance.
  47733. */
  47734. dispose(): void;
  47735. private _gatherRenderTargets;
  47736. }
  47737. }
  47738. declare module BABYLON {
  47739. /**
  47740. * A point light is a light defined by an unique point in world space.
  47741. * The light is emitted in every direction from this point.
  47742. * A good example of a point light is a standard light bulb.
  47743. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47744. */
  47745. export class PointLight extends ShadowLight {
  47746. private _shadowAngle;
  47747. /**
  47748. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47749. * This specifies what angle the shadow will use to be created.
  47750. *
  47751. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47752. */
  47753. /**
  47754. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47755. * This specifies what angle the shadow will use to be created.
  47756. *
  47757. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47758. */
  47759. shadowAngle: number;
  47760. /**
  47761. * Gets the direction if it has been set.
  47762. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47763. */
  47764. /**
  47765. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47766. */
  47767. direction: Vector3;
  47768. /**
  47769. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47770. * A PointLight emits the light in every direction.
  47771. * It can cast shadows.
  47772. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47773. * ```javascript
  47774. * var pointLight = new PointLight("pl", camera.position, scene);
  47775. * ```
  47776. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47777. * @param name The light friendly name
  47778. * @param position The position of the point light in the scene
  47779. * @param scene The scene the lights belongs to
  47780. */
  47781. constructor(name: string, position: Vector3, scene: Scene);
  47782. /**
  47783. * Returns the string "PointLight"
  47784. * @returns the class name
  47785. */
  47786. getClassName(): string;
  47787. /**
  47788. * Returns the integer 0.
  47789. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47790. */
  47791. getTypeID(): number;
  47792. /**
  47793. * Specifies wether or not the shadowmap should be a cube texture.
  47794. * @returns true if the shadowmap needs to be a cube texture.
  47795. */
  47796. needCube(): boolean;
  47797. /**
  47798. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47799. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47800. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47801. */
  47802. getShadowDirection(faceIndex?: number): Vector3;
  47803. /**
  47804. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47805. * - fov = PI / 2
  47806. * - aspect ratio : 1.0
  47807. * - z-near and far equal to the active camera minZ and maxZ.
  47808. * Returns the PointLight.
  47809. */
  47810. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47811. protected _buildUniformLayout(): void;
  47812. /**
  47813. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47814. * @param effect The effect to update
  47815. * @param lightIndex The index of the light in the effect to update
  47816. * @returns The point light
  47817. */
  47818. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47819. /**
  47820. * Prepares the list of defines specific to the light type.
  47821. * @param defines the list of defines
  47822. * @param lightIndex defines the index of the light for the effect
  47823. */
  47824. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47825. }
  47826. }
  47827. declare module BABYLON {
  47828. /**
  47829. * Header information of HDR texture files.
  47830. */
  47831. export interface HDRInfo {
  47832. /**
  47833. * The height of the texture in pixels.
  47834. */
  47835. height: number;
  47836. /**
  47837. * The width of the texture in pixels.
  47838. */
  47839. width: number;
  47840. /**
  47841. * The index of the beginning of the data in the binary file.
  47842. */
  47843. dataPosition: number;
  47844. }
  47845. /**
  47846. * This groups tools to convert HDR texture to native colors array.
  47847. */
  47848. export class HDRTools {
  47849. private static Ldexp;
  47850. private static Rgbe2float;
  47851. private static readStringLine;
  47852. /**
  47853. * Reads header information from an RGBE texture stored in a native array.
  47854. * More information on this format are available here:
  47855. * https://en.wikipedia.org/wiki/RGBE_image_format
  47856. *
  47857. * @param uint8array The binary file stored in native array.
  47858. * @return The header information.
  47859. */
  47860. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47861. /**
  47862. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47863. * This RGBE texture needs to store the information as a panorama.
  47864. *
  47865. * More information on this format are available here:
  47866. * https://en.wikipedia.org/wiki/RGBE_image_format
  47867. *
  47868. * @param buffer The binary file stored in an array buffer.
  47869. * @param size The expected size of the extracted cubemap.
  47870. * @return The Cube Map information.
  47871. */
  47872. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47873. /**
  47874. * Returns the pixels data extracted from an RGBE texture.
  47875. * This pixels will be stored left to right up to down in the R G B order in one array.
  47876. *
  47877. * More information on this format are available here:
  47878. * https://en.wikipedia.org/wiki/RGBE_image_format
  47879. *
  47880. * @param uint8array The binary file stored in an array buffer.
  47881. * @param hdrInfo The header information of the file.
  47882. * @return The pixels data in RGB right to left up to down order.
  47883. */
  47884. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47885. private static RGBE_ReadPixels_RLE;
  47886. }
  47887. }
  47888. declare module BABYLON {
  47889. /**
  47890. * This represents a texture coming from an HDR input.
  47891. *
  47892. * The only supported format is currently panorama picture stored in RGBE format.
  47893. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47894. */
  47895. export class HDRCubeTexture extends BaseTexture {
  47896. private static _facesMapping;
  47897. private _generateHarmonics;
  47898. private _noMipmap;
  47899. private _textureMatrix;
  47900. private _size;
  47901. private _onLoad;
  47902. private _onError;
  47903. /**
  47904. * The texture URL.
  47905. */
  47906. url: string;
  47907. /**
  47908. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47909. */
  47910. coordinatesMode: number;
  47911. protected _isBlocking: boolean;
  47912. /**
  47913. * Sets wether or not the texture is blocking during loading.
  47914. */
  47915. /**
  47916. * Gets wether or not the texture is blocking during loading.
  47917. */
  47918. isBlocking: boolean;
  47919. protected _rotationY: number;
  47920. /**
  47921. * Sets texture matrix rotation angle around Y axis in radians.
  47922. */
  47923. /**
  47924. * Gets texture matrix rotation angle around Y axis radians.
  47925. */
  47926. rotationY: number;
  47927. /**
  47928. * Gets or sets the center of the bounding box associated with the cube texture
  47929. * It must define where the camera used to render the texture was set
  47930. */
  47931. boundingBoxPosition: Vector3;
  47932. private _boundingBoxSize;
  47933. /**
  47934. * Gets or sets the size of the bounding box associated with the cube texture
  47935. * When defined, the cubemap will switch to local mode
  47936. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47937. * @example https://www.babylonjs-playground.com/#RNASML
  47938. */
  47939. boundingBoxSize: Vector3;
  47940. /**
  47941. * Instantiates an HDRTexture from the following parameters.
  47942. *
  47943. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47944. * @param scene The scene the texture will be used in
  47945. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47946. * @param noMipmap Forces to not generate the mipmap if true
  47947. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47948. * @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)
  47949. * @param reserved Reserved flag for internal use.
  47950. */
  47951. 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>);
  47952. /**
  47953. * Get the current class name of the texture useful for serialization or dynamic coding.
  47954. * @returns "HDRCubeTexture"
  47955. */
  47956. getClassName(): string;
  47957. /**
  47958. * Occurs when the file is raw .hdr file.
  47959. */
  47960. private loadTexture;
  47961. clone(): HDRCubeTexture;
  47962. delayLoad(): void;
  47963. /**
  47964. * Get the texture reflection matrix used to rotate/transform the reflection.
  47965. * @returns the reflection matrix
  47966. */
  47967. getReflectionTextureMatrix(): Matrix;
  47968. /**
  47969. * Set the texture reflection matrix used to rotate/transform the reflection.
  47970. * @param value Define the reflection matrix to set
  47971. */
  47972. setReflectionTextureMatrix(value: Matrix): void;
  47973. /**
  47974. * Parses a JSON representation of an HDR Texture in order to create the texture
  47975. * @param parsedTexture Define the JSON representation
  47976. * @param scene Define the scene the texture should be created in
  47977. * @param rootUrl Define the root url in case we need to load relative dependencies
  47978. * @returns the newly created texture after parsing
  47979. */
  47980. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47981. serialize(): any;
  47982. }
  47983. }
  47984. declare module BABYLON {
  47985. /**
  47986. * Class used to control physics engine
  47987. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47988. */
  47989. export class PhysicsEngine implements IPhysicsEngine {
  47990. private _physicsPlugin;
  47991. /**
  47992. * Global value used to control the smallest number supported by the simulation
  47993. */
  47994. static Epsilon: number;
  47995. private _impostors;
  47996. private _joints;
  47997. /**
  47998. * Gets the gravity vector used by the simulation
  47999. */
  48000. gravity: Vector3;
  48001. /**
  48002. * Factory used to create the default physics plugin.
  48003. * @returns The default physics plugin
  48004. */
  48005. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48006. /**
  48007. * Creates a new Physics Engine
  48008. * @param gravity defines the gravity vector used by the simulation
  48009. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48010. */
  48011. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48012. /**
  48013. * Sets the gravity vector used by the simulation
  48014. * @param gravity defines the gravity vector to use
  48015. */
  48016. setGravity(gravity: Vector3): void;
  48017. /**
  48018. * Set the time step of the physics engine.
  48019. * Default is 1/60.
  48020. * To slow it down, enter 1/600 for example.
  48021. * To speed it up, 1/30
  48022. * @param newTimeStep defines the new timestep to apply to this world.
  48023. */
  48024. setTimeStep(newTimeStep?: number): void;
  48025. /**
  48026. * Get the time step of the physics engine.
  48027. * @returns the current time step
  48028. */
  48029. getTimeStep(): number;
  48030. /**
  48031. * Release all resources
  48032. */
  48033. dispose(): void;
  48034. /**
  48035. * Gets the name of the current physics plugin
  48036. * @returns the name of the plugin
  48037. */
  48038. getPhysicsPluginName(): string;
  48039. /**
  48040. * Adding a new impostor for the impostor tracking.
  48041. * This will be done by the impostor itself.
  48042. * @param impostor the impostor to add
  48043. */
  48044. addImpostor(impostor: PhysicsImpostor): void;
  48045. /**
  48046. * Remove an impostor from the engine.
  48047. * This impostor and its mesh will not longer be updated by the physics engine.
  48048. * @param impostor the impostor to remove
  48049. */
  48050. removeImpostor(impostor: PhysicsImpostor): void;
  48051. /**
  48052. * Add a joint to the physics engine
  48053. * @param mainImpostor defines the main impostor to which the joint is added.
  48054. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48055. * @param joint defines the joint that will connect both impostors.
  48056. */
  48057. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48058. /**
  48059. * Removes a joint from the simulation
  48060. * @param mainImpostor defines the impostor used with the joint
  48061. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48062. * @param joint defines the joint to remove
  48063. */
  48064. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48065. /**
  48066. * Called by the scene. No need to call it.
  48067. * @param delta defines the timespam between frames
  48068. */
  48069. _step(delta: number): void;
  48070. /**
  48071. * Gets the current plugin used to run the simulation
  48072. * @returns current plugin
  48073. */
  48074. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48075. /**
  48076. * Gets the list of physic impostors
  48077. * @returns an array of PhysicsImpostor
  48078. */
  48079. getImpostors(): Array<PhysicsImpostor>;
  48080. /**
  48081. * Gets the impostor for a physics enabled object
  48082. * @param object defines the object impersonated by the impostor
  48083. * @returns the PhysicsImpostor or null if not found
  48084. */
  48085. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48086. /**
  48087. * Gets the impostor for a physics body object
  48088. * @param body defines physics body used by the impostor
  48089. * @returns the PhysicsImpostor or null if not found
  48090. */
  48091. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48092. /**
  48093. * Does a raycast in the physics world
  48094. * @param from when should the ray start?
  48095. * @param to when should the ray end?
  48096. * @returns PhysicsRaycastResult
  48097. */
  48098. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48099. }
  48100. }
  48101. declare module BABYLON {
  48102. /** @hidden */
  48103. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48104. private _useDeltaForWorldStep;
  48105. world: any;
  48106. name: string;
  48107. private _physicsMaterials;
  48108. private _fixedTimeStep;
  48109. private _cannonRaycastResult;
  48110. private _raycastResult;
  48111. private _removeAfterStep;
  48112. BJSCANNON: any;
  48113. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48114. setGravity(gravity: Vector3): void;
  48115. setTimeStep(timeStep: number): void;
  48116. getTimeStep(): number;
  48117. executeStep(delta: number): void;
  48118. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48119. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48120. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48121. private _processChildMeshes;
  48122. removePhysicsBody(impostor: PhysicsImpostor): void;
  48123. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48124. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48125. private _addMaterial;
  48126. private _checkWithEpsilon;
  48127. private _createShape;
  48128. private _createHeightmap;
  48129. private _minus90X;
  48130. private _plus90X;
  48131. private _tmpPosition;
  48132. private _tmpDeltaPosition;
  48133. private _tmpUnityRotation;
  48134. private _updatePhysicsBodyTransformation;
  48135. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48136. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48137. isSupported(): boolean;
  48138. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48139. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48140. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48141. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48142. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48143. getBodyMass(impostor: PhysicsImpostor): number;
  48144. getBodyFriction(impostor: PhysicsImpostor): number;
  48145. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48146. getBodyRestitution(impostor: PhysicsImpostor): number;
  48147. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48148. sleepBody(impostor: PhysicsImpostor): void;
  48149. wakeUpBody(impostor: PhysicsImpostor): void;
  48150. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48151. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48152. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48153. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48154. getRadius(impostor: PhysicsImpostor): number;
  48155. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48156. dispose(): void;
  48157. private _extendNamespace;
  48158. /**
  48159. * Does a raycast in the physics world
  48160. * @param from when should the ray start?
  48161. * @param to when should the ray end?
  48162. * @returns PhysicsRaycastResult
  48163. */
  48164. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48165. }
  48166. }
  48167. declare module BABYLON {
  48168. /** @hidden */
  48169. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48170. world: any;
  48171. name: string;
  48172. BJSOIMO: any;
  48173. private _raycastResult;
  48174. constructor(iterations?: number, oimoInjection?: any);
  48175. setGravity(gravity: Vector3): void;
  48176. setTimeStep(timeStep: number): void;
  48177. getTimeStep(): number;
  48178. private _tmpImpostorsArray;
  48179. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48180. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48181. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48182. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48183. private _tmpPositionVector;
  48184. removePhysicsBody(impostor: PhysicsImpostor): void;
  48185. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48186. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48187. isSupported(): boolean;
  48188. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48189. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48190. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48191. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48192. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48193. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48194. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48195. getBodyMass(impostor: PhysicsImpostor): number;
  48196. getBodyFriction(impostor: PhysicsImpostor): number;
  48197. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48198. getBodyRestitution(impostor: PhysicsImpostor): number;
  48199. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48200. sleepBody(impostor: PhysicsImpostor): void;
  48201. wakeUpBody(impostor: PhysicsImpostor): void;
  48202. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48203. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48204. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48205. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48206. getRadius(impostor: PhysicsImpostor): number;
  48207. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48208. dispose(): void;
  48209. /**
  48210. * Does a raycast in the physics world
  48211. * @param from when should the ray start?
  48212. * @param to when should the ray end?
  48213. * @returns PhysicsRaycastResult
  48214. */
  48215. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48216. }
  48217. }
  48218. declare module BABYLON {
  48219. /**
  48220. * Class containing static functions to help procedurally build meshes
  48221. */
  48222. export class RibbonBuilder {
  48223. /**
  48224. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48225. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48226. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48227. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48228. * * 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
  48229. * * 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
  48230. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  48231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48233. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48234. * * 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
  48235. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48236. * * 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
  48237. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48239. * @param name defines the name of the mesh
  48240. * @param options defines the options used to create the mesh
  48241. * @param scene defines the hosting scene
  48242. * @returns the ribbon mesh
  48243. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48244. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48245. */
  48246. static CreateRibbon(name: string, options: {
  48247. pathArray: Vector3[][];
  48248. closeArray?: boolean;
  48249. closePath?: boolean;
  48250. offset?: number;
  48251. updatable?: boolean;
  48252. sideOrientation?: number;
  48253. frontUVs?: Vector4;
  48254. backUVs?: Vector4;
  48255. instance?: Mesh;
  48256. invertUV?: boolean;
  48257. uvs?: Vector2[];
  48258. colors?: Color4[];
  48259. }, scene?: Nullable<Scene>): Mesh;
  48260. }
  48261. }
  48262. declare module BABYLON {
  48263. /**
  48264. * Class containing static functions to help procedurally build meshes
  48265. */
  48266. export class ShapeBuilder {
  48267. /**
  48268. * 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.
  48269. * * 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.
  48270. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48271. * * 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.
  48272. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48273. * * 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
  48274. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  48275. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48278. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48280. * @param name defines the name of the mesh
  48281. * @param options defines the options used to create the mesh
  48282. * @param scene defines the hosting scene
  48283. * @returns the extruded shape mesh
  48284. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48285. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48286. */
  48287. static ExtrudeShape(name: string, options: {
  48288. shape: Vector3[];
  48289. path: Vector3[];
  48290. scale?: number;
  48291. rotation?: number;
  48292. cap?: number;
  48293. updatable?: boolean;
  48294. sideOrientation?: number;
  48295. frontUVs?: Vector4;
  48296. backUVs?: Vector4;
  48297. instance?: Mesh;
  48298. invertUV?: boolean;
  48299. }, scene?: Nullable<Scene>): Mesh;
  48300. /**
  48301. * Creates an custom extruded shape mesh.
  48302. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48303. * * 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.
  48304. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48305. * * 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
  48306. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48307. * * 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
  48308. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48309. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48310. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48311. * * 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
  48312. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  48313. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48316. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48318. * @param name defines the name of the mesh
  48319. * @param options defines the options used to create the mesh
  48320. * @param scene defines the hosting scene
  48321. * @returns the custom extruded shape mesh
  48322. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48323. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48324. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48325. */
  48326. static ExtrudeShapeCustom(name: string, options: {
  48327. shape: Vector3[];
  48328. path: Vector3[];
  48329. scaleFunction?: any;
  48330. rotationFunction?: any;
  48331. ribbonCloseArray?: boolean;
  48332. ribbonClosePath?: boolean;
  48333. cap?: number;
  48334. updatable?: boolean;
  48335. sideOrientation?: number;
  48336. frontUVs?: Vector4;
  48337. backUVs?: Vector4;
  48338. instance?: Mesh;
  48339. invertUV?: boolean;
  48340. }, scene?: Nullable<Scene>): Mesh;
  48341. private static _ExtrudeShapeGeneric;
  48342. }
  48343. }
  48344. declare module BABYLON {
  48345. /**
  48346. * AmmoJS Physics plugin
  48347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48348. * @see https://github.com/kripken/ammo.js/
  48349. */
  48350. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48351. private _useDeltaForWorldStep;
  48352. /**
  48353. * Reference to the Ammo library
  48354. */
  48355. bjsAMMO: any;
  48356. /**
  48357. * Created ammoJS world which physics bodies are added to
  48358. */
  48359. world: any;
  48360. /**
  48361. * Name of the plugin
  48362. */
  48363. name: string;
  48364. private _timeStep;
  48365. private _fixedTimeStep;
  48366. private _maxSteps;
  48367. private _tmpQuaternion;
  48368. private _tmpAmmoTransform;
  48369. private _tmpAmmoQuaternion;
  48370. private _tmpAmmoConcreteContactResultCallback;
  48371. private _collisionConfiguration;
  48372. private _dispatcher;
  48373. private _overlappingPairCache;
  48374. private _solver;
  48375. private _softBodySolver;
  48376. private _tmpAmmoVectorA;
  48377. private _tmpAmmoVectorB;
  48378. private _tmpAmmoVectorC;
  48379. private _tmpAmmoVectorD;
  48380. private _tmpContactCallbackResult;
  48381. private _tmpAmmoVectorRCA;
  48382. private _tmpAmmoVectorRCB;
  48383. private _raycastResult;
  48384. private static readonly DISABLE_COLLISION_FLAG;
  48385. private static readonly KINEMATIC_FLAG;
  48386. private static readonly DISABLE_DEACTIVATION_FLAG;
  48387. /**
  48388. * Initializes the ammoJS plugin
  48389. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48390. * @param ammoInjection can be used to inject your own ammo reference
  48391. */
  48392. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48393. /**
  48394. * Sets the gravity of the physics world (m/(s^2))
  48395. * @param gravity Gravity to set
  48396. */
  48397. setGravity(gravity: Vector3): void;
  48398. /**
  48399. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48400. * @param timeStep timestep to use in seconds
  48401. */
  48402. setTimeStep(timeStep: number): void;
  48403. /**
  48404. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  48405. * @param fixedTimeStep fixedTimeStep to use in seconds
  48406. */
  48407. setFixedTimeStep(fixedTimeStep: number): void;
  48408. /**
  48409. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48410. * @param maxSteps the maximum number of steps by the physics engine per frame
  48411. */
  48412. setMaxSteps(maxSteps: number): void;
  48413. /**
  48414. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48415. * @returns the current timestep in seconds
  48416. */
  48417. getTimeStep(): number;
  48418. private _isImpostorInContact;
  48419. private _isImpostorPairInContact;
  48420. private _stepSimulation;
  48421. /**
  48422. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48423. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48424. * After the step the babylon meshes are set to the position of the physics imposters
  48425. * @param delta amount of time to step forward
  48426. * @param impostors array of imposters to update before/after the step
  48427. */
  48428. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48429. /**
  48430. * Update babylon mesh to match physics world object
  48431. * @param impostor imposter to match
  48432. */
  48433. private _afterSoftStep;
  48434. /**
  48435. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48436. * @param impostor imposter to match
  48437. */
  48438. private _ropeStep;
  48439. /**
  48440. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48441. * @param impostor imposter to match
  48442. */
  48443. private _softbodyOrClothStep;
  48444. private _tmpVector;
  48445. private _tmpMatrix;
  48446. /**
  48447. * Applies an impulse on the imposter
  48448. * @param impostor imposter to apply impulse to
  48449. * @param force amount of force to be applied to the imposter
  48450. * @param contactPoint the location to apply the impulse on the imposter
  48451. */
  48452. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48453. /**
  48454. * Applies a force on the imposter
  48455. * @param impostor imposter to apply force
  48456. * @param force amount of force to be applied to the imposter
  48457. * @param contactPoint the location to apply the force on the imposter
  48458. */
  48459. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48460. /**
  48461. * Creates a physics body using the plugin
  48462. * @param impostor the imposter to create the physics body on
  48463. */
  48464. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48465. /**
  48466. * Removes the physics body from the imposter and disposes of the body's memory
  48467. * @param impostor imposter to remove the physics body from
  48468. */
  48469. removePhysicsBody(impostor: PhysicsImpostor): void;
  48470. /**
  48471. * Generates a joint
  48472. * @param impostorJoint the imposter joint to create the joint with
  48473. */
  48474. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48475. /**
  48476. * Removes a joint
  48477. * @param impostorJoint the imposter joint to remove the joint from
  48478. */
  48479. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48480. private _addMeshVerts;
  48481. /**
  48482. * Initialise the soft body vertices to match its object's (mesh) vertices
  48483. * Softbody vertices (nodes) are in world space and to match this
  48484. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48485. * @param impostor to create the softbody for
  48486. */
  48487. private _softVertexData;
  48488. /**
  48489. * Create an impostor's soft body
  48490. * @param impostor to create the softbody for
  48491. */
  48492. private _createSoftbody;
  48493. /**
  48494. * Create cloth for an impostor
  48495. * @param impostor to create the softbody for
  48496. */
  48497. private _createCloth;
  48498. /**
  48499. * Create rope for an impostor
  48500. * @param impostor to create the softbody for
  48501. */
  48502. private _createRope;
  48503. private _addHullVerts;
  48504. private _createShape;
  48505. /**
  48506. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48507. * @param impostor imposter containing the physics body and babylon object
  48508. */
  48509. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48510. /**
  48511. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48512. * @param impostor imposter containing the physics body and babylon object
  48513. * @param newPosition new position
  48514. * @param newRotation new rotation
  48515. */
  48516. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48517. /**
  48518. * If this plugin is supported
  48519. * @returns true if its supported
  48520. */
  48521. isSupported(): boolean;
  48522. /**
  48523. * Sets the linear velocity of the physics body
  48524. * @param impostor imposter to set the velocity on
  48525. * @param velocity velocity to set
  48526. */
  48527. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48528. /**
  48529. * Sets the angular velocity of the physics body
  48530. * @param impostor imposter to set the velocity on
  48531. * @param velocity velocity to set
  48532. */
  48533. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48534. /**
  48535. * gets the linear velocity
  48536. * @param impostor imposter to get linear velocity from
  48537. * @returns linear velocity
  48538. */
  48539. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48540. /**
  48541. * gets the angular velocity
  48542. * @param impostor imposter to get angular velocity from
  48543. * @returns angular velocity
  48544. */
  48545. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48546. /**
  48547. * Sets the mass of physics body
  48548. * @param impostor imposter to set the mass on
  48549. * @param mass mass to set
  48550. */
  48551. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48552. /**
  48553. * Gets the mass of the physics body
  48554. * @param impostor imposter to get the mass from
  48555. * @returns mass
  48556. */
  48557. getBodyMass(impostor: PhysicsImpostor): number;
  48558. /**
  48559. * Gets friction of the impostor
  48560. * @param impostor impostor to get friction from
  48561. * @returns friction value
  48562. */
  48563. getBodyFriction(impostor: PhysicsImpostor): number;
  48564. /**
  48565. * Sets friction of the impostor
  48566. * @param impostor impostor to set friction on
  48567. * @param friction friction value
  48568. */
  48569. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48570. /**
  48571. * Gets restitution of the impostor
  48572. * @param impostor impostor to get restitution from
  48573. * @returns restitution value
  48574. */
  48575. getBodyRestitution(impostor: PhysicsImpostor): number;
  48576. /**
  48577. * Sets resitution of the impostor
  48578. * @param impostor impostor to set resitution on
  48579. * @param restitution resitution value
  48580. */
  48581. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48582. /**
  48583. * Gets pressure inside the impostor
  48584. * @param impostor impostor to get pressure from
  48585. * @returns pressure value
  48586. */
  48587. getBodyPressure(impostor: PhysicsImpostor): number;
  48588. /**
  48589. * Sets pressure inside a soft body impostor
  48590. * Cloth and rope must remain 0 pressure
  48591. * @param impostor impostor to set pressure on
  48592. * @param pressure pressure value
  48593. */
  48594. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48595. /**
  48596. * Gets stiffness of the impostor
  48597. * @param impostor impostor to get stiffness from
  48598. * @returns pressure value
  48599. */
  48600. getBodyStiffness(impostor: PhysicsImpostor): number;
  48601. /**
  48602. * Sets stiffness of the impostor
  48603. * @param impostor impostor to set stiffness on
  48604. * @param stiffness stiffness value from 0 to 1
  48605. */
  48606. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48607. /**
  48608. * Gets velocityIterations of the impostor
  48609. * @param impostor impostor to get velocity iterations from
  48610. * @returns velocityIterations value
  48611. */
  48612. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48613. /**
  48614. * Sets velocityIterations of the impostor
  48615. * @param impostor impostor to set velocity iterations on
  48616. * @param velocityIterations velocityIterations value
  48617. */
  48618. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48619. /**
  48620. * Gets positionIterations of the impostor
  48621. * @param impostor impostor to get position iterations from
  48622. * @returns positionIterations value
  48623. */
  48624. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48625. /**
  48626. * Sets positionIterations of the impostor
  48627. * @param impostor impostor to set position on
  48628. * @param positionIterations positionIterations value
  48629. */
  48630. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48631. /**
  48632. * Append an anchor to a cloth object
  48633. * @param impostor is the cloth impostor to add anchor to
  48634. * @param otherImpostor is the rigid impostor to anchor to
  48635. * @param width ratio across width from 0 to 1
  48636. * @param height ratio up height from 0 to 1
  48637. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48638. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48639. */
  48640. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48641. /**
  48642. * Append an hook to a rope object
  48643. * @param impostor is the rope impostor to add hook to
  48644. * @param otherImpostor is the rigid impostor to hook to
  48645. * @param length ratio along the rope from 0 to 1
  48646. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48647. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48648. */
  48649. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48650. /**
  48651. * Sleeps the physics body and stops it from being active
  48652. * @param impostor impostor to sleep
  48653. */
  48654. sleepBody(impostor: PhysicsImpostor): void;
  48655. /**
  48656. * Activates the physics body
  48657. * @param impostor impostor to activate
  48658. */
  48659. wakeUpBody(impostor: PhysicsImpostor): void;
  48660. /**
  48661. * Updates the distance parameters of the joint
  48662. * @param joint joint to update
  48663. * @param maxDistance maximum distance of the joint
  48664. * @param minDistance minimum distance of the joint
  48665. */
  48666. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48667. /**
  48668. * Sets a motor on the joint
  48669. * @param joint joint to set motor on
  48670. * @param speed speed of the motor
  48671. * @param maxForce maximum force of the motor
  48672. * @param motorIndex index of the motor
  48673. */
  48674. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48675. /**
  48676. * Sets the motors limit
  48677. * @param joint joint to set limit on
  48678. * @param upperLimit upper limit
  48679. * @param lowerLimit lower limit
  48680. */
  48681. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48682. /**
  48683. * Syncs the position and rotation of a mesh with the impostor
  48684. * @param mesh mesh to sync
  48685. * @param impostor impostor to update the mesh with
  48686. */
  48687. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48688. /**
  48689. * Gets the radius of the impostor
  48690. * @param impostor impostor to get radius from
  48691. * @returns the radius
  48692. */
  48693. getRadius(impostor: PhysicsImpostor): number;
  48694. /**
  48695. * Gets the box size of the impostor
  48696. * @param impostor impostor to get box size from
  48697. * @param result the resulting box size
  48698. */
  48699. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48700. /**
  48701. * Disposes of the impostor
  48702. */
  48703. dispose(): void;
  48704. /**
  48705. * Does a raycast in the physics world
  48706. * @param from when should the ray start?
  48707. * @param to when should the ray end?
  48708. * @returns PhysicsRaycastResult
  48709. */
  48710. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48711. }
  48712. }
  48713. declare module BABYLON {
  48714. interface AbstractScene {
  48715. /**
  48716. * The list of reflection probes added to the scene
  48717. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48718. */
  48719. reflectionProbes: Array<ReflectionProbe>;
  48720. /**
  48721. * Removes the given reflection probe from this scene.
  48722. * @param toRemove The reflection probe to remove
  48723. * @returns The index of the removed reflection probe
  48724. */
  48725. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48726. /**
  48727. * Adds the given reflection probe to this scene.
  48728. * @param newReflectionProbe The reflection probe to add
  48729. */
  48730. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48731. }
  48732. /**
  48733. * Class used to generate realtime reflection / refraction cube textures
  48734. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48735. */
  48736. export class ReflectionProbe {
  48737. /** defines the name of the probe */
  48738. name: string;
  48739. private _scene;
  48740. private _renderTargetTexture;
  48741. private _projectionMatrix;
  48742. private _viewMatrix;
  48743. private _target;
  48744. private _add;
  48745. private _attachedMesh;
  48746. private _invertYAxis;
  48747. /** Gets or sets probe position (center of the cube map) */
  48748. position: Vector3;
  48749. /**
  48750. * Creates a new reflection probe
  48751. * @param name defines the name of the probe
  48752. * @param size defines the texture resolution (for each face)
  48753. * @param scene defines the hosting scene
  48754. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48755. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48756. */
  48757. constructor(
  48758. /** defines the name of the probe */
  48759. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48760. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48761. samples: number;
  48762. /** Gets or sets the refresh rate to use (on every frame by default) */
  48763. refreshRate: number;
  48764. /**
  48765. * Gets the hosting scene
  48766. * @returns a Scene
  48767. */
  48768. getScene(): Scene;
  48769. /** Gets the internal CubeTexture used to render to */
  48770. readonly cubeTexture: RenderTargetTexture;
  48771. /** Gets the list of meshes to render */
  48772. readonly renderList: Nullable<AbstractMesh[]>;
  48773. /**
  48774. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48775. * @param mesh defines the mesh to attach to
  48776. */
  48777. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48778. /**
  48779. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48780. * @param renderingGroupId The rendering group id corresponding to its index
  48781. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48782. */
  48783. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48784. /**
  48785. * Clean all associated resources
  48786. */
  48787. dispose(): void;
  48788. /**
  48789. * Converts the reflection probe information to a readable string for debug purpose.
  48790. * @param fullDetails Supports for multiple levels of logging within scene loading
  48791. * @returns the human readable reflection probe info
  48792. */
  48793. toString(fullDetails?: boolean): string;
  48794. /**
  48795. * Get the class name of the relfection probe.
  48796. * @returns "ReflectionProbe"
  48797. */
  48798. getClassName(): string;
  48799. /**
  48800. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48801. * @returns The JSON representation of the texture
  48802. */
  48803. serialize(): any;
  48804. /**
  48805. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48806. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48807. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48808. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48809. * @returns The parsed reflection probe if successful
  48810. */
  48811. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48812. }
  48813. }
  48814. declare module BABYLON {
  48815. /** @hidden */
  48816. export var _BabylonLoaderRegistered: boolean;
  48817. }
  48818. declare module BABYLON {
  48819. /**
  48820. * The Physically based simple base material of BJS.
  48821. *
  48822. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48823. * It is used as the base class for both the specGloss and metalRough conventions.
  48824. */
  48825. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48826. /**
  48827. * Number of Simultaneous lights allowed on the material.
  48828. */
  48829. maxSimultaneousLights: number;
  48830. /**
  48831. * If sets to true, disables all the lights affecting the material.
  48832. */
  48833. disableLighting: boolean;
  48834. /**
  48835. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48836. */
  48837. environmentTexture: BaseTexture;
  48838. /**
  48839. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48840. */
  48841. invertNormalMapX: boolean;
  48842. /**
  48843. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48844. */
  48845. invertNormalMapY: boolean;
  48846. /**
  48847. * Normal map used in the model.
  48848. */
  48849. normalTexture: BaseTexture;
  48850. /**
  48851. * Emissivie color used to self-illuminate the model.
  48852. */
  48853. emissiveColor: Color3;
  48854. /**
  48855. * Emissivie texture used to self-illuminate the model.
  48856. */
  48857. emissiveTexture: BaseTexture;
  48858. /**
  48859. * Occlusion Channel Strenght.
  48860. */
  48861. occlusionStrength: number;
  48862. /**
  48863. * Occlusion Texture of the material (adding extra occlusion effects).
  48864. */
  48865. occlusionTexture: BaseTexture;
  48866. /**
  48867. * Defines the alpha limits in alpha test mode.
  48868. */
  48869. alphaCutOff: number;
  48870. /**
  48871. * Gets the current double sided mode.
  48872. */
  48873. /**
  48874. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48875. */
  48876. doubleSided: boolean;
  48877. /**
  48878. * Stores the pre-calculated light information of a mesh in a texture.
  48879. */
  48880. lightmapTexture: BaseTexture;
  48881. /**
  48882. * If true, the light map contains occlusion information instead of lighting info.
  48883. */
  48884. useLightmapAsShadowmap: boolean;
  48885. /**
  48886. * Instantiates a new PBRMaterial instance.
  48887. *
  48888. * @param name The material name
  48889. * @param scene The scene the material will be use in.
  48890. */
  48891. constructor(name: string, scene: Scene);
  48892. getClassName(): string;
  48893. }
  48894. }
  48895. declare module BABYLON {
  48896. /**
  48897. * The PBR material of BJS following the metal roughness convention.
  48898. *
  48899. * This fits to the PBR convention in the GLTF definition:
  48900. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48901. */
  48902. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48903. /**
  48904. * The base color has two different interpretations depending on the value of metalness.
  48905. * When the material is a metal, the base color is the specific measured reflectance value
  48906. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48907. * of the material.
  48908. */
  48909. baseColor: Color3;
  48910. /**
  48911. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48912. * well as opacity information in the alpha channel.
  48913. */
  48914. baseTexture: BaseTexture;
  48915. /**
  48916. * Specifies the metallic scalar value of the material.
  48917. * Can also be used to scale the metalness values of the metallic texture.
  48918. */
  48919. metallic: number;
  48920. /**
  48921. * Specifies the roughness scalar value of the material.
  48922. * Can also be used to scale the roughness values of the metallic texture.
  48923. */
  48924. roughness: number;
  48925. /**
  48926. * Texture containing both the metallic value in the B channel and the
  48927. * roughness value in the G channel to keep better precision.
  48928. */
  48929. metallicRoughnessTexture: BaseTexture;
  48930. /**
  48931. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48932. *
  48933. * @param name The material name
  48934. * @param scene The scene the material will be use in.
  48935. */
  48936. constructor(name: string, scene: Scene);
  48937. /**
  48938. * Return the currrent class name of the material.
  48939. */
  48940. getClassName(): string;
  48941. /**
  48942. * Makes a duplicate of the current material.
  48943. * @param name - name to use for the new material.
  48944. */
  48945. clone(name: string): PBRMetallicRoughnessMaterial;
  48946. /**
  48947. * Serialize the material to a parsable JSON object.
  48948. */
  48949. serialize(): any;
  48950. /**
  48951. * Parses a JSON object correponding to the serialize function.
  48952. */
  48953. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48954. }
  48955. }
  48956. declare module BABYLON {
  48957. /**
  48958. * The PBR material of BJS following the specular glossiness convention.
  48959. *
  48960. * This fits to the PBR convention in the GLTF definition:
  48961. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48962. */
  48963. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48964. /**
  48965. * Specifies the diffuse color of the material.
  48966. */
  48967. diffuseColor: Color3;
  48968. /**
  48969. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48970. * channel.
  48971. */
  48972. diffuseTexture: BaseTexture;
  48973. /**
  48974. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48975. */
  48976. specularColor: Color3;
  48977. /**
  48978. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48979. */
  48980. glossiness: number;
  48981. /**
  48982. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48983. */
  48984. specularGlossinessTexture: BaseTexture;
  48985. /**
  48986. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48987. *
  48988. * @param name The material name
  48989. * @param scene The scene the material will be use in.
  48990. */
  48991. constructor(name: string, scene: Scene);
  48992. /**
  48993. * Return the currrent class name of the material.
  48994. */
  48995. getClassName(): string;
  48996. /**
  48997. * Makes a duplicate of the current material.
  48998. * @param name - name to use for the new material.
  48999. */
  49000. clone(name: string): PBRSpecularGlossinessMaterial;
  49001. /**
  49002. * Serialize the material to a parsable JSON object.
  49003. */
  49004. serialize(): any;
  49005. /**
  49006. * Parses a JSON object correponding to the serialize function.
  49007. */
  49008. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49009. }
  49010. }
  49011. declare module BABYLON {
  49012. /**
  49013. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49014. * It can help converting any input color in a desired output one. This can then be used to create effects
  49015. * from sepia, black and white to sixties or futuristic rendering...
  49016. *
  49017. * The only supported format is currently 3dl.
  49018. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49019. */
  49020. export class ColorGradingTexture extends BaseTexture {
  49021. /**
  49022. * The current texture matrix. (will always be identity in color grading texture)
  49023. */
  49024. private _textureMatrix;
  49025. /**
  49026. * The texture URL.
  49027. */
  49028. url: string;
  49029. /**
  49030. * Empty line regex stored for GC.
  49031. */
  49032. private static _noneEmptyLineRegex;
  49033. private _engine;
  49034. /**
  49035. * Instantiates a ColorGradingTexture from the following parameters.
  49036. *
  49037. * @param url The location of the color gradind data (currently only supporting 3dl)
  49038. * @param scene The scene the texture will be used in
  49039. */
  49040. constructor(url: string, scene: Scene);
  49041. /**
  49042. * Returns the texture matrix used in most of the material.
  49043. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49044. */
  49045. getTextureMatrix(): Matrix;
  49046. /**
  49047. * Occurs when the file being loaded is a .3dl LUT file.
  49048. */
  49049. private load3dlTexture;
  49050. /**
  49051. * Starts the loading process of the texture.
  49052. */
  49053. private loadTexture;
  49054. /**
  49055. * Clones the color gradind texture.
  49056. */
  49057. clone(): ColorGradingTexture;
  49058. /**
  49059. * Called during delayed load for textures.
  49060. */
  49061. delayLoad(): void;
  49062. /**
  49063. * Parses a color grading texture serialized by Babylon.
  49064. * @param parsedTexture The texture information being parsedTexture
  49065. * @param scene The scene to load the texture in
  49066. * @param rootUrl The root url of the data assets to load
  49067. * @return A color gradind texture
  49068. */
  49069. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49070. /**
  49071. * Serializes the LUT texture to json format.
  49072. */
  49073. serialize(): any;
  49074. }
  49075. }
  49076. declare module BABYLON {
  49077. /**
  49078. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49079. */
  49080. export class EquiRectangularCubeTexture extends BaseTexture {
  49081. /** The six faces of the cube. */
  49082. private static _FacesMapping;
  49083. private _noMipmap;
  49084. private _onLoad;
  49085. private _onError;
  49086. /** The size of the cubemap. */
  49087. private _size;
  49088. /** The buffer of the image. */
  49089. private _buffer;
  49090. /** The width of the input image. */
  49091. private _width;
  49092. /** The height of the input image. */
  49093. private _height;
  49094. /** The URL to the image. */
  49095. url: string;
  49096. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49097. coordinatesMode: number;
  49098. /**
  49099. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49100. * @param url The location of the image
  49101. * @param scene The scene the texture will be used in
  49102. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49103. * @param noMipmap Forces to not generate the mipmap if true
  49104. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49105. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49106. * @param onLoad — defines a callback called when texture is loaded
  49107. * @param onError — defines a callback called if there is an error
  49108. */
  49109. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49110. /**
  49111. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49112. */
  49113. private loadImage;
  49114. /**
  49115. * Convert the image buffer into a cubemap and create a CubeTexture.
  49116. */
  49117. private loadTexture;
  49118. /**
  49119. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49120. * @param buffer The ArrayBuffer that should be converted.
  49121. * @returns The buffer as Float32Array.
  49122. */
  49123. private getFloat32ArrayFromArrayBuffer;
  49124. /**
  49125. * Get the current class name of the texture useful for serialization or dynamic coding.
  49126. * @returns "EquiRectangularCubeTexture"
  49127. */
  49128. getClassName(): string;
  49129. /**
  49130. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49131. * @returns A clone of the current EquiRectangularCubeTexture.
  49132. */
  49133. clone(): EquiRectangularCubeTexture;
  49134. }
  49135. }
  49136. declare module BABYLON {
  49137. /**
  49138. * Based on jsTGALoader - Javascript loader for TGA file
  49139. * By Vincent Thibault
  49140. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49141. */
  49142. export class TGATools {
  49143. private static _TYPE_INDEXED;
  49144. private static _TYPE_RGB;
  49145. private static _TYPE_GREY;
  49146. private static _TYPE_RLE_INDEXED;
  49147. private static _TYPE_RLE_RGB;
  49148. private static _TYPE_RLE_GREY;
  49149. private static _ORIGIN_MASK;
  49150. private static _ORIGIN_SHIFT;
  49151. private static _ORIGIN_BL;
  49152. private static _ORIGIN_BR;
  49153. private static _ORIGIN_UL;
  49154. private static _ORIGIN_UR;
  49155. /**
  49156. * Gets the header of a TGA file
  49157. * @param data defines the TGA data
  49158. * @returns the header
  49159. */
  49160. static GetTGAHeader(data: Uint8Array): any;
  49161. /**
  49162. * Uploads TGA content to a Babylon Texture
  49163. * @hidden
  49164. */
  49165. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49166. /** @hidden */
  49167. 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;
  49168. /** @hidden */
  49169. 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;
  49170. /** @hidden */
  49171. 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;
  49172. /** @hidden */
  49173. 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;
  49174. /** @hidden */
  49175. 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;
  49176. /** @hidden */
  49177. 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;
  49178. }
  49179. }
  49180. declare module BABYLON {
  49181. /**
  49182. * Implementation of the TGA Texture Loader.
  49183. * @hidden
  49184. */
  49185. export class _TGATextureLoader implements IInternalTextureLoader {
  49186. /**
  49187. * Defines wether the loader supports cascade loading the different faces.
  49188. */
  49189. readonly supportCascades: boolean;
  49190. /**
  49191. * This returns if the loader support the current file information.
  49192. * @param extension defines the file extension of the file being loaded
  49193. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49194. * @param fallback defines the fallback internal texture if any
  49195. * @param isBase64 defines whether the texture is encoded as a base64
  49196. * @param isBuffer defines whether the texture data are stored as a buffer
  49197. * @returns true if the loader can load the specified file
  49198. */
  49199. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49200. /**
  49201. * Transform the url before loading if required.
  49202. * @param rootUrl the url of the texture
  49203. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49204. * @returns the transformed texture
  49205. */
  49206. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49207. /**
  49208. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49209. * @param rootUrl the url of the texture
  49210. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49211. * @returns the fallback texture
  49212. */
  49213. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49214. /**
  49215. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49216. * @param data contains the texture data
  49217. * @param texture defines the BabylonJS internal texture
  49218. * @param createPolynomials will be true if polynomials have been requested
  49219. * @param onLoad defines the callback to trigger once the texture is ready
  49220. * @param onError defines the callback to trigger in case of error
  49221. */
  49222. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49223. /**
  49224. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49225. * @param data contains the texture data
  49226. * @param texture defines the BabylonJS internal texture
  49227. * @param callback defines the method to call once ready to upload
  49228. */
  49229. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49230. }
  49231. }
  49232. declare module BABYLON {
  49233. /**
  49234. * 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.
  49235. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49236. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49237. */
  49238. export class CustomProceduralTexture extends ProceduralTexture {
  49239. private _animate;
  49240. private _time;
  49241. private _config;
  49242. private _texturePath;
  49243. /**
  49244. * Instantiates a new Custom Procedural Texture.
  49245. * 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.
  49246. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49247. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49248. * @param name Define the name of the texture
  49249. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49250. * @param size Define the size of the texture to create
  49251. * @param scene Define the scene the texture belongs to
  49252. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49253. * @param generateMipMaps Define if the texture should creates mip maps or not
  49254. */
  49255. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49256. private _loadJson;
  49257. /**
  49258. * Is the texture ready to be used ? (rendered at least once)
  49259. * @returns true if ready, otherwise, false.
  49260. */
  49261. isReady(): boolean;
  49262. /**
  49263. * Render the texture to its associated render target.
  49264. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49265. */
  49266. render(useCameraPostProcess?: boolean): void;
  49267. /**
  49268. * Update the list of dependant textures samplers in the shader.
  49269. */
  49270. updateTextures(): void;
  49271. /**
  49272. * Update the uniform values of the procedural texture in the shader.
  49273. */
  49274. updateShaderUniforms(): void;
  49275. /**
  49276. * Define if the texture animates or not.
  49277. */
  49278. animate: boolean;
  49279. }
  49280. }
  49281. declare module BABYLON {
  49282. /** @hidden */
  49283. export var noisePixelShader: {
  49284. name: string;
  49285. shader: string;
  49286. };
  49287. }
  49288. declare module BABYLON {
  49289. /**
  49290. * Class used to generate noise procedural textures
  49291. */
  49292. export class NoiseProceduralTexture extends ProceduralTexture {
  49293. private _time;
  49294. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49295. brightness: number;
  49296. /** Defines the number of octaves to process */
  49297. octaves: number;
  49298. /** Defines the level of persistence (0.8 by default) */
  49299. persistence: number;
  49300. /** Gets or sets animation speed factor (default is 1) */
  49301. animationSpeedFactor: number;
  49302. /**
  49303. * Creates a new NoiseProceduralTexture
  49304. * @param name defines the name fo the texture
  49305. * @param size defines the size of the texture (default is 256)
  49306. * @param scene defines the hosting scene
  49307. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49308. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49309. */
  49310. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49311. private _updateShaderUniforms;
  49312. protected _getDefines(): string;
  49313. /** Generate the current state of the procedural texture */
  49314. render(useCameraPostProcess?: boolean): void;
  49315. /**
  49316. * Serializes this noise procedural texture
  49317. * @returns a serialized noise procedural texture object
  49318. */
  49319. serialize(): any;
  49320. /**
  49321. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49322. * @param parsedTexture defines parsed texture data
  49323. * @param scene defines the current scene
  49324. * @param rootUrl defines the root URL containing noise procedural texture information
  49325. * @returns a parsed NoiseProceduralTexture
  49326. */
  49327. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49328. }
  49329. }
  49330. declare module BABYLON {
  49331. /**
  49332. * Raw cube texture where the raw buffers are passed in
  49333. */
  49334. export class RawCubeTexture extends CubeTexture {
  49335. /**
  49336. * Creates a cube texture where the raw buffers are passed in.
  49337. * @param scene defines the scene the texture is attached to
  49338. * @param data defines the array of data to use to create each face
  49339. * @param size defines the size of the textures
  49340. * @param format defines the format of the data
  49341. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49342. * @param generateMipMaps defines if the engine should generate the mip levels
  49343. * @param invertY defines if data must be stored with Y axis inverted
  49344. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49345. * @param compression defines the compression used (null by default)
  49346. */
  49347. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49348. /**
  49349. * Updates the raw cube texture.
  49350. * @param data defines the data to store
  49351. * @param format defines the data format
  49352. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49353. * @param invertY defines if data must be stored with Y axis inverted
  49354. * @param compression defines the compression used (null by default)
  49355. * @param level defines which level of the texture to update
  49356. */
  49357. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49358. /**
  49359. * Updates a raw cube texture with RGBD encoded data.
  49360. * @param data defines the array of data [mipmap][face] to use to create each face
  49361. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49362. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49363. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49364. * @returns a promsie that resolves when the operation is complete
  49365. */
  49366. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49367. /**
  49368. * Clones the raw cube texture.
  49369. * @return a new cube texture
  49370. */
  49371. clone(): CubeTexture;
  49372. /** @hidden */
  49373. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49374. }
  49375. }
  49376. declare module BABYLON {
  49377. /**
  49378. * Class used to store 3D textures containing user data
  49379. */
  49380. export class RawTexture3D extends Texture {
  49381. /** Gets or sets the texture format to use */
  49382. format: number;
  49383. private _engine;
  49384. /**
  49385. * Create a new RawTexture3D
  49386. * @param data defines the data of the texture
  49387. * @param width defines the width of the texture
  49388. * @param height defines the height of the texture
  49389. * @param depth defines the depth of the texture
  49390. * @param format defines the texture format to use
  49391. * @param scene defines the hosting scene
  49392. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49393. * @param invertY defines if texture must be stored with Y axis inverted
  49394. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49395. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49396. */
  49397. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49398. /** Gets or sets the texture format to use */
  49399. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49400. /**
  49401. * Update the texture with new data
  49402. * @param data defines the data to store in the texture
  49403. */
  49404. update(data: ArrayBufferView): void;
  49405. }
  49406. }
  49407. declare module BABYLON {
  49408. /**
  49409. * Creates a refraction texture used by refraction channel of the standard material.
  49410. * It is like a mirror but to see through a material.
  49411. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49412. */
  49413. export class RefractionTexture extends RenderTargetTexture {
  49414. /**
  49415. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49416. * It is possible to directly set the refractionPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  49417. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49418. */
  49419. refractionPlane: Plane;
  49420. /**
  49421. * Define how deep under the surface we should see.
  49422. */
  49423. depth: number;
  49424. /**
  49425. * Creates a refraction texture used by refraction channel of the standard material.
  49426. * It is like a mirror but to see through a material.
  49427. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49428. * @param name Define the texture name
  49429. * @param size Define the size of the underlying texture
  49430. * @param scene Define the scene the refraction belongs to
  49431. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49432. */
  49433. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49434. /**
  49435. * Clone the refraction texture.
  49436. * @returns the cloned texture
  49437. */
  49438. clone(): RefractionTexture;
  49439. /**
  49440. * Serialize the texture to a JSON representation you could use in Parse later on
  49441. * @returns the serialized JSON representation
  49442. */
  49443. serialize(): any;
  49444. }
  49445. }
  49446. declare module BABYLON {
  49447. /**
  49448. * Defines the options related to the creation of an HtmlElementTexture
  49449. */
  49450. export interface IHtmlElementTextureOptions {
  49451. /**
  49452. * Defines wether mip maps should be created or not.
  49453. */
  49454. generateMipMaps?: boolean;
  49455. /**
  49456. * Defines the sampling mode of the texture.
  49457. */
  49458. samplingMode?: number;
  49459. /**
  49460. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  49461. */
  49462. engine: Nullable<Engine>;
  49463. /**
  49464. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  49465. */
  49466. scene: Nullable<Scene>;
  49467. }
  49468. /**
  49469. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  49470. * To be as efficient as possible depending on your constraints nothing aside the first upload
  49471. * is automatically managed.
  49472. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  49473. * in your application.
  49474. *
  49475. * As the update is not automatic, you need to call them manually.
  49476. */
  49477. export class HtmlElementTexture extends BaseTexture {
  49478. /**
  49479. * The texture URL.
  49480. */
  49481. element: HTMLVideoElement | HTMLCanvasElement;
  49482. private static readonly DefaultOptions;
  49483. private _textureMatrix;
  49484. private _engine;
  49485. private _isVideo;
  49486. private _generateMipMaps;
  49487. private _samplingMode;
  49488. /**
  49489. * Instantiates a HtmlElementTexture from the following parameters.
  49490. *
  49491. * @param name Defines the name of the texture
  49492. * @param element Defines the video or canvas the texture is filled with
  49493. * @param options Defines the other none mandatory texture creation options
  49494. */
  49495. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  49496. private _createInternalTexture;
  49497. /**
  49498. * Returns the texture matrix used in most of the material.
  49499. */
  49500. getTextureMatrix(): Matrix;
  49501. /**
  49502. * Updates the content of the texture.
  49503. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  49504. */
  49505. update(invertY?: Nullable<boolean>): void;
  49506. }
  49507. }
  49508. declare module BABYLON {
  49509. /**
  49510. * Helper class to push actions to a pool of workers.
  49511. */
  49512. export class WorkerPool implements IDisposable {
  49513. private _workerInfos;
  49514. private _pendingActions;
  49515. /**
  49516. * Constructor
  49517. * @param workers Array of workers to use for actions
  49518. */
  49519. constructor(workers: Array<Worker>);
  49520. /**
  49521. * Terminates all workers and clears any pending actions.
  49522. */
  49523. dispose(): void;
  49524. /**
  49525. * Pushes an action to the worker pool. If all the workers are active, the action will be
  49526. * pended until a worker has completed its action.
  49527. * @param action The action to perform. Call onComplete when the action is complete.
  49528. */
  49529. push(action: (worker: Worker, onComplete: () => void) => void): void;
  49530. private _execute;
  49531. }
  49532. }
  49533. declare module BABYLON {
  49534. /**
  49535. * Configuration for Draco compression
  49536. */
  49537. export interface IDracoCompressionConfiguration {
  49538. /**
  49539. * Configuration for the decoder.
  49540. */
  49541. decoder?: {
  49542. /**
  49543. * The url to the WebAssembly module.
  49544. */
  49545. wasmUrl?: string;
  49546. /**
  49547. * The url to the WebAssembly binary.
  49548. */
  49549. wasmBinaryUrl?: string;
  49550. /**
  49551. * The url to the fallback JavaScript module.
  49552. */
  49553. fallbackUrl?: string;
  49554. };
  49555. }
  49556. /**
  49557. * Draco compression (https://google.github.io/draco/)
  49558. *
  49559. * This class wraps the Draco module.
  49560. *
  49561. * **Encoder**
  49562. *
  49563. * The encoder is not currently implemented.
  49564. *
  49565. * **Decoder**
  49566. *
  49567. * 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.
  49568. *
  49569. * To update the configuration, use the following code:
  49570. * ```javascript
  49571. * DracoCompression.Configuration = {
  49572. * decoder: {
  49573. * wasmUrl: "<url to the WebAssembly library>",
  49574. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49575. * fallbackUrl: "<url to the fallback JavaScript library>",
  49576. * }
  49577. * };
  49578. * ```
  49579. *
  49580. * 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.
  49581. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49582. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49583. *
  49584. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49585. * ```javascript
  49586. * var dracoCompression = new DracoCompression();
  49587. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49588. * [VertexBuffer.PositionKind]: 0
  49589. * });
  49590. * ```
  49591. *
  49592. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49593. */
  49594. export class DracoCompression implements IDisposable {
  49595. private _workerPoolPromise;
  49596. /**
  49597. * The configuration. Defaults to the following urls:
  49598. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49599. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49600. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49601. */
  49602. static Configuration: IDracoCompressionConfiguration;
  49603. /**
  49604. * Returns true if the decoder is available.
  49605. */
  49606. static readonly DecoderAvailable: boolean;
  49607. /**
  49608. * Default number of workers to create when creating the draco compression object.
  49609. */
  49610. static DefaultNumWorkers: number;
  49611. private static GetDefaultNumWorkers;
  49612. /**
  49613. * Constructor
  49614. * @param numWorkers The number of workers for async operations
  49615. */
  49616. constructor(numWorkers?: number);
  49617. /**
  49618. * Stop all async operations and release resources.
  49619. */
  49620. dispose(): void;
  49621. /**
  49622. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  49623. * @returns a promise that resolves when ready
  49624. */
  49625. whenReadyAsync(): Promise<void>;
  49626. /**
  49627. * Decode Draco compressed mesh data to vertex data.
  49628. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49629. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49630. * @returns A promise that resolves with the decoded vertex data
  49631. */
  49632. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  49633. [kind: string]: number;
  49634. }): Promise<VertexData>;
  49635. /**
  49636. * The worker function that gets converted to a blob url to pass into a worker.
  49637. */
  49638. private static _Worker;
  49639. private _loadDecoderWasmBinaryAsync;
  49640. }
  49641. }
  49642. declare module BABYLON {
  49643. /**
  49644. * Class for building Constructive Solid Geometry
  49645. */
  49646. export class CSG {
  49647. private polygons;
  49648. /**
  49649. * The world matrix
  49650. */
  49651. matrix: Matrix;
  49652. /**
  49653. * Stores the position
  49654. */
  49655. position: Vector3;
  49656. /**
  49657. * Stores the rotation
  49658. */
  49659. rotation: Vector3;
  49660. /**
  49661. * Stores the rotation quaternion
  49662. */
  49663. rotationQuaternion: Nullable<Quaternion>;
  49664. /**
  49665. * Stores the scaling vector
  49666. */
  49667. scaling: Vector3;
  49668. /**
  49669. * Convert the Mesh to CSG
  49670. * @param mesh The Mesh to convert to CSG
  49671. * @returns A new CSG from the Mesh
  49672. */
  49673. static FromMesh(mesh: Mesh): CSG;
  49674. /**
  49675. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49676. * @param polygons Polygons used to construct a CSG solid
  49677. */
  49678. private static FromPolygons;
  49679. /**
  49680. * Clones, or makes a deep copy, of the CSG
  49681. * @returns A new CSG
  49682. */
  49683. clone(): CSG;
  49684. /**
  49685. * Unions this CSG with another CSG
  49686. * @param csg The CSG to union against this CSG
  49687. * @returns The unioned CSG
  49688. */
  49689. union(csg: CSG): CSG;
  49690. /**
  49691. * Unions this CSG with another CSG in place
  49692. * @param csg The CSG to union against this CSG
  49693. */
  49694. unionInPlace(csg: CSG): void;
  49695. /**
  49696. * Subtracts this CSG with another CSG
  49697. * @param csg The CSG to subtract against this CSG
  49698. * @returns A new CSG
  49699. */
  49700. subtract(csg: CSG): CSG;
  49701. /**
  49702. * Subtracts this CSG with another CSG in place
  49703. * @param csg The CSG to subtact against this CSG
  49704. */
  49705. subtractInPlace(csg: CSG): void;
  49706. /**
  49707. * Intersect this CSG with another CSG
  49708. * @param csg The CSG to intersect against this CSG
  49709. * @returns A new CSG
  49710. */
  49711. intersect(csg: CSG): CSG;
  49712. /**
  49713. * Intersects this CSG with another CSG in place
  49714. * @param csg The CSG to intersect against this CSG
  49715. */
  49716. intersectInPlace(csg: CSG): void;
  49717. /**
  49718. * Return a new CSG solid with solid and empty space switched. This solid is
  49719. * not modified.
  49720. * @returns A new CSG solid with solid and empty space switched
  49721. */
  49722. inverse(): CSG;
  49723. /**
  49724. * Inverses the CSG in place
  49725. */
  49726. inverseInPlace(): void;
  49727. /**
  49728. * This is used to keep meshes transformations so they can be restored
  49729. * when we build back a Babylon Mesh
  49730. * NB : All CSG operations are performed in world coordinates
  49731. * @param csg The CSG to copy the transform attributes from
  49732. * @returns This CSG
  49733. */
  49734. copyTransformAttributes(csg: CSG): CSG;
  49735. /**
  49736. * Build Raw mesh from CSG
  49737. * Coordinates here are in world space
  49738. * @param name The name of the mesh geometry
  49739. * @param scene The Scene
  49740. * @param keepSubMeshes Specifies if the submeshes should be kept
  49741. * @returns A new Mesh
  49742. */
  49743. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49744. /**
  49745. * Build Mesh from CSG taking material and transforms into account
  49746. * @param name The name of the Mesh
  49747. * @param material The material of the Mesh
  49748. * @param scene The Scene
  49749. * @param keepSubMeshes Specifies if submeshes should be kept
  49750. * @returns The new Mesh
  49751. */
  49752. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49753. }
  49754. }
  49755. declare module BABYLON {
  49756. /**
  49757. * Class used to create a trail following a mesh
  49758. */
  49759. export class TrailMesh extends Mesh {
  49760. private _generator;
  49761. private _autoStart;
  49762. private _running;
  49763. private _diameter;
  49764. private _length;
  49765. private _sectionPolygonPointsCount;
  49766. private _sectionVectors;
  49767. private _sectionNormalVectors;
  49768. private _beforeRenderObserver;
  49769. /**
  49770. * @constructor
  49771. * @param name The value used by scene.getMeshByName() to do a lookup.
  49772. * @param generator The mesh to generate a trail.
  49773. * @param scene The scene to add this mesh to.
  49774. * @param diameter Diameter of trailing mesh. Default is 1.
  49775. * @param length Length of trailing mesh. Default is 60.
  49776. * @param autoStart Automatically start trailing mesh. Default true.
  49777. */
  49778. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49779. /**
  49780. * "TrailMesh"
  49781. * @returns "TrailMesh"
  49782. */
  49783. getClassName(): string;
  49784. private _createMesh;
  49785. /**
  49786. * Start trailing mesh.
  49787. */
  49788. start(): void;
  49789. /**
  49790. * Stop trailing mesh.
  49791. */
  49792. stop(): void;
  49793. /**
  49794. * Update trailing mesh geometry.
  49795. */
  49796. update(): void;
  49797. /**
  49798. * Returns a new TrailMesh object.
  49799. * @param name is a string, the name given to the new mesh
  49800. * @param newGenerator use new generator object for cloned trail mesh
  49801. * @returns a new mesh
  49802. */
  49803. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49804. /**
  49805. * Serializes this trail mesh
  49806. * @param serializationObject object to write serialization to
  49807. */
  49808. serialize(serializationObject: any): void;
  49809. /**
  49810. * Parses a serialized trail mesh
  49811. * @param parsedMesh the serialized mesh
  49812. * @param scene the scene to create the trail mesh in
  49813. * @returns the created trail mesh
  49814. */
  49815. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49816. }
  49817. }
  49818. declare module BABYLON {
  49819. /**
  49820. * Class containing static functions to help procedurally build meshes
  49821. */
  49822. export class TorusKnotBuilder {
  49823. /**
  49824. * Creates a torus knot mesh
  49825. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49826. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49827. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49828. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49832. * @param name defines the name of the mesh
  49833. * @param options defines the options used to create the mesh
  49834. * @param scene defines the hosting scene
  49835. * @returns the torus knot mesh
  49836. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49837. */
  49838. static CreateTorusKnot(name: string, options: {
  49839. radius?: number;
  49840. tube?: number;
  49841. radialSegments?: number;
  49842. tubularSegments?: number;
  49843. p?: number;
  49844. q?: number;
  49845. updatable?: boolean;
  49846. sideOrientation?: number;
  49847. frontUVs?: Vector4;
  49848. backUVs?: Vector4;
  49849. }, scene: any): Mesh;
  49850. }
  49851. }
  49852. declare module BABYLON {
  49853. /**
  49854. * Polygon
  49855. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49856. */
  49857. export class Polygon {
  49858. /**
  49859. * Creates a rectangle
  49860. * @param xmin bottom X coord
  49861. * @param ymin bottom Y coord
  49862. * @param xmax top X coord
  49863. * @param ymax top Y coord
  49864. * @returns points that make the resulting rectation
  49865. */
  49866. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49867. /**
  49868. * Creates a circle
  49869. * @param radius radius of circle
  49870. * @param cx scale in x
  49871. * @param cy scale in y
  49872. * @param numberOfSides number of sides that make up the circle
  49873. * @returns points that make the resulting circle
  49874. */
  49875. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49876. /**
  49877. * Creates a polygon from input string
  49878. * @param input Input polygon data
  49879. * @returns the parsed points
  49880. */
  49881. static Parse(input: string): Vector2[];
  49882. /**
  49883. * Starts building a polygon from x and y coordinates
  49884. * @param x x coordinate
  49885. * @param y y coordinate
  49886. * @returns the started path2
  49887. */
  49888. static StartingAt(x: number, y: number): Path2;
  49889. }
  49890. /**
  49891. * Builds a polygon
  49892. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49893. */
  49894. export class PolygonMeshBuilder {
  49895. private _points;
  49896. private _outlinepoints;
  49897. private _holes;
  49898. private _name;
  49899. private _scene;
  49900. private _epoints;
  49901. private _eholes;
  49902. private _addToepoint;
  49903. /**
  49904. * Babylon reference to the earcut plugin.
  49905. */
  49906. bjsEarcut: any;
  49907. /**
  49908. * Creates a PolygonMeshBuilder
  49909. * @param name name of the builder
  49910. * @param contours Path of the polygon
  49911. * @param scene scene to add to when creating the mesh
  49912. * @param earcutInjection can be used to inject your own earcut reference
  49913. */
  49914. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  49915. /**
  49916. * Adds a whole within the polygon
  49917. * @param hole Array of points defining the hole
  49918. * @returns this
  49919. */
  49920. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49921. /**
  49922. * Creates the polygon
  49923. * @param updatable If the mesh should be updatable
  49924. * @param depth The depth of the mesh created
  49925. * @returns the created mesh
  49926. */
  49927. build(updatable?: boolean, depth?: number): Mesh;
  49928. /**
  49929. * Creates the polygon
  49930. * @param depth The depth of the mesh created
  49931. * @returns the created VertexData
  49932. */
  49933. buildVertexData(depth?: number): VertexData;
  49934. /**
  49935. * Adds a side to the polygon
  49936. * @param positions points that make the polygon
  49937. * @param normals normals of the polygon
  49938. * @param uvs uvs of the polygon
  49939. * @param indices indices of the polygon
  49940. * @param bounds bounds of the polygon
  49941. * @param points points of the polygon
  49942. * @param depth depth of the polygon
  49943. * @param flip flip of the polygon
  49944. */
  49945. private addSide;
  49946. }
  49947. }
  49948. declare module BABYLON {
  49949. /**
  49950. * Class containing static functions to help procedurally build meshes
  49951. */
  49952. export class PolygonBuilder {
  49953. /**
  49954. * Creates a polygon mesh
  49955. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49956. * * 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
  49957. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49959. * * 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)
  49960. * * Remember you can only change the shape positions, not their number when updating a polygon
  49961. * @param name defines the name of the mesh
  49962. * @param options defines the options used to create the mesh
  49963. * @param scene defines the hosting scene
  49964. * @param earcutInjection can be used to inject your own earcut reference
  49965. * @returns the polygon mesh
  49966. */
  49967. static CreatePolygon(name: string, options: {
  49968. shape: Vector3[];
  49969. holes?: Vector3[][];
  49970. depth?: number;
  49971. faceUV?: Vector4[];
  49972. faceColors?: Color4[];
  49973. updatable?: boolean;
  49974. sideOrientation?: number;
  49975. frontUVs?: Vector4;
  49976. backUVs?: Vector4;
  49977. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49978. /**
  49979. * Creates an extruded polygon mesh, with depth in the Y direction.
  49980. * * 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)
  49981. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49982. * @param name defines the name of the mesh
  49983. * @param options defines the options used to create the mesh
  49984. * @param scene defines the hosting scene
  49985. * @param earcutInjection can be used to inject your own earcut reference
  49986. * @returns the polygon mesh
  49987. */
  49988. static ExtrudePolygon(name: string, options: {
  49989. shape: Vector3[];
  49990. holes?: Vector3[][];
  49991. depth?: number;
  49992. faceUV?: Vector4[];
  49993. faceColors?: Color4[];
  49994. updatable?: boolean;
  49995. sideOrientation?: number;
  49996. frontUVs?: Vector4;
  49997. backUVs?: Vector4;
  49998. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49999. }
  50000. }
  50001. declare module BABYLON {
  50002. /**
  50003. * Class containing static functions to help procedurally build meshes
  50004. */
  50005. export class LatheBuilder {
  50006. /**
  50007. * Creates lathe mesh.
  50008. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50009. * * 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
  50010. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50011. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50012. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50013. * * 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
  50014. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50015. * * 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
  50016. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50017. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50018. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50020. * @param name defines the name of the mesh
  50021. * @param options defines the options used to create the mesh
  50022. * @param scene defines the hosting scene
  50023. * @returns the lathe mesh
  50024. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50025. */
  50026. static CreateLathe(name: string, options: {
  50027. shape: Vector3[];
  50028. radius?: number;
  50029. tessellation?: number;
  50030. clip?: number;
  50031. arc?: number;
  50032. closed?: boolean;
  50033. updatable?: boolean;
  50034. sideOrientation?: number;
  50035. frontUVs?: Vector4;
  50036. backUVs?: Vector4;
  50037. cap?: number;
  50038. invertUV?: boolean;
  50039. }, scene?: Nullable<Scene>): Mesh;
  50040. }
  50041. }
  50042. declare module BABYLON {
  50043. /**
  50044. * Class containing static functions to help procedurally build meshes
  50045. */
  50046. export class TubeBuilder {
  50047. /**
  50048. * Creates a tube mesh.
  50049. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50050. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50051. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50052. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50053. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50054. * * 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)
  50055. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50056. * * 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
  50057. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  50058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50059. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50060. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50062. * @param name defines the name of the mesh
  50063. * @param options defines the options used to create the mesh
  50064. * @param scene defines the hosting scene
  50065. * @returns the tube mesh
  50066. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50067. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50068. */
  50069. static CreateTube(name: string, options: {
  50070. path: Vector3[];
  50071. radius?: number;
  50072. tessellation?: number;
  50073. radiusFunction?: {
  50074. (i: number, distance: number): number;
  50075. };
  50076. cap?: number;
  50077. arc?: number;
  50078. updatable?: boolean;
  50079. sideOrientation?: number;
  50080. frontUVs?: Vector4;
  50081. backUVs?: Vector4;
  50082. instance?: Mesh;
  50083. invertUV?: boolean;
  50084. }, scene?: Nullable<Scene>): Mesh;
  50085. }
  50086. }
  50087. declare module BABYLON {
  50088. /**
  50089. * Class containing static functions to help procedurally build meshes
  50090. */
  50091. export class IcoSphereBuilder {
  50092. /**
  50093. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50094. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50095. * * 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`)
  50096. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50097. * * 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
  50098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50099. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50101. * @param name defines the name of the mesh
  50102. * @param options defines the options used to create the mesh
  50103. * @param scene defines the hosting scene
  50104. * @returns the icosahedron mesh
  50105. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50106. */
  50107. static CreateIcoSphere(name: string, options: {
  50108. radius?: number;
  50109. radiusX?: number;
  50110. radiusY?: number;
  50111. radiusZ?: number;
  50112. flat?: boolean;
  50113. subdivisions?: number;
  50114. sideOrientation?: number;
  50115. frontUVs?: Vector4;
  50116. backUVs?: Vector4;
  50117. updatable?: boolean;
  50118. }, scene?: Nullable<Scene>): Mesh;
  50119. }
  50120. }
  50121. declare module BABYLON {
  50122. /**
  50123. * Class containing static functions to help procedurally build meshes
  50124. */
  50125. export class DecalBuilder {
  50126. /**
  50127. * Creates a decal mesh.
  50128. * 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
  50129. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50130. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50131. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50132. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50133. * @param name defines the name of the mesh
  50134. * @param sourceMesh defines the mesh where the decal must be applied
  50135. * @param options defines the options used to create the mesh
  50136. * @param scene defines the hosting scene
  50137. * @returns the decal mesh
  50138. * @see https://doc.babylonjs.com/how_to/decals
  50139. */
  50140. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50141. position?: Vector3;
  50142. normal?: Vector3;
  50143. size?: Vector3;
  50144. angle?: number;
  50145. }): Mesh;
  50146. }
  50147. }
  50148. declare module BABYLON {
  50149. /**
  50150. * Class containing static functions to help procedurally build meshes
  50151. */
  50152. export class MeshBuilder {
  50153. /**
  50154. * Creates a box mesh
  50155. * * The parameter `size` sets the size (float) of each box side (default 1)
  50156. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50157. * * 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)
  50158. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50160. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50162. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50163. * @param name defines the name of the mesh
  50164. * @param options defines the options used to create the mesh
  50165. * @param scene defines the hosting scene
  50166. * @returns the box mesh
  50167. */
  50168. static CreateBox(name: string, options: {
  50169. size?: number;
  50170. width?: number;
  50171. height?: number;
  50172. depth?: number;
  50173. faceUV?: Vector4[];
  50174. faceColors?: Color4[];
  50175. sideOrientation?: number;
  50176. frontUVs?: Vector4;
  50177. backUVs?: Vector4;
  50178. updatable?: boolean;
  50179. }, scene?: Nullable<Scene>): Mesh;
  50180. /**
  50181. * Creates a sphere mesh
  50182. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50183. * * 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`)
  50184. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50185. * * 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
  50186. * * 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)
  50187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50190. * @param name defines the name of the mesh
  50191. * @param options defines the options used to create the mesh
  50192. * @param scene defines the hosting scene
  50193. * @returns the sphere mesh
  50194. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50195. */
  50196. static CreateSphere(name: string, options: {
  50197. segments?: number;
  50198. diameter?: number;
  50199. diameterX?: number;
  50200. diameterY?: number;
  50201. diameterZ?: number;
  50202. arc?: number;
  50203. slice?: number;
  50204. sideOrientation?: number;
  50205. frontUVs?: Vector4;
  50206. backUVs?: Vector4;
  50207. updatable?: boolean;
  50208. }, scene?: Nullable<Scene>): Mesh;
  50209. /**
  50210. * Creates a plane polygonal mesh. By default, this is a disc
  50211. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50212. * * 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
  50213. * * 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
  50214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50217. * @param name defines the name of the mesh
  50218. * @param options defines the options used to create the mesh
  50219. * @param scene defines the hosting scene
  50220. * @returns the plane polygonal mesh
  50221. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50222. */
  50223. static CreateDisc(name: string, options: {
  50224. radius?: number;
  50225. tessellation?: number;
  50226. arc?: number;
  50227. updatable?: boolean;
  50228. sideOrientation?: number;
  50229. frontUVs?: Vector4;
  50230. backUVs?: Vector4;
  50231. }, scene?: Nullable<Scene>): Mesh;
  50232. /**
  50233. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50234. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50235. * * 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`)
  50236. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50237. * * 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
  50238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50239. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50241. * @param name defines the name of the mesh
  50242. * @param options defines the options used to create the mesh
  50243. * @param scene defines the hosting scene
  50244. * @returns the icosahedron mesh
  50245. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50246. */
  50247. static CreateIcoSphere(name: string, options: {
  50248. radius?: number;
  50249. radiusX?: number;
  50250. radiusY?: number;
  50251. radiusZ?: number;
  50252. flat?: boolean;
  50253. subdivisions?: number;
  50254. sideOrientation?: number;
  50255. frontUVs?: Vector4;
  50256. backUVs?: Vector4;
  50257. updatable?: boolean;
  50258. }, scene?: Nullable<Scene>): Mesh;
  50259. /**
  50260. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50261. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50262. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50263. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50264. * * 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
  50265. * * 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
  50266. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  50267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50268. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50269. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50270. * * 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
  50271. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50272. * * 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
  50273. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50275. * @param name defines the name of the mesh
  50276. * @param options defines the options used to create the mesh
  50277. * @param scene defines the hosting scene
  50278. * @returns the ribbon mesh
  50279. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50280. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50281. */
  50282. static CreateRibbon(name: string, options: {
  50283. pathArray: Vector3[][];
  50284. closeArray?: boolean;
  50285. closePath?: boolean;
  50286. offset?: number;
  50287. updatable?: boolean;
  50288. sideOrientation?: number;
  50289. frontUVs?: Vector4;
  50290. backUVs?: Vector4;
  50291. instance?: Mesh;
  50292. invertUV?: boolean;
  50293. uvs?: Vector2[];
  50294. colors?: Color4[];
  50295. }, scene?: Nullable<Scene>): Mesh;
  50296. /**
  50297. * Creates a cylinder or a cone mesh
  50298. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50299. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50300. * * 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.
  50301. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50302. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50303. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50304. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50305. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50306. * * 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).
  50307. * * 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
  50308. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50309. * * 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
  50310. * * 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.
  50311. * * If `enclose` is false, a ring surface is one element.
  50312. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50313. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  50314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50317. * @param name defines the name of the mesh
  50318. * @param options defines the options used to create the mesh
  50319. * @param scene defines the hosting scene
  50320. * @returns the cylinder mesh
  50321. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50322. */
  50323. static CreateCylinder(name: string, options: {
  50324. height?: number;
  50325. diameterTop?: number;
  50326. diameterBottom?: number;
  50327. diameter?: number;
  50328. tessellation?: number;
  50329. subdivisions?: number;
  50330. arc?: number;
  50331. faceColors?: Color4[];
  50332. faceUV?: Vector4[];
  50333. updatable?: boolean;
  50334. hasRings?: boolean;
  50335. enclose?: boolean;
  50336. sideOrientation?: number;
  50337. frontUVs?: Vector4;
  50338. backUVs?: Vector4;
  50339. }, scene?: Nullable<Scene>): Mesh;
  50340. /**
  50341. * Creates a torus mesh
  50342. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50343. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50344. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50346. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50348. * @param name defines the name of the mesh
  50349. * @param options defines the options used to create the mesh
  50350. * @param scene defines the hosting scene
  50351. * @returns the torus mesh
  50352. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50353. */
  50354. static CreateTorus(name: string, options: {
  50355. diameter?: number;
  50356. thickness?: number;
  50357. tessellation?: number;
  50358. updatable?: boolean;
  50359. sideOrientation?: number;
  50360. frontUVs?: Vector4;
  50361. backUVs?: Vector4;
  50362. }, scene?: Nullable<Scene>): Mesh;
  50363. /**
  50364. * Creates a torus knot mesh
  50365. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50366. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50367. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50368. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50370. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50372. * @param name defines the name of the mesh
  50373. * @param options defines the options used to create the mesh
  50374. * @param scene defines the hosting scene
  50375. * @returns the torus knot mesh
  50376. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50377. */
  50378. static CreateTorusKnot(name: string, options: {
  50379. radius?: number;
  50380. tube?: number;
  50381. radialSegments?: number;
  50382. tubularSegments?: number;
  50383. p?: number;
  50384. q?: number;
  50385. updatable?: boolean;
  50386. sideOrientation?: number;
  50387. frontUVs?: Vector4;
  50388. backUVs?: Vector4;
  50389. }, scene?: Nullable<Scene>): Mesh;
  50390. /**
  50391. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50392. * * 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
  50393. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50394. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50395. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50396. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50397. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50398. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  50399. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50401. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50402. * @param name defines the name of the new line system
  50403. * @param options defines the options used to create the line system
  50404. * @param scene defines the hosting scene
  50405. * @returns a new line system mesh
  50406. */
  50407. static CreateLineSystem(name: string, options: {
  50408. lines: Vector3[][];
  50409. updatable?: boolean;
  50410. instance?: Nullable<LinesMesh>;
  50411. colors?: Nullable<Color4[][]>;
  50412. useVertexAlpha?: boolean;
  50413. }, scene: Nullable<Scene>): LinesMesh;
  50414. /**
  50415. * Creates a line mesh
  50416. * 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
  50417. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50418. * * The parameter `points` is an array successive Vector3
  50419. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  50420. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50421. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50422. * * When updating an instance, remember that only point positions can change, not the number of points
  50423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50424. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50425. * @param name defines the name of the new line system
  50426. * @param options defines the options used to create the line system
  50427. * @param scene defines the hosting scene
  50428. * @returns a new line mesh
  50429. */
  50430. static CreateLines(name: string, options: {
  50431. points: Vector3[];
  50432. updatable?: boolean;
  50433. instance?: Nullable<LinesMesh>;
  50434. colors?: Color4[];
  50435. useVertexAlpha?: boolean;
  50436. }, scene?: Nullable<Scene>): LinesMesh;
  50437. /**
  50438. * Creates a dashed line mesh
  50439. * * 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
  50440. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50441. * * The parameter `points` is an array successive Vector3
  50442. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50443. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50444. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50445. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  50446. * * When updating an instance, remember that only point positions can change, not the number of points
  50447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50448. * @param name defines the name of the mesh
  50449. * @param options defines the options used to create the mesh
  50450. * @param scene defines the hosting scene
  50451. * @returns the dashed line mesh
  50452. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50453. */
  50454. static CreateDashedLines(name: string, options: {
  50455. points: Vector3[];
  50456. dashSize?: number;
  50457. gapSize?: number;
  50458. dashNb?: number;
  50459. updatable?: boolean;
  50460. instance?: LinesMesh;
  50461. }, scene?: Nullable<Scene>): LinesMesh;
  50462. /**
  50463. * 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.
  50464. * * 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.
  50465. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50466. * * 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.
  50467. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50468. * * 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
  50469. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  50470. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50473. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50475. * @param name defines the name of the mesh
  50476. * @param options defines the options used to create the mesh
  50477. * @param scene defines the hosting scene
  50478. * @returns the extruded shape mesh
  50479. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50480. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50481. */
  50482. static ExtrudeShape(name: string, options: {
  50483. shape: Vector3[];
  50484. path: Vector3[];
  50485. scale?: number;
  50486. rotation?: number;
  50487. cap?: number;
  50488. updatable?: boolean;
  50489. sideOrientation?: number;
  50490. frontUVs?: Vector4;
  50491. backUVs?: Vector4;
  50492. instance?: Mesh;
  50493. invertUV?: boolean;
  50494. }, scene?: Nullable<Scene>): Mesh;
  50495. /**
  50496. * Creates an custom extruded shape mesh.
  50497. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50498. * * 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.
  50499. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50500. * * 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
  50501. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50502. * * 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
  50503. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50504. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50505. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50506. * * 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
  50507. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  50508. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50511. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50513. * @param name defines the name of the mesh
  50514. * @param options defines the options used to create the mesh
  50515. * @param scene defines the hosting scene
  50516. * @returns the custom extruded shape mesh
  50517. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50518. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50519. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50520. */
  50521. static ExtrudeShapeCustom(name: string, options: {
  50522. shape: Vector3[];
  50523. path: Vector3[];
  50524. scaleFunction?: any;
  50525. rotationFunction?: any;
  50526. ribbonCloseArray?: boolean;
  50527. ribbonClosePath?: boolean;
  50528. cap?: number;
  50529. updatable?: boolean;
  50530. sideOrientation?: number;
  50531. frontUVs?: Vector4;
  50532. backUVs?: Vector4;
  50533. instance?: Mesh;
  50534. invertUV?: boolean;
  50535. }, scene?: Nullable<Scene>): Mesh;
  50536. /**
  50537. * Creates lathe mesh.
  50538. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50539. * * 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
  50540. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50541. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50542. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50543. * * 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
  50544. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50545. * * 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
  50546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50548. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50550. * @param name defines the name of the mesh
  50551. * @param options defines the options used to create the mesh
  50552. * @param scene defines the hosting scene
  50553. * @returns the lathe mesh
  50554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50555. */
  50556. static CreateLathe(name: string, options: {
  50557. shape: Vector3[];
  50558. radius?: number;
  50559. tessellation?: number;
  50560. clip?: number;
  50561. arc?: number;
  50562. closed?: boolean;
  50563. updatable?: boolean;
  50564. sideOrientation?: number;
  50565. frontUVs?: Vector4;
  50566. backUVs?: Vector4;
  50567. cap?: number;
  50568. invertUV?: boolean;
  50569. }, scene?: Nullable<Scene>): Mesh;
  50570. /**
  50571. * Creates a plane mesh
  50572. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50573. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50574. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50578. * @param name defines the name of the mesh
  50579. * @param options defines the options used to create the mesh
  50580. * @param scene defines the hosting scene
  50581. * @returns the plane mesh
  50582. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50583. */
  50584. static CreatePlane(name: string, options: {
  50585. size?: number;
  50586. width?: number;
  50587. height?: number;
  50588. sideOrientation?: number;
  50589. frontUVs?: Vector4;
  50590. backUVs?: Vector4;
  50591. updatable?: boolean;
  50592. sourcePlane?: Plane;
  50593. }, scene?: Nullable<Scene>): Mesh;
  50594. /**
  50595. * Creates a ground mesh
  50596. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50597. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50599. * @param name defines the name of the mesh
  50600. * @param options defines the options used to create the mesh
  50601. * @param scene defines the hosting scene
  50602. * @returns the ground mesh
  50603. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50604. */
  50605. static CreateGround(name: string, options: {
  50606. width?: number;
  50607. height?: number;
  50608. subdivisions?: number;
  50609. subdivisionsX?: number;
  50610. subdivisionsY?: number;
  50611. updatable?: boolean;
  50612. }, scene?: Nullable<Scene>): Mesh;
  50613. /**
  50614. * Creates a tiled ground mesh
  50615. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50616. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50617. * * 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
  50618. * * 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
  50619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50620. * @param name defines the name of the mesh
  50621. * @param options defines the options used to create the mesh
  50622. * @param scene defines the hosting scene
  50623. * @returns the tiled ground mesh
  50624. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50625. */
  50626. static CreateTiledGround(name: string, options: {
  50627. xmin: number;
  50628. zmin: number;
  50629. xmax: number;
  50630. zmax: number;
  50631. subdivisions?: {
  50632. w: number;
  50633. h: number;
  50634. };
  50635. precision?: {
  50636. w: number;
  50637. h: number;
  50638. };
  50639. updatable?: boolean;
  50640. }, scene?: Nullable<Scene>): Mesh;
  50641. /**
  50642. * Creates a ground mesh from a height map
  50643. * * The parameter `url` sets the URL of the height map image resource.
  50644. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50645. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50646. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50647. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50648. * * 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.
  50649. * * 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).
  50650. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50652. * @param name defines the name of the mesh
  50653. * @param url defines the url to the height map
  50654. * @param options defines the options used to create the mesh
  50655. * @param scene defines the hosting scene
  50656. * @returns the ground mesh
  50657. * @see https://doc.babylonjs.com/babylon101/height_map
  50658. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50659. */
  50660. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50661. width?: number;
  50662. height?: number;
  50663. subdivisions?: number;
  50664. minHeight?: number;
  50665. maxHeight?: number;
  50666. colorFilter?: Color3;
  50667. alphaFilter?: number;
  50668. updatable?: boolean;
  50669. onReady?: (mesh: GroundMesh) => void;
  50670. }, scene?: Nullable<Scene>): GroundMesh;
  50671. /**
  50672. * Creates a polygon mesh
  50673. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50674. * * 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
  50675. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50677. * * 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)
  50678. * * Remember you can only change the shape positions, not their number when updating a polygon
  50679. * @param name defines the name of the mesh
  50680. * @param options defines the options used to create the mesh
  50681. * @param scene defines the hosting scene
  50682. * @param earcutInjection can be used to inject your own earcut reference
  50683. * @returns the polygon mesh
  50684. */
  50685. static CreatePolygon(name: string, options: {
  50686. shape: Vector3[];
  50687. holes?: Vector3[][];
  50688. depth?: number;
  50689. faceUV?: Vector4[];
  50690. faceColors?: Color4[];
  50691. updatable?: boolean;
  50692. sideOrientation?: number;
  50693. frontUVs?: Vector4;
  50694. backUVs?: Vector4;
  50695. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50696. /**
  50697. * Creates an extruded polygon mesh, with depth in the Y direction.
  50698. * * 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)
  50699. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50700. * @param name defines the name of the mesh
  50701. * @param options defines the options used to create the mesh
  50702. * @param scene defines the hosting scene
  50703. * @param earcutInjection can be used to inject your own earcut reference
  50704. * @returns the polygon mesh
  50705. */
  50706. static ExtrudePolygon(name: string, options: {
  50707. shape: Vector3[];
  50708. holes?: Vector3[][];
  50709. depth?: number;
  50710. faceUV?: Vector4[];
  50711. faceColors?: Color4[];
  50712. updatable?: boolean;
  50713. sideOrientation?: number;
  50714. frontUVs?: Vector4;
  50715. backUVs?: Vector4;
  50716. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50717. /**
  50718. * Creates a tube mesh.
  50719. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50720. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50721. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50722. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50723. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50724. * * 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)
  50725. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50726. * * 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
  50727. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  50728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50730. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50732. * @param name defines the name of the mesh
  50733. * @param options defines the options used to create the mesh
  50734. * @param scene defines the hosting scene
  50735. * @returns the tube mesh
  50736. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50737. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50738. */
  50739. static CreateTube(name: string, options: {
  50740. path: Vector3[];
  50741. radius?: number;
  50742. tessellation?: number;
  50743. radiusFunction?: {
  50744. (i: number, distance: number): number;
  50745. };
  50746. cap?: number;
  50747. arc?: number;
  50748. updatable?: boolean;
  50749. sideOrientation?: number;
  50750. frontUVs?: Vector4;
  50751. backUVs?: Vector4;
  50752. instance?: Mesh;
  50753. invertUV?: boolean;
  50754. }, scene?: Nullable<Scene>): Mesh;
  50755. /**
  50756. * Creates a polyhedron mesh
  50757. * * 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
  50758. * * The parameter `size` (positive float, default 1) sets the polygon size
  50759. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50760. * * 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`
  50761. * * 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
  50762. * * 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)`)
  50763. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50764. * * 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
  50765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50768. * @param name defines the name of the mesh
  50769. * @param options defines the options used to create the mesh
  50770. * @param scene defines the hosting scene
  50771. * @returns the polyhedron mesh
  50772. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50773. */
  50774. static CreatePolyhedron(name: string, options: {
  50775. type?: number;
  50776. size?: number;
  50777. sizeX?: number;
  50778. sizeY?: number;
  50779. sizeZ?: number;
  50780. custom?: any;
  50781. faceUV?: Vector4[];
  50782. faceColors?: Color4[];
  50783. flat?: boolean;
  50784. updatable?: boolean;
  50785. sideOrientation?: number;
  50786. frontUVs?: Vector4;
  50787. backUVs?: Vector4;
  50788. }, scene?: Nullable<Scene>): Mesh;
  50789. /**
  50790. * Creates a decal mesh.
  50791. * 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
  50792. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50793. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50794. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50795. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50796. * @param name defines the name of the mesh
  50797. * @param sourceMesh defines the mesh where the decal must be applied
  50798. * @param options defines the options used to create the mesh
  50799. * @param scene defines the hosting scene
  50800. * @returns the decal mesh
  50801. * @see https://doc.babylonjs.com/how_to/decals
  50802. */
  50803. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50804. position?: Vector3;
  50805. normal?: Vector3;
  50806. size?: Vector3;
  50807. angle?: number;
  50808. }): Mesh;
  50809. }
  50810. }
  50811. declare module BABYLON {
  50812. /**
  50813. * A simplifier interface for future simplification implementations
  50814. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50815. */
  50816. export interface ISimplifier {
  50817. /**
  50818. * Simplification of a given mesh according to the given settings.
  50819. * Since this requires computation, it is assumed that the function runs async.
  50820. * @param settings The settings of the simplification, including quality and distance
  50821. * @param successCallback A callback that will be called after the mesh was simplified.
  50822. * @param errorCallback in case of an error, this callback will be called. optional.
  50823. */
  50824. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50825. }
  50826. /**
  50827. * Expected simplification settings.
  50828. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50829. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50830. */
  50831. export interface ISimplificationSettings {
  50832. /**
  50833. * Gets or sets the expected quality
  50834. */
  50835. quality: number;
  50836. /**
  50837. * Gets or sets the distance when this optimized version should be used
  50838. */
  50839. distance: number;
  50840. /**
  50841. * Gets an already optimized mesh
  50842. */
  50843. optimizeMesh?: boolean;
  50844. }
  50845. /**
  50846. * Class used to specify simplification options
  50847. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50848. */
  50849. export class SimplificationSettings implements ISimplificationSettings {
  50850. /** expected quality */
  50851. quality: number;
  50852. /** distance when this optimized version should be used */
  50853. distance: number;
  50854. /** already optimized mesh */
  50855. optimizeMesh?: boolean | undefined;
  50856. /**
  50857. * Creates a SimplificationSettings
  50858. * @param quality expected quality
  50859. * @param distance distance when this optimized version should be used
  50860. * @param optimizeMesh already optimized mesh
  50861. */
  50862. constructor(
  50863. /** expected quality */
  50864. quality: number,
  50865. /** distance when this optimized version should be used */
  50866. distance: number,
  50867. /** already optimized mesh */
  50868. optimizeMesh?: boolean | undefined);
  50869. }
  50870. /**
  50871. * Interface used to define a simplification task
  50872. */
  50873. export interface ISimplificationTask {
  50874. /**
  50875. * Array of settings
  50876. */
  50877. settings: Array<ISimplificationSettings>;
  50878. /**
  50879. * Simplification type
  50880. */
  50881. simplificationType: SimplificationType;
  50882. /**
  50883. * Mesh to simplify
  50884. */
  50885. mesh: Mesh;
  50886. /**
  50887. * Callback called on success
  50888. */
  50889. successCallback?: () => void;
  50890. /**
  50891. * Defines if parallel processing can be used
  50892. */
  50893. parallelProcessing: boolean;
  50894. }
  50895. /**
  50896. * Queue used to order the simplification tasks
  50897. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50898. */
  50899. export class SimplificationQueue {
  50900. private _simplificationArray;
  50901. /**
  50902. * Gets a boolean indicating that the process is still running
  50903. */
  50904. running: boolean;
  50905. /**
  50906. * Creates a new queue
  50907. */
  50908. constructor();
  50909. /**
  50910. * Adds a new simplification task
  50911. * @param task defines a task to add
  50912. */
  50913. addTask(task: ISimplificationTask): void;
  50914. /**
  50915. * Execute next task
  50916. */
  50917. executeNext(): void;
  50918. /**
  50919. * Execute a simplification task
  50920. * @param task defines the task to run
  50921. */
  50922. runSimplification(task: ISimplificationTask): void;
  50923. private getSimplifier;
  50924. }
  50925. /**
  50926. * The implemented types of simplification
  50927. * At the moment only Quadratic Error Decimation is implemented
  50928. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50929. */
  50930. export enum SimplificationType {
  50931. /** Quadratic error decimation */
  50932. QUADRATIC = 0
  50933. }
  50934. }
  50935. declare module BABYLON {
  50936. interface Scene {
  50937. /** @hidden (Backing field) */
  50938. _simplificationQueue: SimplificationQueue;
  50939. /**
  50940. * Gets or sets the simplification queue attached to the scene
  50941. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50942. */
  50943. simplificationQueue: SimplificationQueue;
  50944. }
  50945. interface Mesh {
  50946. /**
  50947. * Simplify the mesh according to the given array of settings.
  50948. * Function will return immediately and will simplify async
  50949. * @param settings a collection of simplification settings
  50950. * @param parallelProcessing should all levels calculate parallel or one after the other
  50951. * @param simplificationType the type of simplification to run
  50952. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50953. * @returns the current mesh
  50954. */
  50955. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50956. }
  50957. /**
  50958. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50959. * created in a scene
  50960. */
  50961. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50962. /**
  50963. * The component name helpfull to identify the component in the list of scene components.
  50964. */
  50965. readonly name: string;
  50966. /**
  50967. * The scene the component belongs to.
  50968. */
  50969. scene: Scene;
  50970. /**
  50971. * Creates a new instance of the component for the given scene
  50972. * @param scene Defines the scene to register the component in
  50973. */
  50974. constructor(scene: Scene);
  50975. /**
  50976. * Registers the component in a given scene
  50977. */
  50978. register(): void;
  50979. /**
  50980. * Rebuilds the elements related to this component in case of
  50981. * context lost for instance.
  50982. */
  50983. rebuild(): void;
  50984. /**
  50985. * Disposes the component and the associated ressources
  50986. */
  50987. dispose(): void;
  50988. private _beforeCameraUpdate;
  50989. }
  50990. }
  50991. declare module BABYLON {
  50992. /**
  50993. * Class used to enable access to IndexedDB
  50994. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50995. */
  50996. export class Database implements IOfflineProvider {
  50997. private _callbackManifestChecked;
  50998. private _currentSceneUrl;
  50999. private _db;
  51000. private _enableSceneOffline;
  51001. private _enableTexturesOffline;
  51002. private _manifestVersionFound;
  51003. private _mustUpdateRessources;
  51004. private _hasReachedQuota;
  51005. private _isSupported;
  51006. private _idbFactory;
  51007. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51008. private static IsUASupportingBlobStorage;
  51009. /**
  51010. * Gets a boolean indicating if Database storate is enabled (off by default)
  51011. */
  51012. static IDBStorageEnabled: boolean;
  51013. /**
  51014. * Gets a boolean indicating if scene must be saved in the database
  51015. */
  51016. readonly enableSceneOffline: boolean;
  51017. /**
  51018. * Gets a boolean indicating if textures must be saved in the database
  51019. */
  51020. readonly enableTexturesOffline: boolean;
  51021. /**
  51022. * Creates a new Database
  51023. * @param urlToScene defines the url to load the scene
  51024. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51025. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51026. */
  51027. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51028. private static _ParseURL;
  51029. private static _ReturnFullUrlLocation;
  51030. private _checkManifestFile;
  51031. /**
  51032. * Open the database and make it available
  51033. * @param successCallback defines the callback to call on success
  51034. * @param errorCallback defines the callback to call on error
  51035. */
  51036. open(successCallback: () => void, errorCallback: () => void): void;
  51037. /**
  51038. * Loads an image from the database
  51039. * @param url defines the url to load from
  51040. * @param image defines the target DOM image
  51041. */
  51042. loadImage(url: string, image: HTMLImageElement): void;
  51043. private _loadImageFromDBAsync;
  51044. private _saveImageIntoDBAsync;
  51045. private _checkVersionFromDB;
  51046. private _loadVersionFromDBAsync;
  51047. private _saveVersionIntoDBAsync;
  51048. /**
  51049. * Loads a file from database
  51050. * @param url defines the URL to load from
  51051. * @param sceneLoaded defines a callback to call on success
  51052. * @param progressCallBack defines a callback to call when progress changed
  51053. * @param errorCallback defines a callback to call on error
  51054. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51055. */
  51056. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51057. private _loadFileAsync;
  51058. private _saveFileAsync;
  51059. /**
  51060. * Validates if xhr data is correct
  51061. * @param xhr defines the request to validate
  51062. * @param dataType defines the expected data type
  51063. * @returns true if data is correct
  51064. */
  51065. private static _ValidateXHRData;
  51066. }
  51067. }
  51068. declare module BABYLON {
  51069. /** @hidden */
  51070. export var gpuUpdateParticlesPixelShader: {
  51071. name: string;
  51072. shader: string;
  51073. };
  51074. }
  51075. declare module BABYLON {
  51076. /** @hidden */
  51077. export var gpuUpdateParticlesVertexShader: {
  51078. name: string;
  51079. shader: string;
  51080. };
  51081. }
  51082. declare module BABYLON {
  51083. /** @hidden */
  51084. export var clipPlaneFragmentDeclaration2: {
  51085. name: string;
  51086. shader: string;
  51087. };
  51088. }
  51089. declare module BABYLON {
  51090. /** @hidden */
  51091. export var gpuRenderParticlesPixelShader: {
  51092. name: string;
  51093. shader: string;
  51094. };
  51095. }
  51096. declare module BABYLON {
  51097. /** @hidden */
  51098. export var clipPlaneVertexDeclaration2: {
  51099. name: string;
  51100. shader: string;
  51101. };
  51102. }
  51103. declare module BABYLON {
  51104. /** @hidden */
  51105. export var gpuRenderParticlesVertexShader: {
  51106. name: string;
  51107. shader: string;
  51108. };
  51109. }
  51110. declare module BABYLON {
  51111. /**
  51112. * This represents a GPU particle system in Babylon
  51113. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51114. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51115. */
  51116. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51117. /**
  51118. * The layer mask we are rendering the particles through.
  51119. */
  51120. layerMask: number;
  51121. private _capacity;
  51122. private _activeCount;
  51123. private _currentActiveCount;
  51124. private _accumulatedCount;
  51125. private _renderEffect;
  51126. private _updateEffect;
  51127. private _buffer0;
  51128. private _buffer1;
  51129. private _spriteBuffer;
  51130. private _updateVAO;
  51131. private _renderVAO;
  51132. private _targetIndex;
  51133. private _sourceBuffer;
  51134. private _targetBuffer;
  51135. private _engine;
  51136. private _currentRenderId;
  51137. private _started;
  51138. private _stopped;
  51139. private _timeDelta;
  51140. private _randomTexture;
  51141. private _randomTexture2;
  51142. private _attributesStrideSize;
  51143. private _updateEffectOptions;
  51144. private _randomTextureSize;
  51145. private _actualFrame;
  51146. private readonly _rawTextureWidth;
  51147. /**
  51148. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51149. */
  51150. static readonly IsSupported: boolean;
  51151. /**
  51152. * An event triggered when the system is disposed.
  51153. */
  51154. onDisposeObservable: Observable<GPUParticleSystem>;
  51155. /**
  51156. * Gets the maximum number of particles active at the same time.
  51157. * @returns The max number of active particles.
  51158. */
  51159. getCapacity(): number;
  51160. /**
  51161. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51162. * to override the particles.
  51163. */
  51164. forceDepthWrite: boolean;
  51165. /**
  51166. * Gets or set the number of active particles
  51167. */
  51168. activeParticleCount: number;
  51169. private _preWarmDone;
  51170. /**
  51171. * Is this system ready to be used/rendered
  51172. * @return true if the system is ready
  51173. */
  51174. isReady(): boolean;
  51175. /**
  51176. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51177. * @returns True if it has been started, otherwise false.
  51178. */
  51179. isStarted(): boolean;
  51180. /**
  51181. * Starts the particle system and begins to emit
  51182. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51183. */
  51184. start(delay?: number): void;
  51185. /**
  51186. * Stops the particle system.
  51187. */
  51188. stop(): void;
  51189. /**
  51190. * Remove all active particles
  51191. */
  51192. reset(): void;
  51193. /**
  51194. * Returns the string "GPUParticleSystem"
  51195. * @returns a string containing the class name
  51196. */
  51197. getClassName(): string;
  51198. private _colorGradientsTexture;
  51199. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51200. /**
  51201. * Adds a new color gradient
  51202. * @param gradient defines the gradient to use (between 0 and 1)
  51203. * @param color1 defines the color to affect to the specified gradient
  51204. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51205. * @returns the current particle system
  51206. */
  51207. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51208. /**
  51209. * Remove a specific color gradient
  51210. * @param gradient defines the gradient to remove
  51211. * @returns the current particle system
  51212. */
  51213. removeColorGradient(gradient: number): GPUParticleSystem;
  51214. private _angularSpeedGradientsTexture;
  51215. private _sizeGradientsTexture;
  51216. private _velocityGradientsTexture;
  51217. private _limitVelocityGradientsTexture;
  51218. private _dragGradientsTexture;
  51219. private _addFactorGradient;
  51220. /**
  51221. * Adds a new size gradient
  51222. * @param gradient defines the gradient to use (between 0 and 1)
  51223. * @param factor defines the size factor to affect to the specified gradient
  51224. * @returns the current particle system
  51225. */
  51226. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51227. /**
  51228. * Remove a specific size gradient
  51229. * @param gradient defines the gradient to remove
  51230. * @returns the current particle system
  51231. */
  51232. removeSizeGradient(gradient: number): GPUParticleSystem;
  51233. /**
  51234. * Adds a new angular speed gradient
  51235. * @param gradient defines the gradient to use (between 0 and 1)
  51236. * @param factor defines the angular speed to affect to the specified gradient
  51237. * @returns the current particle system
  51238. */
  51239. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51240. /**
  51241. * Remove a specific angular speed gradient
  51242. * @param gradient defines the gradient to remove
  51243. * @returns the current particle system
  51244. */
  51245. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51246. /**
  51247. * Adds a new velocity gradient
  51248. * @param gradient defines the gradient to use (between 0 and 1)
  51249. * @param factor defines the velocity to affect to the specified gradient
  51250. * @returns the current particle system
  51251. */
  51252. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51253. /**
  51254. * Remove a specific velocity gradient
  51255. * @param gradient defines the gradient to remove
  51256. * @returns the current particle system
  51257. */
  51258. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51259. /**
  51260. * Adds a new limit velocity gradient
  51261. * @param gradient defines the gradient to use (between 0 and 1)
  51262. * @param factor defines the limit velocity value to affect to the specified gradient
  51263. * @returns the current particle system
  51264. */
  51265. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51266. /**
  51267. * Remove a specific limit velocity gradient
  51268. * @param gradient defines the gradient to remove
  51269. * @returns the current particle system
  51270. */
  51271. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51272. /**
  51273. * Adds a new drag gradient
  51274. * @param gradient defines the gradient to use (between 0 and 1)
  51275. * @param factor defines the drag value to affect to the specified gradient
  51276. * @returns the current particle system
  51277. */
  51278. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51279. /**
  51280. * Remove a specific drag gradient
  51281. * @param gradient defines the gradient to remove
  51282. * @returns the current particle system
  51283. */
  51284. removeDragGradient(gradient: number): GPUParticleSystem;
  51285. /**
  51286. * Not supported by GPUParticleSystem
  51287. * @param gradient defines the gradient to use (between 0 and 1)
  51288. * @param factor defines the emit rate value to affect to the specified gradient
  51289. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51290. * @returns the current particle system
  51291. */
  51292. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51293. /**
  51294. * Not supported by GPUParticleSystem
  51295. * @param gradient defines the gradient to remove
  51296. * @returns the current particle system
  51297. */
  51298. removeEmitRateGradient(gradient: number): IParticleSystem;
  51299. /**
  51300. * Not supported by GPUParticleSystem
  51301. * @param gradient defines the gradient to use (between 0 and 1)
  51302. * @param factor defines the start size value to affect to the specified gradient
  51303. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51304. * @returns the current particle system
  51305. */
  51306. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51307. /**
  51308. * Not supported by GPUParticleSystem
  51309. * @param gradient defines the gradient to remove
  51310. * @returns the current particle system
  51311. */
  51312. removeStartSizeGradient(gradient: number): IParticleSystem;
  51313. /**
  51314. * Not supported by GPUParticleSystem
  51315. * @param gradient defines the gradient to use (between 0 and 1)
  51316. * @param min defines the color remap minimal range
  51317. * @param max defines the color remap maximal range
  51318. * @returns the current particle system
  51319. */
  51320. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51321. /**
  51322. * Not supported by GPUParticleSystem
  51323. * @param gradient defines the gradient to remove
  51324. * @returns the current particle system
  51325. */
  51326. removeColorRemapGradient(): IParticleSystem;
  51327. /**
  51328. * Not supported by GPUParticleSystem
  51329. * @param gradient defines the gradient to use (between 0 and 1)
  51330. * @param min defines the alpha remap minimal range
  51331. * @param max defines the alpha remap maximal range
  51332. * @returns the current particle system
  51333. */
  51334. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51335. /**
  51336. * Not supported by GPUParticleSystem
  51337. * @param gradient defines the gradient to remove
  51338. * @returns the current particle system
  51339. */
  51340. removeAlphaRemapGradient(): IParticleSystem;
  51341. /**
  51342. * Not supported by GPUParticleSystem
  51343. * @param gradient defines the gradient to use (between 0 and 1)
  51344. * @param color defines the color to affect to the specified gradient
  51345. * @returns the current particle system
  51346. */
  51347. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51348. /**
  51349. * Not supported by GPUParticleSystem
  51350. * @param gradient defines the gradient to remove
  51351. * @returns the current particle system
  51352. */
  51353. removeRampGradient(): IParticleSystem;
  51354. /**
  51355. * Not supported by GPUParticleSystem
  51356. * @returns the list of ramp gradients
  51357. */
  51358. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51359. /**
  51360. * Not supported by GPUParticleSystem
  51361. * Gets or sets a boolean indicating that ramp gradients must be used
  51362. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51363. */
  51364. useRampGradients: boolean;
  51365. /**
  51366. * Not supported by GPUParticleSystem
  51367. * @param gradient defines the gradient to use (between 0 and 1)
  51368. * @param factor defines the life time factor to affect to the specified gradient
  51369. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51370. * @returns the current particle system
  51371. */
  51372. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51373. /**
  51374. * Not supported by GPUParticleSystem
  51375. * @param gradient defines the gradient to remove
  51376. * @returns the current particle system
  51377. */
  51378. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51379. /**
  51380. * Instantiates a GPU particle system.
  51381. * 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.
  51382. * @param name The name of the particle system
  51383. * @param options The options used to create the system
  51384. * @param scene The scene the particle system belongs to
  51385. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51386. */
  51387. constructor(name: string, options: Partial<{
  51388. capacity: number;
  51389. randomTextureSize: number;
  51390. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51391. protected _reset(): void;
  51392. private _createUpdateVAO;
  51393. private _createRenderVAO;
  51394. private _initialize;
  51395. /** @hidden */
  51396. _recreateUpdateEffect(): void;
  51397. /** @hidden */
  51398. _recreateRenderEffect(): void;
  51399. /**
  51400. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51401. * @param preWarm defines if we are in the pre-warmimg phase
  51402. */
  51403. animate(preWarm?: boolean): void;
  51404. private _createFactorGradientTexture;
  51405. private _createSizeGradientTexture;
  51406. private _createAngularSpeedGradientTexture;
  51407. private _createVelocityGradientTexture;
  51408. private _createLimitVelocityGradientTexture;
  51409. private _createDragGradientTexture;
  51410. private _createColorGradientTexture;
  51411. /**
  51412. * Renders the particle system in its current state
  51413. * @param preWarm defines if the system should only update the particles but not render them
  51414. * @returns the current number of particles
  51415. */
  51416. render(preWarm?: boolean): number;
  51417. /**
  51418. * Rebuilds the particle system
  51419. */
  51420. rebuild(): void;
  51421. private _releaseBuffers;
  51422. private _releaseVAOs;
  51423. /**
  51424. * Disposes the particle system and free the associated resources
  51425. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51426. */
  51427. dispose(disposeTexture?: boolean): void;
  51428. /**
  51429. * Clones the particle system.
  51430. * @param name The name of the cloned object
  51431. * @param newEmitter The new emitter to use
  51432. * @returns the cloned particle system
  51433. */
  51434. clone(name: string, newEmitter: any): GPUParticleSystem;
  51435. /**
  51436. * Serializes the particle system to a JSON object.
  51437. * @returns the JSON object
  51438. */
  51439. serialize(): any;
  51440. /**
  51441. * Parses a JSON object to create a GPU particle system.
  51442. * @param parsedParticleSystem The JSON object to parse
  51443. * @param scene The scene to create the particle system in
  51444. * @param rootUrl The root url to use to load external dependencies like texture
  51445. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51446. * @returns the parsed GPU particle system
  51447. */
  51448. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51449. }
  51450. }
  51451. declare module BABYLON {
  51452. /**
  51453. * Represents a set of particle systems working together to create a specific effect
  51454. */
  51455. export class ParticleSystemSet implements IDisposable {
  51456. private _emitterCreationOptions;
  51457. private _emitterNode;
  51458. /**
  51459. * Gets the particle system list
  51460. */
  51461. systems: IParticleSystem[];
  51462. /**
  51463. * Gets the emitter node used with this set
  51464. */
  51465. readonly emitterNode: Nullable<TransformNode>;
  51466. /**
  51467. * Creates a new emitter mesh as a sphere
  51468. * @param options defines the options used to create the sphere
  51469. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51470. * @param scene defines the hosting scene
  51471. */
  51472. setEmitterAsSphere(options: {
  51473. diameter: number;
  51474. segments: number;
  51475. color: Color3;
  51476. }, renderingGroupId: number, scene: Scene): void;
  51477. /**
  51478. * Starts all particle systems of the set
  51479. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51480. */
  51481. start(emitter?: AbstractMesh): void;
  51482. /**
  51483. * Release all associated resources
  51484. */
  51485. dispose(): void;
  51486. /**
  51487. * Serialize the set into a JSON compatible object
  51488. * @returns a JSON compatible representation of the set
  51489. */
  51490. serialize(): any;
  51491. /**
  51492. * Parse a new ParticleSystemSet from a serialized source
  51493. * @param data defines a JSON compatible representation of the set
  51494. * @param scene defines the hosting scene
  51495. * @param gpu defines if we want GPU particles or CPU particles
  51496. * @returns a new ParticleSystemSet
  51497. */
  51498. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51499. }
  51500. }
  51501. declare module BABYLON {
  51502. /**
  51503. * This class is made for on one-liner static method to help creating particle system set.
  51504. */
  51505. export class ParticleHelper {
  51506. /**
  51507. * Gets or sets base Assets URL
  51508. */
  51509. static BaseAssetsUrl: string;
  51510. /**
  51511. * Create a default particle system that you can tweak
  51512. * @param emitter defines the emitter to use
  51513. * @param capacity defines the system capacity (default is 500 particles)
  51514. * @param scene defines the hosting scene
  51515. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51516. * @returns the new Particle system
  51517. */
  51518. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51519. /**
  51520. * This is the main static method (one-liner) of this helper to create different particle systems
  51521. * @param type This string represents the type to the particle system to create
  51522. * @param scene The scene where the particle system should live
  51523. * @param gpu If the system will use gpu
  51524. * @returns the ParticleSystemSet created
  51525. */
  51526. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51527. /**
  51528. * Static function used to export a particle system to a ParticleSystemSet variable.
  51529. * Please note that the emitter shape is not exported
  51530. * @param systems defines the particle systems to export
  51531. * @returns the created particle system set
  51532. */
  51533. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51534. }
  51535. }
  51536. declare module BABYLON {
  51537. interface Engine {
  51538. /**
  51539. * Create an effect to use with particle systems.
  51540. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51541. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51542. * @param uniformsNames defines a list of attribute names
  51543. * @param samplers defines an array of string used to represent textures
  51544. * @param defines defines the string containing the defines to use to compile the shaders
  51545. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51546. * @param onCompiled defines a function to call when the effect creation is successful
  51547. * @param onError defines a function to call when the effect creation has failed
  51548. * @returns the new Effect
  51549. */
  51550. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51551. }
  51552. interface Mesh {
  51553. /**
  51554. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51555. * @returns an array of IParticleSystem
  51556. */
  51557. getEmittedParticleSystems(): IParticleSystem[];
  51558. /**
  51559. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51560. * @returns an array of IParticleSystem
  51561. */
  51562. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51563. }
  51564. /**
  51565. * @hidden
  51566. */
  51567. export var _IDoNeedToBeInTheBuild: number;
  51568. }
  51569. declare module BABYLON {
  51570. interface Scene {
  51571. /** @hidden (Backing field) */
  51572. _physicsEngine: Nullable<IPhysicsEngine>;
  51573. /**
  51574. * Gets the current physics engine
  51575. * @returns a IPhysicsEngine or null if none attached
  51576. */
  51577. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51578. /**
  51579. * Enables physics to the current scene
  51580. * @param gravity defines the scene's gravity for the physics engine
  51581. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51582. * @return a boolean indicating if the physics engine was initialized
  51583. */
  51584. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51585. /**
  51586. * Disables and disposes the physics engine associated with the scene
  51587. */
  51588. disablePhysicsEngine(): void;
  51589. /**
  51590. * Gets a boolean indicating if there is an active physics engine
  51591. * @returns a boolean indicating if there is an active physics engine
  51592. */
  51593. isPhysicsEnabled(): boolean;
  51594. /**
  51595. * Deletes a physics compound impostor
  51596. * @param compound defines the compound to delete
  51597. */
  51598. deleteCompoundImpostor(compound: any): void;
  51599. /**
  51600. * An event triggered when physic simulation is about to be run
  51601. */
  51602. onBeforePhysicsObservable: Observable<Scene>;
  51603. /**
  51604. * An event triggered when physic simulation has been done
  51605. */
  51606. onAfterPhysicsObservable: Observable<Scene>;
  51607. }
  51608. interface AbstractMesh {
  51609. /** @hidden */
  51610. _physicsImpostor: Nullable<PhysicsImpostor>;
  51611. /**
  51612. * Gets or sets impostor used for physic simulation
  51613. * @see http://doc.babylonjs.com/features/physics_engine
  51614. */
  51615. physicsImpostor: Nullable<PhysicsImpostor>;
  51616. /**
  51617. * Gets the current physics impostor
  51618. * @see http://doc.babylonjs.com/features/physics_engine
  51619. * @returns a physics impostor or null
  51620. */
  51621. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51622. /** Apply a physic impulse to the mesh
  51623. * @param force defines the force to apply
  51624. * @param contactPoint defines where to apply the force
  51625. * @returns the current mesh
  51626. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51627. */
  51628. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51629. /**
  51630. * Creates a physic joint between two meshes
  51631. * @param otherMesh defines the other mesh to use
  51632. * @param pivot1 defines the pivot to use on this mesh
  51633. * @param pivot2 defines the pivot to use on the other mesh
  51634. * @param options defines additional options (can be plugin dependent)
  51635. * @returns the current mesh
  51636. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51637. */
  51638. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51639. /** @hidden */
  51640. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51641. }
  51642. /**
  51643. * Defines the physics engine scene component responsible to manage a physics engine
  51644. */
  51645. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51646. /**
  51647. * The component name helpful to identify the component in the list of scene components.
  51648. */
  51649. readonly name: string;
  51650. /**
  51651. * The scene the component belongs to.
  51652. */
  51653. scene: Scene;
  51654. /**
  51655. * Creates a new instance of the component for the given scene
  51656. * @param scene Defines the scene to register the component in
  51657. */
  51658. constructor(scene: Scene);
  51659. /**
  51660. * Registers the component in a given scene
  51661. */
  51662. register(): void;
  51663. /**
  51664. * Rebuilds the elements related to this component in case of
  51665. * context lost for instance.
  51666. */
  51667. rebuild(): void;
  51668. /**
  51669. * Disposes the component and the associated ressources
  51670. */
  51671. dispose(): void;
  51672. }
  51673. }
  51674. declare module BABYLON {
  51675. /**
  51676. * A helper for physics simulations
  51677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51678. */
  51679. export class PhysicsHelper {
  51680. private _scene;
  51681. private _physicsEngine;
  51682. /**
  51683. * Initializes the Physics helper
  51684. * @param scene Babylon.js scene
  51685. */
  51686. constructor(scene: Scene);
  51687. /**
  51688. * Applies a radial explosion impulse
  51689. * @param origin the origin of the explosion
  51690. * @param radiusOrEventOptions the radius or the options of radial explosion
  51691. * @param strength the explosion strength
  51692. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51693. * @returns A physics radial explosion event, or null
  51694. */
  51695. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51696. /**
  51697. * Applies a radial explosion force
  51698. * @param origin the origin of the explosion
  51699. * @param radiusOrEventOptions the radius or the options of radial explosion
  51700. * @param strength the explosion strength
  51701. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51702. * @returns A physics radial explosion event, or null
  51703. */
  51704. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51705. /**
  51706. * Creates a gravitational field
  51707. * @param origin the origin of the explosion
  51708. * @param radiusOrEventOptions the radius or the options of radial explosion
  51709. * @param strength the explosion strength
  51710. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51711. * @returns A physics gravitational field event, or null
  51712. */
  51713. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51714. /**
  51715. * Creates a physics updraft event
  51716. * @param origin the origin of the updraft
  51717. * @param radiusOrEventOptions the radius or the options of the updraft
  51718. * @param strength the strength of the updraft
  51719. * @param height the height of the updraft
  51720. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51721. * @returns A physics updraft event, or null
  51722. */
  51723. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51724. /**
  51725. * Creates a physics vortex event
  51726. * @param origin the of the vortex
  51727. * @param radiusOrEventOptions the radius or the options of the vortex
  51728. * @param strength the strength of the vortex
  51729. * @param height the height of the vortex
  51730. * @returns a Physics vortex event, or null
  51731. * A physics vortex event or null
  51732. */
  51733. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  51734. }
  51735. /**
  51736. * Represents a physics radial explosion event
  51737. */
  51738. class PhysicsRadialExplosionEvent {
  51739. private _scene;
  51740. private _options;
  51741. private _sphere;
  51742. private _dataFetched;
  51743. /**
  51744. * Initializes a radial explosioin event
  51745. * @param _scene BabylonJS scene
  51746. * @param _options The options for the vortex event
  51747. */
  51748. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  51749. /**
  51750. * Returns the data related to the radial explosion event (sphere).
  51751. * @returns The radial explosion event data
  51752. */
  51753. getData(): PhysicsRadialExplosionEventData;
  51754. /**
  51755. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51756. * @param impostor A physics imposter
  51757. * @param origin the origin of the explosion
  51758. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  51759. */
  51760. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  51761. /**
  51762. * Triggers affecterd impostors callbacks
  51763. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  51764. */
  51765. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  51766. /**
  51767. * Disposes the sphere.
  51768. * @param force Specifies if the sphere should be disposed by force
  51769. */
  51770. dispose(force?: boolean): void;
  51771. /*** Helpers ***/
  51772. private _prepareSphere;
  51773. private _intersectsWithSphere;
  51774. }
  51775. /**
  51776. * Represents a gravitational field event
  51777. */
  51778. class PhysicsGravitationalFieldEvent {
  51779. private _physicsHelper;
  51780. private _scene;
  51781. private _origin;
  51782. private _options;
  51783. private _tickCallback;
  51784. private _sphere;
  51785. private _dataFetched;
  51786. /**
  51787. * Initializes the physics gravitational field event
  51788. * @param _physicsHelper A physics helper
  51789. * @param _scene BabylonJS scene
  51790. * @param _origin The origin position of the gravitational field event
  51791. * @param _options The options for the vortex event
  51792. */
  51793. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  51794. /**
  51795. * Returns the data related to the gravitational field event (sphere).
  51796. * @returns A gravitational field event
  51797. */
  51798. getData(): PhysicsGravitationalFieldEventData;
  51799. /**
  51800. * Enables the gravitational field.
  51801. */
  51802. enable(): void;
  51803. /**
  51804. * Disables the gravitational field.
  51805. */
  51806. disable(): void;
  51807. /**
  51808. * Disposes the sphere.
  51809. * @param force The force to dispose from the gravitational field event
  51810. */
  51811. dispose(force?: boolean): void;
  51812. private _tick;
  51813. }
  51814. /**
  51815. * Represents a physics updraft event
  51816. */
  51817. class PhysicsUpdraftEvent {
  51818. private _scene;
  51819. private _origin;
  51820. private _options;
  51821. private _physicsEngine;
  51822. private _originTop;
  51823. private _originDirection;
  51824. private _tickCallback;
  51825. private _cylinder;
  51826. private _cylinderPosition;
  51827. private _dataFetched;
  51828. /**
  51829. * Initializes the physics updraft event
  51830. * @param _scene BabylonJS scene
  51831. * @param _origin The origin position of the updraft
  51832. * @param _options The options for the updraft event
  51833. */
  51834. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  51835. /**
  51836. * Returns the data related to the updraft event (cylinder).
  51837. * @returns A physics updraft event
  51838. */
  51839. getData(): PhysicsUpdraftEventData;
  51840. /**
  51841. * Enables the updraft.
  51842. */
  51843. enable(): void;
  51844. /**
  51845. * Disables the updraft.
  51846. */
  51847. disable(): void;
  51848. /**
  51849. * Disposes the cylinder.
  51850. * @param force Specifies if the updraft should be disposed by force
  51851. */
  51852. dispose(force?: boolean): void;
  51853. private getImpostorHitData;
  51854. private _tick;
  51855. /*** Helpers ***/
  51856. private _prepareCylinder;
  51857. private _intersectsWithCylinder;
  51858. }
  51859. /**
  51860. * Represents a physics vortex event
  51861. */
  51862. class PhysicsVortexEvent {
  51863. private _scene;
  51864. private _origin;
  51865. private _options;
  51866. private _physicsEngine;
  51867. private _originTop;
  51868. private _tickCallback;
  51869. private _cylinder;
  51870. private _cylinderPosition;
  51871. private _dataFetched;
  51872. /**
  51873. * Initializes the physics vortex event
  51874. * @param _scene The BabylonJS scene
  51875. * @param _origin The origin position of the vortex
  51876. * @param _options The options for the vortex event
  51877. */
  51878. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  51879. /**
  51880. * Returns the data related to the vortex event (cylinder).
  51881. * @returns The physics vortex event data
  51882. */
  51883. getData(): PhysicsVortexEventData;
  51884. /**
  51885. * Enables the vortex.
  51886. */
  51887. enable(): void;
  51888. /**
  51889. * Disables the cortex.
  51890. */
  51891. disable(): void;
  51892. /**
  51893. * Disposes the sphere.
  51894. * @param force
  51895. */
  51896. dispose(force?: boolean): void;
  51897. private getImpostorHitData;
  51898. private _tick;
  51899. /*** Helpers ***/
  51900. private _prepareCylinder;
  51901. private _intersectsWithCylinder;
  51902. }
  51903. /**
  51904. * Options fot the radial explosion event
  51905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51906. */
  51907. export class PhysicsRadialExplosionEventOptions {
  51908. /**
  51909. * The radius of the sphere for the radial explosion.
  51910. */
  51911. radius: number;
  51912. /**
  51913. * The strenth of the explosion.
  51914. */
  51915. strength: number;
  51916. /**
  51917. * The strenght of the force in correspondence to the distance of the affected object
  51918. */
  51919. falloff: PhysicsRadialImpulseFalloff;
  51920. /**
  51921. * Sphere options for the radial explosion.
  51922. */
  51923. sphere: {
  51924. segments: number;
  51925. diameter: number;
  51926. };
  51927. /**
  51928. * Sphere options for the radial explosion.
  51929. */
  51930. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  51931. }
  51932. /**
  51933. * Options fot the updraft event
  51934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51935. */
  51936. export class PhysicsUpdraftEventOptions {
  51937. /**
  51938. * The radius of the cylinder for the vortex
  51939. */
  51940. radius: number;
  51941. /**
  51942. * The strenth of the updraft.
  51943. */
  51944. strength: number;
  51945. /**
  51946. * The height of the cylinder for the updraft.
  51947. */
  51948. height: number;
  51949. /**
  51950. * The mode for the the updraft.
  51951. */
  51952. updraftMode: PhysicsUpdraftMode;
  51953. }
  51954. /**
  51955. * Options fot the vortex event
  51956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51957. */
  51958. export class PhysicsVortexEventOptions {
  51959. /**
  51960. * The radius of the cylinder for the vortex
  51961. */
  51962. radius: number;
  51963. /**
  51964. * The strenth of the vortex.
  51965. */
  51966. strength: number;
  51967. /**
  51968. * The height of the cylinder for the vortex.
  51969. */
  51970. height: number;
  51971. /**
  51972. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  51973. */
  51974. centripetalForceThreshold: number;
  51975. /**
  51976. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  51977. */
  51978. centripetalForceMultiplier: number;
  51979. /**
  51980. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  51981. */
  51982. centrifugalForceMultiplier: number;
  51983. /**
  51984. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  51985. */
  51986. updraftForceMultiplier: number;
  51987. }
  51988. /**
  51989. * The strenght of the force in correspondence to the distance of the affected object
  51990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51991. */
  51992. export enum PhysicsRadialImpulseFalloff {
  51993. /** Defines that impulse is constant in strength across it's whole radius */
  51994. Constant = 0,
  51995. /** Defines that impulse gets weaker if it's further from the origin */
  51996. Linear = 1
  51997. }
  51998. /**
  51999. * The strength of the force in correspondence to the distance of the affected object
  52000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52001. */
  52002. export enum PhysicsUpdraftMode {
  52003. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52004. Center = 0,
  52005. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52006. Perpendicular = 1
  52007. }
  52008. /**
  52009. * Interface for a physics hit data
  52010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52011. */
  52012. export interface PhysicsHitData {
  52013. /**
  52014. * The force applied at the contact point
  52015. */
  52016. force: Vector3;
  52017. /**
  52018. * The contact point
  52019. */
  52020. contactPoint: Vector3;
  52021. /**
  52022. * The distance from the origin to the contact point
  52023. */
  52024. distanceFromOrigin: number;
  52025. }
  52026. /**
  52027. * Interface for radial explosion event data
  52028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52029. */
  52030. export interface PhysicsRadialExplosionEventData {
  52031. /**
  52032. * A sphere used for the radial explosion event
  52033. */
  52034. sphere: Mesh;
  52035. }
  52036. /**
  52037. * Interface for gravitational field event data
  52038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52039. */
  52040. export interface PhysicsGravitationalFieldEventData {
  52041. /**
  52042. * A sphere mesh used for the gravitational field event
  52043. */
  52044. sphere: Mesh;
  52045. }
  52046. /**
  52047. * Interface for updraft event data
  52048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52049. */
  52050. export interface PhysicsUpdraftEventData {
  52051. /**
  52052. * A cylinder used for the updraft event
  52053. */
  52054. cylinder: Mesh;
  52055. }
  52056. /**
  52057. * Interface for vortex event data
  52058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52059. */
  52060. export interface PhysicsVortexEventData {
  52061. /**
  52062. * A cylinder used for the vortex event
  52063. */
  52064. cylinder: Mesh;
  52065. }
  52066. /**
  52067. * Interface for an affected physics impostor
  52068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52069. */
  52070. export interface PhysicsAffectedImpostorWithData {
  52071. /**
  52072. * The impostor affected by the effect
  52073. */
  52074. impostor: PhysicsImpostor;
  52075. /**
  52076. * The data about the hit/horce from the explosion
  52077. */
  52078. hitData: PhysicsHitData;
  52079. }
  52080. }
  52081. declare module BABYLON {
  52082. /** @hidden */
  52083. export var blackAndWhitePixelShader: {
  52084. name: string;
  52085. shader: string;
  52086. };
  52087. }
  52088. declare module BABYLON {
  52089. /**
  52090. * Post process used to render in black and white
  52091. */
  52092. export class BlackAndWhitePostProcess extends PostProcess {
  52093. /**
  52094. * Linear about to convert he result to black and white (default: 1)
  52095. */
  52096. degree: number;
  52097. /**
  52098. * Creates a black and white post process
  52099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52100. * @param name The name of the effect.
  52101. * @param options The required width/height ratio to downsize to before computing the render pass.
  52102. * @param camera The camera to apply the render pass to.
  52103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52104. * @param engine The engine which the post process will be applied. (default: current engine)
  52105. * @param reusable If the post process can be reused on the same frame. (default: false)
  52106. */
  52107. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52108. }
  52109. }
  52110. declare module BABYLON {
  52111. /**
  52112. * This represents a set of one or more post processes in Babylon.
  52113. * A post process can be used to apply a shader to a texture after it is rendered.
  52114. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52115. */
  52116. export class PostProcessRenderEffect {
  52117. private _postProcesses;
  52118. private _getPostProcesses;
  52119. private _singleInstance;
  52120. private _cameras;
  52121. private _indicesForCamera;
  52122. /**
  52123. * Name of the effect
  52124. * @hidden
  52125. */
  52126. _name: string;
  52127. /**
  52128. * Instantiates a post process render effect.
  52129. * A post process can be used to apply a shader to a texture after it is rendered.
  52130. * @param engine The engine the effect is tied to
  52131. * @param name The name of the effect
  52132. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52133. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52134. */
  52135. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52136. /**
  52137. * Checks if all the post processes in the effect are supported.
  52138. */
  52139. readonly isSupported: boolean;
  52140. /**
  52141. * Updates the current state of the effect
  52142. * @hidden
  52143. */
  52144. _update(): void;
  52145. /**
  52146. * Attaches the effect on cameras
  52147. * @param cameras The camera to attach to.
  52148. * @hidden
  52149. */
  52150. _attachCameras(cameras: Camera): void;
  52151. /**
  52152. * Attaches the effect on cameras
  52153. * @param cameras The camera to attach to.
  52154. * @hidden
  52155. */
  52156. _attachCameras(cameras: Camera[]): void;
  52157. /**
  52158. * Detaches the effect on cameras
  52159. * @param cameras The camera to detatch from.
  52160. * @hidden
  52161. */
  52162. _detachCameras(cameras: Camera): void;
  52163. /**
  52164. * Detatches the effect on cameras
  52165. * @param cameras The camera to detatch from.
  52166. * @hidden
  52167. */
  52168. _detachCameras(cameras: Camera[]): void;
  52169. /**
  52170. * Enables the effect on given cameras
  52171. * @param cameras The camera to enable.
  52172. * @hidden
  52173. */
  52174. _enable(cameras: Camera): void;
  52175. /**
  52176. * Enables the effect on given cameras
  52177. * @param cameras The camera to enable.
  52178. * @hidden
  52179. */
  52180. _enable(cameras: Nullable<Camera[]>): void;
  52181. /**
  52182. * Disables the effect on the given cameras
  52183. * @param cameras The camera to disable.
  52184. * @hidden
  52185. */
  52186. _disable(cameras: Camera): void;
  52187. /**
  52188. * Disables the effect on the given cameras
  52189. * @param cameras The camera to disable.
  52190. * @hidden
  52191. */
  52192. _disable(cameras: Nullable<Camera[]>): void;
  52193. /**
  52194. * Gets a list of the post processes contained in the effect.
  52195. * @param camera The camera to get the post processes on.
  52196. * @returns The list of the post processes in the effect.
  52197. */
  52198. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52199. }
  52200. }
  52201. declare module BABYLON {
  52202. /** @hidden */
  52203. export var extractHighlightsPixelShader: {
  52204. name: string;
  52205. shader: string;
  52206. };
  52207. }
  52208. declare module BABYLON {
  52209. /**
  52210. * 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.
  52211. */
  52212. export class ExtractHighlightsPostProcess extends PostProcess {
  52213. /**
  52214. * The luminance threshold, pixels below this value will be set to black.
  52215. */
  52216. threshold: number;
  52217. /** @hidden */
  52218. _exposure: number;
  52219. /**
  52220. * Post process which has the input texture to be used when performing highlight extraction
  52221. * @hidden
  52222. */
  52223. _inputPostProcess: Nullable<PostProcess>;
  52224. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52225. }
  52226. }
  52227. declare module BABYLON {
  52228. /** @hidden */
  52229. export var bloomMergePixelShader: {
  52230. name: string;
  52231. shader: string;
  52232. };
  52233. }
  52234. declare module BABYLON {
  52235. /**
  52236. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52237. */
  52238. export class BloomMergePostProcess extends PostProcess {
  52239. /** Weight of the bloom to be added to the original input. */
  52240. weight: number;
  52241. /**
  52242. * Creates a new instance of @see BloomMergePostProcess
  52243. * @param name The name of the effect.
  52244. * @param originalFromInput Post process which's input will be used for the merge.
  52245. * @param blurred Blurred highlights post process which's output will be used.
  52246. * @param weight Weight of the bloom to be added to the original input.
  52247. * @param options The required width/height ratio to downsize to before computing the render pass.
  52248. * @param camera The camera to apply the render pass to.
  52249. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52250. * @param engine The engine which the post process will be applied. (default: current engine)
  52251. * @param reusable If the post process can be reused on the same frame. (default: false)
  52252. * @param textureType Type of textures used when performing the post process. (default: 0)
  52253. * @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)
  52254. */
  52255. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52256. /** Weight of the bloom to be added to the original input. */
  52257. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52258. }
  52259. }
  52260. declare module BABYLON {
  52261. /**
  52262. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52263. */
  52264. export class BloomEffect extends PostProcessRenderEffect {
  52265. private bloomScale;
  52266. /**
  52267. * @hidden Internal
  52268. */
  52269. _effects: Array<PostProcess>;
  52270. /**
  52271. * @hidden Internal
  52272. */
  52273. _downscale: ExtractHighlightsPostProcess;
  52274. private _blurX;
  52275. private _blurY;
  52276. private _merge;
  52277. /**
  52278. * The luminance threshold to find bright areas of the image to bloom.
  52279. */
  52280. threshold: number;
  52281. /**
  52282. * The strength of the bloom.
  52283. */
  52284. weight: number;
  52285. /**
  52286. * Specifies the size of the bloom blur kernel, relative to the final output size
  52287. */
  52288. kernel: number;
  52289. /**
  52290. * Creates a new instance of @see BloomEffect
  52291. * @param scene The scene the effect belongs to.
  52292. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52293. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52294. * @param bloomWeight The the strength of bloom.
  52295. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52296. * @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)
  52297. */
  52298. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52299. /**
  52300. * Disposes each of the internal effects for a given camera.
  52301. * @param camera The camera to dispose the effect on.
  52302. */
  52303. disposeEffects(camera: Camera): void;
  52304. /**
  52305. * @hidden Internal
  52306. */
  52307. _updateEffects(): void;
  52308. /**
  52309. * Internal
  52310. * @returns if all the contained post processes are ready.
  52311. * @hidden
  52312. */
  52313. _isReady(): boolean;
  52314. }
  52315. }
  52316. declare module BABYLON {
  52317. /** @hidden */
  52318. export var chromaticAberrationPixelShader: {
  52319. name: string;
  52320. shader: string;
  52321. };
  52322. }
  52323. declare module BABYLON {
  52324. /**
  52325. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52326. */
  52327. export class ChromaticAberrationPostProcess extends PostProcess {
  52328. /**
  52329. * The amount of seperation of rgb channels (default: 30)
  52330. */
  52331. aberrationAmount: number;
  52332. /**
  52333. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52334. */
  52335. radialIntensity: number;
  52336. /**
  52337. * 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))
  52338. */
  52339. direction: Vector2;
  52340. /**
  52341. * 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))
  52342. */
  52343. centerPosition: Vector2;
  52344. /**
  52345. * Creates a new instance ChromaticAberrationPostProcess
  52346. * @param name The name of the effect.
  52347. * @param screenWidth The width of the screen to apply the effect on.
  52348. * @param screenHeight The height of the screen to apply the effect on.
  52349. * @param options The required width/height ratio to downsize to before computing the render pass.
  52350. * @param camera The camera to apply the render pass to.
  52351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52352. * @param engine The engine which the post process will be applied. (default: current engine)
  52353. * @param reusable If the post process can be reused on the same frame. (default: false)
  52354. * @param textureType Type of textures used when performing the post process. (default: 0)
  52355. * @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)
  52356. */
  52357. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52358. }
  52359. }
  52360. declare module BABYLON {
  52361. /** @hidden */
  52362. export var circleOfConfusionPixelShader: {
  52363. name: string;
  52364. shader: string;
  52365. };
  52366. }
  52367. declare module BABYLON {
  52368. /**
  52369. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52370. */
  52371. export class CircleOfConfusionPostProcess extends PostProcess {
  52372. /**
  52373. * 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.
  52374. */
  52375. lensSize: number;
  52376. /**
  52377. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52378. */
  52379. fStop: number;
  52380. /**
  52381. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52382. */
  52383. focusDistance: number;
  52384. /**
  52385. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52386. */
  52387. focalLength: number;
  52388. private _depthTexture;
  52389. /**
  52390. * Creates a new instance CircleOfConfusionPostProcess
  52391. * @param name The name of the effect.
  52392. * @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.
  52393. * @param options The required width/height ratio to downsize to before computing the render pass.
  52394. * @param camera The camera to apply the render pass to.
  52395. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52396. * @param engine The engine which the post process will be applied. (default: current engine)
  52397. * @param reusable If the post process can be reused on the same frame. (default: false)
  52398. * @param textureType Type of textures used when performing the post process. (default: 0)
  52399. * @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)
  52400. */
  52401. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52402. /**
  52403. * 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.
  52404. */
  52405. depthTexture: RenderTargetTexture;
  52406. }
  52407. }
  52408. declare module BABYLON {
  52409. /** @hidden */
  52410. export var colorCorrectionPixelShader: {
  52411. name: string;
  52412. shader: string;
  52413. };
  52414. }
  52415. declare module BABYLON {
  52416. /**
  52417. *
  52418. * This post-process allows the modification of rendered colors by using
  52419. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52420. *
  52421. * The object needs to be provided an url to a texture containing the color
  52422. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52423. * Use an image editing software to tweak the LUT to match your needs.
  52424. *
  52425. * For an example of a color LUT, see here:
  52426. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52427. * For explanations on color grading, see here:
  52428. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52429. *
  52430. */
  52431. export class ColorCorrectionPostProcess extends PostProcess {
  52432. private _colorTableTexture;
  52433. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52434. }
  52435. }
  52436. declare module BABYLON {
  52437. /** @hidden */
  52438. export var convolutionPixelShader: {
  52439. name: string;
  52440. shader: string;
  52441. };
  52442. }
  52443. declare module BABYLON {
  52444. /**
  52445. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52446. * input texture to perform effects such as edge detection or sharpening
  52447. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52448. */
  52449. export class ConvolutionPostProcess extends PostProcess {
  52450. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52451. kernel: number[];
  52452. /**
  52453. * Creates a new instance ConvolutionPostProcess
  52454. * @param name The name of the effect.
  52455. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52456. * @param options The required width/height ratio to downsize to before computing the render pass.
  52457. * @param camera The camera to apply the render pass to.
  52458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52459. * @param engine The engine which the post process will be applied. (default: current engine)
  52460. * @param reusable If the post process can be reused on the same frame. (default: false)
  52461. * @param textureType Type of textures used when performing the post process. (default: 0)
  52462. */
  52463. constructor(name: string,
  52464. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52465. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52466. /**
  52467. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52468. */
  52469. static EdgeDetect0Kernel: number[];
  52470. /**
  52471. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52472. */
  52473. static EdgeDetect1Kernel: number[];
  52474. /**
  52475. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52476. */
  52477. static EdgeDetect2Kernel: number[];
  52478. /**
  52479. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52480. */
  52481. static SharpenKernel: number[];
  52482. /**
  52483. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52484. */
  52485. static EmbossKernel: number[];
  52486. /**
  52487. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52488. */
  52489. static GaussianKernel: number[];
  52490. }
  52491. }
  52492. declare module BABYLON {
  52493. /**
  52494. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52495. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52496. * based on samples that have a large difference in distance than the center pixel.
  52497. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52498. */
  52499. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52500. direction: Vector2;
  52501. /**
  52502. * Creates a new instance CircleOfConfusionPostProcess
  52503. * @param name The name of the effect.
  52504. * @param scene The scene the effect belongs to.
  52505. * @param direction The direction the blur should be applied.
  52506. * @param kernel The size of the kernel used to blur.
  52507. * @param options The required width/height ratio to downsize to before computing the render pass.
  52508. * @param camera The camera to apply the render pass to.
  52509. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52510. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52511. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52512. * @param engine The engine which the post process will be applied. (default: current engine)
  52513. * @param reusable If the post process can be reused on the same frame. (default: false)
  52514. * @param textureType Type of textures used when performing the post process. (default: 0)
  52515. * @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)
  52516. */
  52517. 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);
  52518. }
  52519. }
  52520. declare module BABYLON {
  52521. /** @hidden */
  52522. export var depthOfFieldMergePixelShader: {
  52523. name: string;
  52524. shader: string;
  52525. };
  52526. }
  52527. declare module BABYLON {
  52528. /**
  52529. * Options to be set when merging outputs from the default pipeline.
  52530. */
  52531. export class DepthOfFieldMergePostProcessOptions {
  52532. /**
  52533. * The original image to merge on top of
  52534. */
  52535. originalFromInput: PostProcess;
  52536. /**
  52537. * Parameters to perform the merge of the depth of field effect
  52538. */
  52539. depthOfField?: {
  52540. circleOfConfusion: PostProcess;
  52541. blurSteps: Array<PostProcess>;
  52542. };
  52543. /**
  52544. * Parameters to perform the merge of bloom effect
  52545. */
  52546. bloom?: {
  52547. blurred: PostProcess;
  52548. weight: number;
  52549. };
  52550. }
  52551. /**
  52552. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52553. */
  52554. export class DepthOfFieldMergePostProcess extends PostProcess {
  52555. private blurSteps;
  52556. /**
  52557. * Creates a new instance of DepthOfFieldMergePostProcess
  52558. * @param name The name of the effect.
  52559. * @param originalFromInput Post process which's input will be used for the merge.
  52560. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52561. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52562. * @param options The required width/height ratio to downsize to before computing the render pass.
  52563. * @param camera The camera to apply the render pass to.
  52564. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52565. * @param engine The engine which the post process will be applied. (default: current engine)
  52566. * @param reusable If the post process can be reused on the same frame. (default: false)
  52567. * @param textureType Type of textures used when performing the post process. (default: 0)
  52568. * @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)
  52569. */
  52570. 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);
  52571. /**
  52572. * Updates the effect with the current post process compile time values and recompiles the shader.
  52573. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52574. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52575. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52576. * @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
  52577. * @param onCompiled Called when the shader has been compiled.
  52578. * @param onError Called if there is an error when compiling a shader.
  52579. */
  52580. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52581. }
  52582. }
  52583. declare module BABYLON {
  52584. /**
  52585. * Specifies the level of max blur that should be applied when using the depth of field effect
  52586. */
  52587. export enum DepthOfFieldEffectBlurLevel {
  52588. /**
  52589. * Subtle blur
  52590. */
  52591. Low = 0,
  52592. /**
  52593. * Medium blur
  52594. */
  52595. Medium = 1,
  52596. /**
  52597. * Large blur
  52598. */
  52599. High = 2
  52600. }
  52601. /**
  52602. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52603. */
  52604. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52605. private _circleOfConfusion;
  52606. /**
  52607. * @hidden Internal, blurs from high to low
  52608. */
  52609. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52610. private _depthOfFieldBlurY;
  52611. private _dofMerge;
  52612. /**
  52613. * @hidden Internal post processes in depth of field effect
  52614. */
  52615. _effects: Array<PostProcess>;
  52616. /**
  52617. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52618. */
  52619. focalLength: number;
  52620. /**
  52621. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52622. */
  52623. fStop: number;
  52624. /**
  52625. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52626. */
  52627. focusDistance: number;
  52628. /**
  52629. * 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.
  52630. */
  52631. lensSize: number;
  52632. /**
  52633. * Creates a new instance DepthOfFieldEffect
  52634. * @param scene The scene the effect belongs to.
  52635. * @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.
  52636. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52637. * @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)
  52638. */
  52639. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52640. /**
  52641. * Get the current class name of the current effet
  52642. * @returns "DepthOfFieldEffect"
  52643. */
  52644. getClassName(): string;
  52645. /**
  52646. * 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.
  52647. */
  52648. depthTexture: RenderTargetTexture;
  52649. /**
  52650. * Disposes each of the internal effects for a given camera.
  52651. * @param camera The camera to dispose the effect on.
  52652. */
  52653. disposeEffects(camera: Camera): void;
  52654. /**
  52655. * @hidden Internal
  52656. */
  52657. _updateEffects(): void;
  52658. /**
  52659. * Internal
  52660. * @returns if all the contained post processes are ready.
  52661. * @hidden
  52662. */
  52663. _isReady(): boolean;
  52664. }
  52665. }
  52666. declare module BABYLON {
  52667. /** @hidden */
  52668. export var displayPassPixelShader: {
  52669. name: string;
  52670. shader: string;
  52671. };
  52672. }
  52673. declare module BABYLON {
  52674. /**
  52675. * DisplayPassPostProcess which produces an output the same as it's input
  52676. */
  52677. export class DisplayPassPostProcess extends PostProcess {
  52678. /**
  52679. * Creates the DisplayPassPostProcess
  52680. * @param name The name of the effect.
  52681. * @param options The required width/height ratio to downsize to before computing the render pass.
  52682. * @param camera The camera to apply the render pass to.
  52683. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52684. * @param engine The engine which the post process will be applied. (default: current engine)
  52685. * @param reusable If the post process can be reused on the same frame. (default: false)
  52686. */
  52687. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52688. }
  52689. }
  52690. declare module BABYLON {
  52691. /** @hidden */
  52692. export var filterPixelShader: {
  52693. name: string;
  52694. shader: string;
  52695. };
  52696. }
  52697. declare module BABYLON {
  52698. /**
  52699. * Applies a kernel filter to the image
  52700. */
  52701. export class FilterPostProcess extends PostProcess {
  52702. /** The matrix to be applied to the image */
  52703. kernelMatrix: Matrix;
  52704. /**
  52705. *
  52706. * @param name The name of the effect.
  52707. * @param kernelMatrix The matrix to be applied to the image
  52708. * @param options The required width/height ratio to downsize to before computing the render pass.
  52709. * @param camera The camera to apply the render pass to.
  52710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52711. * @param engine The engine which the post process will be applied. (default: current engine)
  52712. * @param reusable If the post process can be reused on the same frame. (default: false)
  52713. */
  52714. constructor(name: string,
  52715. /** The matrix to be applied to the image */
  52716. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52717. }
  52718. }
  52719. declare module BABYLON {
  52720. /** @hidden */
  52721. export var fxaaPixelShader: {
  52722. name: string;
  52723. shader: string;
  52724. };
  52725. }
  52726. declare module BABYLON {
  52727. /** @hidden */
  52728. export var fxaaVertexShader: {
  52729. name: string;
  52730. shader: string;
  52731. };
  52732. }
  52733. declare module BABYLON {
  52734. /**
  52735. * Fxaa post process
  52736. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52737. */
  52738. export class FxaaPostProcess extends PostProcess {
  52739. /** @hidden */
  52740. texelWidth: number;
  52741. /** @hidden */
  52742. texelHeight: number;
  52743. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52744. private _getDefines;
  52745. }
  52746. }
  52747. declare module BABYLON {
  52748. /** @hidden */
  52749. export var grainPixelShader: {
  52750. name: string;
  52751. shader: string;
  52752. };
  52753. }
  52754. declare module BABYLON {
  52755. /**
  52756. * The GrainPostProcess adds noise to the image at mid luminance levels
  52757. */
  52758. export class GrainPostProcess extends PostProcess {
  52759. /**
  52760. * The intensity of the grain added (default: 30)
  52761. */
  52762. intensity: number;
  52763. /**
  52764. * If the grain should be randomized on every frame
  52765. */
  52766. animated: boolean;
  52767. /**
  52768. * Creates a new instance of @see GrainPostProcess
  52769. * @param name The name of the effect.
  52770. * @param options The required width/height ratio to downsize to before computing the render pass.
  52771. * @param camera The camera to apply the render pass to.
  52772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52773. * @param engine The engine which the post process will be applied. (default: current engine)
  52774. * @param reusable If the post process can be reused on the same frame. (default: false)
  52775. * @param textureType Type of textures used when performing the post process. (default: 0)
  52776. * @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)
  52777. */
  52778. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52779. }
  52780. }
  52781. declare module BABYLON {
  52782. /** @hidden */
  52783. export var highlightsPixelShader: {
  52784. name: string;
  52785. shader: string;
  52786. };
  52787. }
  52788. declare module BABYLON {
  52789. /**
  52790. * Extracts highlights from the image
  52791. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52792. */
  52793. export class HighlightsPostProcess extends PostProcess {
  52794. /**
  52795. * Extracts highlights from the image
  52796. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52797. * @param name The name of the effect.
  52798. * @param options The required width/height ratio to downsize to before computing the render pass.
  52799. * @param camera The camera to apply the render pass to.
  52800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52801. * @param engine The engine which the post process will be applied. (default: current engine)
  52802. * @param reusable If the post process can be reused on the same frame. (default: false)
  52803. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52804. */
  52805. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52806. }
  52807. }
  52808. declare module BABYLON {
  52809. /** @hidden */
  52810. export var mrtFragmentDeclaration: {
  52811. name: string;
  52812. shader: string;
  52813. };
  52814. }
  52815. declare module BABYLON {
  52816. /** @hidden */
  52817. export var geometryPixelShader: {
  52818. name: string;
  52819. shader: string;
  52820. };
  52821. }
  52822. declare module BABYLON {
  52823. /** @hidden */
  52824. export var geometryVertexShader: {
  52825. name: string;
  52826. shader: string;
  52827. };
  52828. }
  52829. declare module BABYLON {
  52830. /**
  52831. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52832. */
  52833. export class GeometryBufferRenderer {
  52834. /**
  52835. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52836. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52837. */
  52838. static readonly POSITION_TEXTURE_TYPE: number;
  52839. /**
  52840. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52841. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52842. */
  52843. static readonly VELOCITY_TEXTURE_TYPE: number;
  52844. /**
  52845. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52846. * in order to compute objects velocities when enableVelocity is set to "true"
  52847. * @hidden
  52848. */
  52849. _previousTransformationMatrices: {
  52850. [index: number]: Matrix;
  52851. };
  52852. private _scene;
  52853. private _multiRenderTarget;
  52854. private _ratio;
  52855. private _enablePosition;
  52856. private _enableVelocity;
  52857. private _positionIndex;
  52858. private _velocityIndex;
  52859. protected _effect: Effect;
  52860. protected _cachedDefines: string;
  52861. /**
  52862. * Set the render list (meshes to be rendered) used in the G buffer.
  52863. */
  52864. renderList: Mesh[];
  52865. /**
  52866. * Gets wether or not G buffer are supported by the running hardware.
  52867. * This requires draw buffer supports
  52868. */
  52869. readonly isSupported: boolean;
  52870. /**
  52871. * Returns the index of the given texture type in the G-Buffer textures array
  52872. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52873. * @returns the index of the given texture type in the G-Buffer textures array
  52874. */
  52875. getTextureIndex(textureType: number): number;
  52876. /**
  52877. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52878. */
  52879. /**
  52880. * Sets whether or not objects positions are enabled for the G buffer.
  52881. */
  52882. enablePosition: boolean;
  52883. /**
  52884. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52885. */
  52886. /**
  52887. * Sets wether or not objects velocities are enabled for the G buffer.
  52888. */
  52889. enableVelocity: boolean;
  52890. /**
  52891. * Gets the scene associated with the buffer.
  52892. */
  52893. readonly scene: Scene;
  52894. /**
  52895. * Gets the ratio used by the buffer during its creation.
  52896. * How big is the buffer related to the main canvas.
  52897. */
  52898. readonly ratio: number;
  52899. /** @hidden */
  52900. static _SceneComponentInitialization: (scene: Scene) => void;
  52901. /**
  52902. * Creates a new G Buffer for the scene
  52903. * @param scene The scene the buffer belongs to
  52904. * @param ratio How big is the buffer related to the main canvas.
  52905. */
  52906. constructor(scene: Scene, ratio?: number);
  52907. /**
  52908. * Checks wether everything is ready to render a submesh to the G buffer.
  52909. * @param subMesh the submesh to check readiness for
  52910. * @param useInstances is the mesh drawn using instance or not
  52911. * @returns true if ready otherwise false
  52912. */
  52913. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52914. /**
  52915. * Gets the current underlying G Buffer.
  52916. * @returns the buffer
  52917. */
  52918. getGBuffer(): MultiRenderTarget;
  52919. /**
  52920. * Gets the number of samples used to render the buffer (anti aliasing).
  52921. */
  52922. /**
  52923. * Sets the number of samples used to render the buffer (anti aliasing).
  52924. */
  52925. samples: number;
  52926. /**
  52927. * Disposes the renderer and frees up associated resources.
  52928. */
  52929. dispose(): void;
  52930. protected _createRenderTargets(): void;
  52931. }
  52932. }
  52933. declare module BABYLON {
  52934. interface Scene {
  52935. /** @hidden (Backing field) */
  52936. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52937. /**
  52938. * Gets or Sets the current geometry buffer associated to the scene.
  52939. */
  52940. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52941. /**
  52942. * Enables a GeometryBufferRender and associates it with the scene
  52943. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  52944. * @returns the GeometryBufferRenderer
  52945. */
  52946. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  52947. /**
  52948. * Disables the GeometryBufferRender associated with the scene
  52949. */
  52950. disableGeometryBufferRenderer(): void;
  52951. }
  52952. /**
  52953. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  52954. * in several rendering techniques.
  52955. */
  52956. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  52957. /**
  52958. * The component name helpful to identify the component in the list of scene components.
  52959. */
  52960. readonly name: string;
  52961. /**
  52962. * The scene the component belongs to.
  52963. */
  52964. scene: Scene;
  52965. /**
  52966. * Creates a new instance of the component for the given scene
  52967. * @param scene Defines the scene to register the component in
  52968. */
  52969. constructor(scene: Scene);
  52970. /**
  52971. * Registers the component in a given scene
  52972. */
  52973. register(): void;
  52974. /**
  52975. * Rebuilds the elements related to this component in case of
  52976. * context lost for instance.
  52977. */
  52978. rebuild(): void;
  52979. /**
  52980. * Disposes the component and the associated ressources
  52981. */
  52982. dispose(): void;
  52983. private _gatherRenderTargets;
  52984. }
  52985. }
  52986. declare module BABYLON {
  52987. /** @hidden */
  52988. export var motionBlurPixelShader: {
  52989. name: string;
  52990. shader: string;
  52991. };
  52992. }
  52993. declare module BABYLON {
  52994. /**
  52995. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52996. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52997. * As an example, all you have to do is to create the post-process:
  52998. * var mb = new BABYLON.MotionBlurPostProcess(
  52999. * 'mb', // The name of the effect.
  53000. * scene, // The scene containing the objects to blur according to their velocity.
  53001. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53002. * camera // The camera to apply the render pass to.
  53003. * );
  53004. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53005. */
  53006. export class MotionBlurPostProcess extends PostProcess {
  53007. /**
  53008. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53009. */
  53010. motionStrength: number;
  53011. /**
  53012. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53013. */
  53014. /**
  53015. * Sets the number of iterations to be used for motion blur quality
  53016. */
  53017. motionBlurSamples: number;
  53018. private _motionBlurSamples;
  53019. private _geometryBufferRenderer;
  53020. /**
  53021. * Creates a new instance MotionBlurPostProcess
  53022. * @param name The name of the effect.
  53023. * @param scene The scene containing the objects to blur according to their velocity.
  53024. * @param options The required width/height ratio to downsize to before computing the render pass.
  53025. * @param camera The camera to apply the render pass to.
  53026. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53027. * @param engine The engine which the post process will be applied. (default: current engine)
  53028. * @param reusable If the post process can be reused on the same frame. (default: false)
  53029. * @param textureType Type of textures used when performing the post process. (default: 0)
  53030. * @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)
  53031. */
  53032. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53033. /**
  53034. * Disposes the post process.
  53035. * @param camera The camera to dispose the post process on.
  53036. */
  53037. dispose(camera?: Camera): void;
  53038. }
  53039. }
  53040. declare module BABYLON {
  53041. /** @hidden */
  53042. export var refractionPixelShader: {
  53043. name: string;
  53044. shader: string;
  53045. };
  53046. }
  53047. declare module BABYLON {
  53048. /**
  53049. * Post process which applies a refractin texture
  53050. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53051. */
  53052. export class RefractionPostProcess extends PostProcess {
  53053. /** the base color of the refraction (used to taint the rendering) */
  53054. color: Color3;
  53055. /** simulated refraction depth */
  53056. depth: number;
  53057. /** the coefficient of the base color (0 to remove base color tainting) */
  53058. colorLevel: number;
  53059. private _refTexture;
  53060. private _ownRefractionTexture;
  53061. /**
  53062. * Gets or sets the refraction texture
  53063. * Please note that you are responsible for disposing the texture if you set it manually
  53064. */
  53065. refractionTexture: Texture;
  53066. /**
  53067. * Initializes the RefractionPostProcess
  53068. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53069. * @param name The name of the effect.
  53070. * @param refractionTextureUrl Url of the refraction texture to use
  53071. * @param color the base color of the refraction (used to taint the rendering)
  53072. * @param depth simulated refraction depth
  53073. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53074. * @param camera The camera to apply the render pass to.
  53075. * @param options The required width/height ratio to downsize to before computing the render pass.
  53076. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53077. * @param engine The engine which the post process will be applied. (default: current engine)
  53078. * @param reusable If the post process can be reused on the same frame. (default: false)
  53079. */
  53080. constructor(name: string, refractionTextureUrl: string,
  53081. /** the base color of the refraction (used to taint the rendering) */
  53082. color: Color3,
  53083. /** simulated refraction depth */
  53084. depth: number,
  53085. /** the coefficient of the base color (0 to remove base color tainting) */
  53086. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53087. /**
  53088. * Disposes of the post process
  53089. * @param camera Camera to dispose post process on
  53090. */
  53091. dispose(camera: Camera): void;
  53092. }
  53093. }
  53094. declare module BABYLON {
  53095. /** @hidden */
  53096. export var sharpenPixelShader: {
  53097. name: string;
  53098. shader: string;
  53099. };
  53100. }
  53101. declare module BABYLON {
  53102. /**
  53103. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53104. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53105. */
  53106. export class SharpenPostProcess extends PostProcess {
  53107. /**
  53108. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53109. */
  53110. colorAmount: number;
  53111. /**
  53112. * How much sharpness should be applied (default: 0.3)
  53113. */
  53114. edgeAmount: number;
  53115. /**
  53116. * Creates a new instance ConvolutionPostProcess
  53117. * @param name The name of the effect.
  53118. * @param options The required width/height ratio to downsize to before computing the render pass.
  53119. * @param camera The camera to apply the render pass to.
  53120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53121. * @param engine The engine which the post process will be applied. (default: current engine)
  53122. * @param reusable If the post process can be reused on the same frame. (default: false)
  53123. * @param textureType Type of textures used when performing the post process. (default: 0)
  53124. * @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)
  53125. */
  53126. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53127. }
  53128. }
  53129. declare module BABYLON {
  53130. /**
  53131. * PostProcessRenderPipeline
  53132. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53133. */
  53134. export class PostProcessRenderPipeline {
  53135. private engine;
  53136. private _renderEffects;
  53137. private _renderEffectsForIsolatedPass;
  53138. /**
  53139. * List of inspectable custom properties (used by the Inspector)
  53140. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  53141. */
  53142. inspectableCustomProperties: IInspectable[];
  53143. /**
  53144. * @hidden
  53145. */
  53146. protected _cameras: Camera[];
  53147. /** @hidden */
  53148. _name: string;
  53149. /**
  53150. * Gets pipeline name
  53151. */
  53152. readonly name: string;
  53153. /**
  53154. * Initializes a PostProcessRenderPipeline
  53155. * @param engine engine to add the pipeline to
  53156. * @param name name of the pipeline
  53157. */
  53158. constructor(engine: Engine, name: string);
  53159. /**
  53160. * Gets the class name
  53161. * @returns "PostProcessRenderPipeline"
  53162. */
  53163. getClassName(): string;
  53164. /**
  53165. * If all the render effects in the pipeline are supported
  53166. */
  53167. readonly isSupported: boolean;
  53168. /**
  53169. * Adds an effect to the pipeline
  53170. * @param renderEffect the effect to add
  53171. */
  53172. addEffect(renderEffect: PostProcessRenderEffect): void;
  53173. /** @hidden */
  53174. _rebuild(): void;
  53175. /** @hidden */
  53176. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53177. /** @hidden */
  53178. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53179. /** @hidden */
  53180. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53181. /** @hidden */
  53182. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53183. /** @hidden */
  53184. _attachCameras(cameras: Camera, unique: boolean): void;
  53185. /** @hidden */
  53186. _attachCameras(cameras: Camera[], unique: boolean): void;
  53187. /** @hidden */
  53188. _detachCameras(cameras: Camera): void;
  53189. /** @hidden */
  53190. _detachCameras(cameras: Nullable<Camera[]>): void;
  53191. /** @hidden */
  53192. _update(): void;
  53193. /** @hidden */
  53194. _reset(): void;
  53195. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53196. /**
  53197. * Disposes of the pipeline
  53198. */
  53199. dispose(): void;
  53200. }
  53201. }
  53202. declare module BABYLON {
  53203. /**
  53204. * PostProcessRenderPipelineManager class
  53205. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53206. */
  53207. export class PostProcessRenderPipelineManager {
  53208. private _renderPipelines;
  53209. /**
  53210. * Initializes a PostProcessRenderPipelineManager
  53211. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53212. */
  53213. constructor();
  53214. /**
  53215. * Gets the list of supported render pipelines
  53216. */
  53217. readonly supportedPipelines: PostProcessRenderPipeline[];
  53218. /**
  53219. * Adds a pipeline to the manager
  53220. * @param renderPipeline The pipeline to add
  53221. */
  53222. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53223. /**
  53224. * Attaches a camera to the pipeline
  53225. * @param renderPipelineName The name of the pipeline to attach to
  53226. * @param cameras the camera to attach
  53227. * @param unique if the camera can be attached multiple times to the pipeline
  53228. */
  53229. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53230. /**
  53231. * Detaches a camera from the pipeline
  53232. * @param renderPipelineName The name of the pipeline to detach from
  53233. * @param cameras the camera to detach
  53234. */
  53235. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53236. /**
  53237. * Enables an effect by name on a pipeline
  53238. * @param renderPipelineName the name of the pipeline to enable the effect in
  53239. * @param renderEffectName the name of the effect to enable
  53240. * @param cameras the cameras that the effect should be enabled on
  53241. */
  53242. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53243. /**
  53244. * Disables an effect by name on a pipeline
  53245. * @param renderPipelineName the name of the pipeline to disable the effect in
  53246. * @param renderEffectName the name of the effect to disable
  53247. * @param cameras the cameras that the effect should be disabled on
  53248. */
  53249. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53250. /**
  53251. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53252. */
  53253. update(): void;
  53254. /** @hidden */
  53255. _rebuild(): void;
  53256. /**
  53257. * Disposes of the manager and pipelines
  53258. */
  53259. dispose(): void;
  53260. }
  53261. }
  53262. declare module BABYLON {
  53263. interface Scene {
  53264. /** @hidden (Backing field) */
  53265. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53266. /**
  53267. * Gets the postprocess render pipeline manager
  53268. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53269. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53270. */
  53271. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53272. }
  53273. /**
  53274. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53275. */
  53276. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53277. /**
  53278. * The component name helpfull to identify the component in the list of scene components.
  53279. */
  53280. readonly name: string;
  53281. /**
  53282. * The scene the component belongs to.
  53283. */
  53284. scene: Scene;
  53285. /**
  53286. * Creates a new instance of the component for the given scene
  53287. * @param scene Defines the scene to register the component in
  53288. */
  53289. constructor(scene: Scene);
  53290. /**
  53291. * Registers the component in a given scene
  53292. */
  53293. register(): void;
  53294. /**
  53295. * Rebuilds the elements related to this component in case of
  53296. * context lost for instance.
  53297. */
  53298. rebuild(): void;
  53299. /**
  53300. * Disposes the component and the associated ressources
  53301. */
  53302. dispose(): void;
  53303. private _gatherRenderTargets;
  53304. }
  53305. }
  53306. declare module BABYLON {
  53307. /**
  53308. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53309. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53310. */
  53311. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53312. private _scene;
  53313. private _camerasToBeAttached;
  53314. /**
  53315. * ID of the sharpen post process,
  53316. */
  53317. private readonly SharpenPostProcessId;
  53318. /**
  53319. * @ignore
  53320. * ID of the image processing post process;
  53321. */
  53322. readonly ImageProcessingPostProcessId: string;
  53323. /**
  53324. * @ignore
  53325. * ID of the Fast Approximate Anti-Aliasing post process;
  53326. */
  53327. readonly FxaaPostProcessId: string;
  53328. /**
  53329. * ID of the chromatic aberration post process,
  53330. */
  53331. private readonly ChromaticAberrationPostProcessId;
  53332. /**
  53333. * ID of the grain post process
  53334. */
  53335. private readonly GrainPostProcessId;
  53336. /**
  53337. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53338. */
  53339. sharpen: SharpenPostProcess;
  53340. private _sharpenEffect;
  53341. private bloom;
  53342. /**
  53343. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53344. */
  53345. depthOfField: DepthOfFieldEffect;
  53346. /**
  53347. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53348. */
  53349. fxaa: FxaaPostProcess;
  53350. /**
  53351. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53352. */
  53353. imageProcessing: ImageProcessingPostProcess;
  53354. /**
  53355. * Chromatic aberration post process which will shift rgb colors in the image
  53356. */
  53357. chromaticAberration: ChromaticAberrationPostProcess;
  53358. private _chromaticAberrationEffect;
  53359. /**
  53360. * Grain post process which add noise to the image
  53361. */
  53362. grain: GrainPostProcess;
  53363. private _grainEffect;
  53364. /**
  53365. * Glow post process which adds a glow to emissive areas of the image
  53366. */
  53367. private _glowLayer;
  53368. /**
  53369. * Animations which can be used to tweak settings over a period of time
  53370. */
  53371. animations: Animation[];
  53372. private _imageProcessingConfigurationObserver;
  53373. private _sharpenEnabled;
  53374. private _bloomEnabled;
  53375. private _depthOfFieldEnabled;
  53376. private _depthOfFieldBlurLevel;
  53377. private _fxaaEnabled;
  53378. private _imageProcessingEnabled;
  53379. private _defaultPipelineTextureType;
  53380. private _bloomScale;
  53381. private _chromaticAberrationEnabled;
  53382. private _grainEnabled;
  53383. private _buildAllowed;
  53384. /**
  53385. * Gets active scene
  53386. */
  53387. readonly scene: Scene;
  53388. /**
  53389. * Enable or disable the sharpen process from the pipeline
  53390. */
  53391. sharpenEnabled: boolean;
  53392. private _resizeObserver;
  53393. private _hardwareScaleLevel;
  53394. private _bloomKernel;
  53395. /**
  53396. * Specifies the size of the bloom blur kernel, relative to the final output size
  53397. */
  53398. bloomKernel: number;
  53399. /**
  53400. * Specifies the weight of the bloom in the final rendering
  53401. */
  53402. private _bloomWeight;
  53403. /**
  53404. * Specifies the luma threshold for the area that will be blurred by the bloom
  53405. */
  53406. private _bloomThreshold;
  53407. private _hdr;
  53408. /**
  53409. * The strength of the bloom.
  53410. */
  53411. bloomWeight: number;
  53412. /**
  53413. * The strength of the bloom.
  53414. */
  53415. bloomThreshold: number;
  53416. /**
  53417. * The scale of the bloom, lower value will provide better performance.
  53418. */
  53419. bloomScale: number;
  53420. /**
  53421. * Enable or disable the bloom from the pipeline
  53422. */
  53423. bloomEnabled: boolean;
  53424. private _rebuildBloom;
  53425. /**
  53426. * If the depth of field is enabled.
  53427. */
  53428. depthOfFieldEnabled: boolean;
  53429. /**
  53430. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53431. */
  53432. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53433. /**
  53434. * If the anti aliasing is enabled.
  53435. */
  53436. fxaaEnabled: boolean;
  53437. private _samples;
  53438. /**
  53439. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53440. */
  53441. samples: number;
  53442. /**
  53443. * If image processing is enabled.
  53444. */
  53445. imageProcessingEnabled: boolean;
  53446. /**
  53447. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53448. */
  53449. glowLayerEnabled: boolean;
  53450. /**
  53451. * Enable or disable the chromaticAberration process from the pipeline
  53452. */
  53453. chromaticAberrationEnabled: boolean;
  53454. /**
  53455. * Enable or disable the grain process from the pipeline
  53456. */
  53457. grainEnabled: boolean;
  53458. /**
  53459. * @constructor
  53460. * @param name - The rendering pipeline name (default: "")
  53461. * @param hdr - If high dynamic range textures should be used (default: true)
  53462. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53463. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53464. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53465. */
  53466. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53467. /**
  53468. * Get the class name
  53469. * @returns "DefaultRenderingPipeline"
  53470. */
  53471. getClassName(): string;
  53472. /**
  53473. * Force the compilation of the entire pipeline.
  53474. */
  53475. prepare(): void;
  53476. private _hasCleared;
  53477. private _prevPostProcess;
  53478. private _prevPrevPostProcess;
  53479. private _setAutoClearAndTextureSharing;
  53480. private _depthOfFieldSceneObserver;
  53481. private _buildPipeline;
  53482. private _disposePostProcesses;
  53483. /**
  53484. * Adds a camera to the pipeline
  53485. * @param camera the camera to be added
  53486. */
  53487. addCamera(camera: Camera): void;
  53488. /**
  53489. * Removes a camera from the pipeline
  53490. * @param camera the camera to remove
  53491. */
  53492. removeCamera(camera: Camera): void;
  53493. /**
  53494. * Dispose of the pipeline and stop all post processes
  53495. */
  53496. dispose(): void;
  53497. /**
  53498. * Serialize the rendering pipeline (Used when exporting)
  53499. * @returns the serialized object
  53500. */
  53501. serialize(): any;
  53502. /**
  53503. * Parse the serialized pipeline
  53504. * @param source Source pipeline.
  53505. * @param scene The scene to load the pipeline to.
  53506. * @param rootUrl The URL of the serialized pipeline.
  53507. * @returns An instantiated pipeline from the serialized object.
  53508. */
  53509. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53510. }
  53511. }
  53512. declare module BABYLON {
  53513. /** @hidden */
  53514. export var lensHighlightsPixelShader: {
  53515. name: string;
  53516. shader: string;
  53517. };
  53518. }
  53519. declare module BABYLON {
  53520. /** @hidden */
  53521. export var depthOfFieldPixelShader: {
  53522. name: string;
  53523. shader: string;
  53524. };
  53525. }
  53526. declare module BABYLON {
  53527. /**
  53528. * BABYLON.JS Chromatic Aberration GLSL Shader
  53529. * Author: Olivier Guyot
  53530. * Separates very slightly R, G and B colors on the edges of the screen
  53531. * Inspired by Francois Tarlier & Martins Upitis
  53532. */
  53533. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53534. /**
  53535. * @ignore
  53536. * The chromatic aberration PostProcess id in the pipeline
  53537. */
  53538. LensChromaticAberrationEffect: string;
  53539. /**
  53540. * @ignore
  53541. * The highlights enhancing PostProcess id in the pipeline
  53542. */
  53543. HighlightsEnhancingEffect: string;
  53544. /**
  53545. * @ignore
  53546. * The depth-of-field PostProcess id in the pipeline
  53547. */
  53548. LensDepthOfFieldEffect: string;
  53549. private _scene;
  53550. private _depthTexture;
  53551. private _grainTexture;
  53552. private _chromaticAberrationPostProcess;
  53553. private _highlightsPostProcess;
  53554. private _depthOfFieldPostProcess;
  53555. private _edgeBlur;
  53556. private _grainAmount;
  53557. private _chromaticAberration;
  53558. private _distortion;
  53559. private _highlightsGain;
  53560. private _highlightsThreshold;
  53561. private _dofDistance;
  53562. private _dofAperture;
  53563. private _dofDarken;
  53564. private _dofPentagon;
  53565. private _blurNoise;
  53566. /**
  53567. * @constructor
  53568. *
  53569. * Effect parameters are as follow:
  53570. * {
  53571. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53572. * edge_blur: number; // from 0 to x (1 for realism)
  53573. * distortion: number; // from 0 to x (1 for realism)
  53574. * grain_amount: number; // from 0 to 1
  53575. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53576. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53577. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53578. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53579. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53580. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53581. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53582. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53583. * }
  53584. * Note: if an effect parameter is unset, effect is disabled
  53585. *
  53586. * @param name The rendering pipeline name
  53587. * @param parameters - An object containing all parameters (see above)
  53588. * @param scene The scene linked to this pipeline
  53589. * @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)
  53590. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53591. */
  53592. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53593. /**
  53594. * Get the class name
  53595. * @returns "LensRenderingPipeline"
  53596. */
  53597. getClassName(): string;
  53598. /**
  53599. * Gets associated scene
  53600. */
  53601. readonly scene: Scene;
  53602. /**
  53603. * Gets or sets the edge blur
  53604. */
  53605. edgeBlur: number;
  53606. /**
  53607. * Gets or sets the grain amount
  53608. */
  53609. grainAmount: number;
  53610. /**
  53611. * Gets or sets the chromatic aberration amount
  53612. */
  53613. chromaticAberration: number;
  53614. /**
  53615. * Gets or sets the depth of field aperture
  53616. */
  53617. dofAperture: number;
  53618. /**
  53619. * Gets or sets the edge distortion
  53620. */
  53621. edgeDistortion: number;
  53622. /**
  53623. * Gets or sets the depth of field distortion
  53624. */
  53625. dofDistortion: number;
  53626. /**
  53627. * Gets or sets the darken out of focus amount
  53628. */
  53629. darkenOutOfFocus: number;
  53630. /**
  53631. * Gets or sets a boolean indicating if blur noise is enabled
  53632. */
  53633. blurNoise: boolean;
  53634. /**
  53635. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  53636. */
  53637. pentagonBokeh: boolean;
  53638. /**
  53639. * Gets or sets the highlight grain amount
  53640. */
  53641. highlightsGain: number;
  53642. /**
  53643. * Gets or sets the highlight threshold
  53644. */
  53645. highlightsThreshold: number;
  53646. /**
  53647. * Sets the amount of blur at the edges
  53648. * @param amount blur amount
  53649. */
  53650. setEdgeBlur(amount: number): void;
  53651. /**
  53652. * Sets edge blur to 0
  53653. */
  53654. disableEdgeBlur(): void;
  53655. /**
  53656. * Sets the amout of grain
  53657. * @param amount Amount of grain
  53658. */
  53659. setGrainAmount(amount: number): void;
  53660. /**
  53661. * Set grain amount to 0
  53662. */
  53663. disableGrain(): void;
  53664. /**
  53665. * Sets the chromatic aberration amount
  53666. * @param amount amount of chromatic aberration
  53667. */
  53668. setChromaticAberration(amount: number): void;
  53669. /**
  53670. * Sets chromatic aberration amount to 0
  53671. */
  53672. disableChromaticAberration(): void;
  53673. /**
  53674. * Sets the EdgeDistortion amount
  53675. * @param amount amount of EdgeDistortion
  53676. */
  53677. setEdgeDistortion(amount: number): void;
  53678. /**
  53679. * Sets edge distortion to 0
  53680. */
  53681. disableEdgeDistortion(): void;
  53682. /**
  53683. * Sets the FocusDistance amount
  53684. * @param amount amount of FocusDistance
  53685. */
  53686. setFocusDistance(amount: number): void;
  53687. /**
  53688. * Disables depth of field
  53689. */
  53690. disableDepthOfField(): void;
  53691. /**
  53692. * Sets the Aperture amount
  53693. * @param amount amount of Aperture
  53694. */
  53695. setAperture(amount: number): void;
  53696. /**
  53697. * Sets the DarkenOutOfFocus amount
  53698. * @param amount amount of DarkenOutOfFocus
  53699. */
  53700. setDarkenOutOfFocus(amount: number): void;
  53701. private _pentagonBokehIsEnabled;
  53702. /**
  53703. * Creates a pentagon bokeh effect
  53704. */
  53705. enablePentagonBokeh(): void;
  53706. /**
  53707. * Disables the pentagon bokeh effect
  53708. */
  53709. disablePentagonBokeh(): void;
  53710. /**
  53711. * Enables noise blur
  53712. */
  53713. enableNoiseBlur(): void;
  53714. /**
  53715. * Disables noise blur
  53716. */
  53717. disableNoiseBlur(): void;
  53718. /**
  53719. * Sets the HighlightsGain amount
  53720. * @param amount amount of HighlightsGain
  53721. */
  53722. setHighlightsGain(amount: number): void;
  53723. /**
  53724. * Sets the HighlightsThreshold amount
  53725. * @param amount amount of HighlightsThreshold
  53726. */
  53727. setHighlightsThreshold(amount: number): void;
  53728. /**
  53729. * Disables highlights
  53730. */
  53731. disableHighlights(): void;
  53732. /**
  53733. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53734. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53735. */
  53736. dispose(disableDepthRender?: boolean): void;
  53737. private _createChromaticAberrationPostProcess;
  53738. private _createHighlightsPostProcess;
  53739. private _createDepthOfFieldPostProcess;
  53740. private _createGrainTexture;
  53741. }
  53742. }
  53743. declare module BABYLON {
  53744. /** @hidden */
  53745. export var ssao2PixelShader: {
  53746. name: string;
  53747. shader: string;
  53748. };
  53749. }
  53750. declare module BABYLON {
  53751. /** @hidden */
  53752. export var ssaoCombinePixelShader: {
  53753. name: string;
  53754. shader: string;
  53755. };
  53756. }
  53757. declare module BABYLON {
  53758. /**
  53759. * Render pipeline to produce ssao effect
  53760. */
  53761. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53762. /**
  53763. * @ignore
  53764. * The PassPostProcess id in the pipeline that contains the original scene color
  53765. */
  53766. SSAOOriginalSceneColorEffect: string;
  53767. /**
  53768. * @ignore
  53769. * The SSAO PostProcess id in the pipeline
  53770. */
  53771. SSAORenderEffect: string;
  53772. /**
  53773. * @ignore
  53774. * The horizontal blur PostProcess id in the pipeline
  53775. */
  53776. SSAOBlurHRenderEffect: string;
  53777. /**
  53778. * @ignore
  53779. * The vertical blur PostProcess id in the pipeline
  53780. */
  53781. SSAOBlurVRenderEffect: string;
  53782. /**
  53783. * @ignore
  53784. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53785. */
  53786. SSAOCombineRenderEffect: string;
  53787. /**
  53788. * The output strength of the SSAO post-process. Default value is 1.0.
  53789. */
  53790. totalStrength: number;
  53791. /**
  53792. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53793. */
  53794. maxZ: number;
  53795. /**
  53796. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53797. */
  53798. minZAspect: number;
  53799. private _samples;
  53800. /**
  53801. * Number of samples used for the SSAO calculations. Default value is 8
  53802. */
  53803. samples: number;
  53804. private _textureSamples;
  53805. /**
  53806. * Number of samples to use for antialiasing
  53807. */
  53808. textureSamples: number;
  53809. /**
  53810. * Ratio object used for SSAO ratio and blur ratio
  53811. */
  53812. private _ratio;
  53813. /**
  53814. * Dynamically generated sphere sampler.
  53815. */
  53816. private _sampleSphere;
  53817. /**
  53818. * Blur filter offsets
  53819. */
  53820. private _samplerOffsets;
  53821. private _expensiveBlur;
  53822. /**
  53823. * If bilateral blur should be used
  53824. */
  53825. expensiveBlur: boolean;
  53826. /**
  53827. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53828. */
  53829. radius: number;
  53830. /**
  53831. * The base color of the SSAO post-process
  53832. * The final result is "base + ssao" between [0, 1]
  53833. */
  53834. base: number;
  53835. /**
  53836. * Support test.
  53837. */
  53838. static readonly IsSupported: boolean;
  53839. private _scene;
  53840. private _depthTexture;
  53841. private _normalTexture;
  53842. private _randomTexture;
  53843. private _originalColorPostProcess;
  53844. private _ssaoPostProcess;
  53845. private _blurHPostProcess;
  53846. private _blurVPostProcess;
  53847. private _ssaoCombinePostProcess;
  53848. private _firstUpdate;
  53849. /**
  53850. * Gets active scene
  53851. */
  53852. readonly scene: Scene;
  53853. /**
  53854. * @constructor
  53855. * @param name The rendering pipeline name
  53856. * @param scene The scene linked to this pipeline
  53857. * @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 }
  53858. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53859. */
  53860. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53861. /**
  53862. * Get the class name
  53863. * @returns "SSAO2RenderingPipeline"
  53864. */
  53865. getClassName(): string;
  53866. /**
  53867. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53868. */
  53869. dispose(disableGeometryBufferRenderer?: boolean): void;
  53870. private _createBlurPostProcess;
  53871. /** @hidden */
  53872. _rebuild(): void;
  53873. private _bits;
  53874. private _radicalInverse_VdC;
  53875. private _hammersley;
  53876. private _hemisphereSample_uniform;
  53877. private _generateHemisphere;
  53878. private _createSSAOPostProcess;
  53879. private _createSSAOCombinePostProcess;
  53880. private _createRandomTexture;
  53881. /**
  53882. * Serialize the rendering pipeline (Used when exporting)
  53883. * @returns the serialized object
  53884. */
  53885. serialize(): any;
  53886. /**
  53887. * Parse the serialized pipeline
  53888. * @param source Source pipeline.
  53889. * @param scene The scene to load the pipeline to.
  53890. * @param rootUrl The URL of the serialized pipeline.
  53891. * @returns An instantiated pipeline from the serialized object.
  53892. */
  53893. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53894. }
  53895. }
  53896. declare module BABYLON {
  53897. /** @hidden */
  53898. export var ssaoPixelShader: {
  53899. name: string;
  53900. shader: string;
  53901. };
  53902. }
  53903. declare module BABYLON {
  53904. /**
  53905. * Render pipeline to produce ssao effect
  53906. */
  53907. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53908. /**
  53909. * @ignore
  53910. * The PassPostProcess id in the pipeline that contains the original scene color
  53911. */
  53912. SSAOOriginalSceneColorEffect: string;
  53913. /**
  53914. * @ignore
  53915. * The SSAO PostProcess id in the pipeline
  53916. */
  53917. SSAORenderEffect: string;
  53918. /**
  53919. * @ignore
  53920. * The horizontal blur PostProcess id in the pipeline
  53921. */
  53922. SSAOBlurHRenderEffect: string;
  53923. /**
  53924. * @ignore
  53925. * The vertical blur PostProcess id in the pipeline
  53926. */
  53927. SSAOBlurVRenderEffect: string;
  53928. /**
  53929. * @ignore
  53930. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53931. */
  53932. SSAOCombineRenderEffect: string;
  53933. /**
  53934. * The output strength of the SSAO post-process. Default value is 1.0.
  53935. */
  53936. totalStrength: number;
  53937. /**
  53938. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53939. */
  53940. radius: number;
  53941. /**
  53942. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53943. * Must not be equal to fallOff and superior to fallOff.
  53944. * Default value is 0.0075
  53945. */
  53946. area: number;
  53947. /**
  53948. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53949. * Must not be equal to area and inferior to area.
  53950. * Default value is 0.000001
  53951. */
  53952. fallOff: number;
  53953. /**
  53954. * The base color of the SSAO post-process
  53955. * The final result is "base + ssao" between [0, 1]
  53956. */
  53957. base: number;
  53958. private _scene;
  53959. private _depthTexture;
  53960. private _randomTexture;
  53961. private _originalColorPostProcess;
  53962. private _ssaoPostProcess;
  53963. private _blurHPostProcess;
  53964. private _blurVPostProcess;
  53965. private _ssaoCombinePostProcess;
  53966. private _firstUpdate;
  53967. /**
  53968. * Gets active scene
  53969. */
  53970. readonly scene: Scene;
  53971. /**
  53972. * @constructor
  53973. * @param name - The rendering pipeline name
  53974. * @param scene - The scene linked to this pipeline
  53975. * @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 }
  53976. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53977. */
  53978. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53979. /**
  53980. * Get the class name
  53981. * @returns "SSAORenderingPipeline"
  53982. */
  53983. getClassName(): string;
  53984. /**
  53985. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53986. */
  53987. dispose(disableDepthRender?: boolean): void;
  53988. private _createBlurPostProcess;
  53989. /** @hidden */
  53990. _rebuild(): void;
  53991. private _createSSAOPostProcess;
  53992. private _createSSAOCombinePostProcess;
  53993. private _createRandomTexture;
  53994. }
  53995. }
  53996. declare module BABYLON {
  53997. /** @hidden */
  53998. export var standardPixelShader: {
  53999. name: string;
  54000. shader: string;
  54001. };
  54002. }
  54003. declare module BABYLON {
  54004. /**
  54005. * Standard rendering pipeline
  54006. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54007. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54008. */
  54009. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54010. /**
  54011. * Public members
  54012. */
  54013. /**
  54014. * Post-process which contains the original scene color before the pipeline applies all the effects
  54015. */
  54016. originalPostProcess: Nullable<PostProcess>;
  54017. /**
  54018. * Post-process used to down scale an image x4
  54019. */
  54020. downSampleX4PostProcess: Nullable<PostProcess>;
  54021. /**
  54022. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54023. */
  54024. brightPassPostProcess: Nullable<PostProcess>;
  54025. /**
  54026. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54027. */
  54028. blurHPostProcesses: PostProcess[];
  54029. /**
  54030. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54031. */
  54032. blurVPostProcesses: PostProcess[];
  54033. /**
  54034. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54035. */
  54036. textureAdderPostProcess: Nullable<PostProcess>;
  54037. /**
  54038. * Post-process used to create volumetric lighting effect
  54039. */
  54040. volumetricLightPostProcess: Nullable<PostProcess>;
  54041. /**
  54042. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54043. */
  54044. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54045. /**
  54046. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54047. */
  54048. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54049. /**
  54050. * Post-process used to merge the volumetric light effect and the real scene color
  54051. */
  54052. volumetricLightMergePostProces: Nullable<PostProcess>;
  54053. /**
  54054. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54055. */
  54056. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54057. /**
  54058. * Base post-process used to calculate the average luminance of the final image for HDR
  54059. */
  54060. luminancePostProcess: Nullable<PostProcess>;
  54061. /**
  54062. * Post-processes used to create down sample post-processes in order to get
  54063. * the average luminance of the final image for HDR
  54064. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54065. */
  54066. luminanceDownSamplePostProcesses: PostProcess[];
  54067. /**
  54068. * Post-process used to create a HDR effect (light adaptation)
  54069. */
  54070. hdrPostProcess: Nullable<PostProcess>;
  54071. /**
  54072. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54073. */
  54074. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54075. /**
  54076. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54077. */
  54078. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54079. /**
  54080. * Post-process used to merge the final HDR post-process and the real scene color
  54081. */
  54082. hdrFinalPostProcess: Nullable<PostProcess>;
  54083. /**
  54084. * Post-process used to create a lens flare effect
  54085. */
  54086. lensFlarePostProcess: Nullable<PostProcess>;
  54087. /**
  54088. * Post-process that merges the result of the lens flare post-process and the real scene color
  54089. */
  54090. lensFlareComposePostProcess: Nullable<PostProcess>;
  54091. /**
  54092. * Post-process used to create a motion blur effect
  54093. */
  54094. motionBlurPostProcess: Nullable<PostProcess>;
  54095. /**
  54096. * Post-process used to create a depth of field effect
  54097. */
  54098. depthOfFieldPostProcess: Nullable<PostProcess>;
  54099. /**
  54100. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54101. */
  54102. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54103. /**
  54104. * Represents the brightness threshold in order to configure the illuminated surfaces
  54105. */
  54106. brightThreshold: number;
  54107. /**
  54108. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54109. */
  54110. blurWidth: number;
  54111. /**
  54112. * Sets if the blur for highlighted surfaces must be only horizontal
  54113. */
  54114. horizontalBlur: boolean;
  54115. /**
  54116. * Gets the overall exposure used by the pipeline
  54117. */
  54118. /**
  54119. * Sets the overall exposure used by the pipeline
  54120. */
  54121. exposure: number;
  54122. /**
  54123. * Texture used typically to simulate "dirty" on camera lens
  54124. */
  54125. lensTexture: Nullable<Texture>;
  54126. /**
  54127. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54128. */
  54129. volumetricLightCoefficient: number;
  54130. /**
  54131. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54132. */
  54133. volumetricLightPower: number;
  54134. /**
  54135. * Used the set the blur intensity to smooth the volumetric lights
  54136. */
  54137. volumetricLightBlurScale: number;
  54138. /**
  54139. * Light (spot or directional) used to generate the volumetric lights rays
  54140. * The source light must have a shadow generate so the pipeline can get its
  54141. * depth map
  54142. */
  54143. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54144. /**
  54145. * For eye adaptation, represents the minimum luminance the eye can see
  54146. */
  54147. hdrMinimumLuminance: number;
  54148. /**
  54149. * For eye adaptation, represents the decrease luminance speed
  54150. */
  54151. hdrDecreaseRate: number;
  54152. /**
  54153. * For eye adaptation, represents the increase luminance speed
  54154. */
  54155. hdrIncreaseRate: number;
  54156. /**
  54157. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54158. */
  54159. /**
  54160. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54161. */
  54162. hdrAutoExposure: boolean;
  54163. /**
  54164. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54165. */
  54166. lensColorTexture: Nullable<Texture>;
  54167. /**
  54168. * The overall strengh for the lens flare effect
  54169. */
  54170. lensFlareStrength: number;
  54171. /**
  54172. * Dispersion coefficient for lens flare ghosts
  54173. */
  54174. lensFlareGhostDispersal: number;
  54175. /**
  54176. * Main lens flare halo width
  54177. */
  54178. lensFlareHaloWidth: number;
  54179. /**
  54180. * Based on the lens distortion effect, defines how much the lens flare result
  54181. * is distorted
  54182. */
  54183. lensFlareDistortionStrength: number;
  54184. /**
  54185. * Lens star texture must be used to simulate rays on the flares and is available
  54186. * in the documentation
  54187. */
  54188. lensStarTexture: Nullable<Texture>;
  54189. /**
  54190. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54191. * flare effect by taking account of the dirt texture
  54192. */
  54193. lensFlareDirtTexture: Nullable<Texture>;
  54194. /**
  54195. * Represents the focal length for the depth of field effect
  54196. */
  54197. depthOfFieldDistance: number;
  54198. /**
  54199. * Represents the blur intensity for the blurred part of the depth of field effect
  54200. */
  54201. depthOfFieldBlurWidth: number;
  54202. /**
  54203. * For motion blur, defines how much the image is blurred by the movement
  54204. */
  54205. motionStrength: number;
  54206. /**
  54207. * List of animations for the pipeline (IAnimatable implementation)
  54208. */
  54209. animations: Animation[];
  54210. /**
  54211. * Private members
  54212. */
  54213. private _scene;
  54214. private _currentDepthOfFieldSource;
  54215. private _basePostProcess;
  54216. private _fixedExposure;
  54217. private _currentExposure;
  54218. private _hdrAutoExposure;
  54219. private _hdrCurrentLuminance;
  54220. private _floatTextureType;
  54221. private _ratio;
  54222. private _bloomEnabled;
  54223. private _depthOfFieldEnabled;
  54224. private _vlsEnabled;
  54225. private _lensFlareEnabled;
  54226. private _hdrEnabled;
  54227. private _motionBlurEnabled;
  54228. private _fxaaEnabled;
  54229. private _motionBlurSamples;
  54230. private _volumetricLightStepsCount;
  54231. private _samples;
  54232. /**
  54233. * @ignore
  54234. * Specifies if the bloom pipeline is enabled
  54235. */
  54236. BloomEnabled: boolean;
  54237. /**
  54238. * @ignore
  54239. * Specifies if the depth of field pipeline is enabed
  54240. */
  54241. DepthOfFieldEnabled: boolean;
  54242. /**
  54243. * @ignore
  54244. * Specifies if the lens flare pipeline is enabed
  54245. */
  54246. LensFlareEnabled: boolean;
  54247. /**
  54248. * @ignore
  54249. * Specifies if the HDR pipeline is enabled
  54250. */
  54251. HDREnabled: boolean;
  54252. /**
  54253. * @ignore
  54254. * Specifies if the volumetric lights scattering effect is enabled
  54255. */
  54256. VLSEnabled: boolean;
  54257. /**
  54258. * @ignore
  54259. * Specifies if the motion blur effect is enabled
  54260. */
  54261. MotionBlurEnabled: boolean;
  54262. /**
  54263. * Specifies if anti-aliasing is enabled
  54264. */
  54265. fxaaEnabled: boolean;
  54266. /**
  54267. * Specifies the number of steps used to calculate the volumetric lights
  54268. * Typically in interval [50, 200]
  54269. */
  54270. volumetricLightStepsCount: number;
  54271. /**
  54272. * Specifies the number of samples used for the motion blur effect
  54273. * Typically in interval [16, 64]
  54274. */
  54275. motionBlurSamples: number;
  54276. /**
  54277. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54278. */
  54279. samples: number;
  54280. /**
  54281. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54282. * @constructor
  54283. * @param name The rendering pipeline name
  54284. * @param scene The scene linked to this pipeline
  54285. * @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)
  54286. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54287. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54288. */
  54289. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54290. private _buildPipeline;
  54291. private _createDownSampleX4PostProcess;
  54292. private _createBrightPassPostProcess;
  54293. private _createBlurPostProcesses;
  54294. private _createTextureAdderPostProcess;
  54295. private _createVolumetricLightPostProcess;
  54296. private _createLuminancePostProcesses;
  54297. private _createHdrPostProcess;
  54298. private _createLensFlarePostProcess;
  54299. private _createDepthOfFieldPostProcess;
  54300. private _createMotionBlurPostProcess;
  54301. private _getDepthTexture;
  54302. private _disposePostProcesses;
  54303. /**
  54304. * Dispose of the pipeline and stop all post processes
  54305. */
  54306. dispose(): void;
  54307. /**
  54308. * Serialize the rendering pipeline (Used when exporting)
  54309. * @returns the serialized object
  54310. */
  54311. serialize(): any;
  54312. /**
  54313. * Parse the serialized pipeline
  54314. * @param source Source pipeline.
  54315. * @param scene The scene to load the pipeline to.
  54316. * @param rootUrl The URL of the serialized pipeline.
  54317. * @returns An instantiated pipeline from the serialized object.
  54318. */
  54319. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54320. /**
  54321. * Luminance steps
  54322. */
  54323. static LuminanceSteps: number;
  54324. }
  54325. }
  54326. declare module BABYLON {
  54327. /** @hidden */
  54328. export var tonemapPixelShader: {
  54329. name: string;
  54330. shader: string;
  54331. };
  54332. }
  54333. declare module BABYLON {
  54334. /** Defines operator used for tonemapping */
  54335. export enum TonemappingOperator {
  54336. /** Hable */
  54337. Hable = 0,
  54338. /** Reinhard */
  54339. Reinhard = 1,
  54340. /** HejiDawson */
  54341. HejiDawson = 2,
  54342. /** Photographic */
  54343. Photographic = 3
  54344. }
  54345. /**
  54346. * Defines a post process to apply tone mapping
  54347. */
  54348. export class TonemapPostProcess extends PostProcess {
  54349. private _operator;
  54350. /** Defines the required exposure adjustement */
  54351. exposureAdjustment: number;
  54352. /**
  54353. * Creates a new TonemapPostProcess
  54354. * @param name defines the name of the postprocess
  54355. * @param _operator defines the operator to use
  54356. * @param exposureAdjustment defines the required exposure adjustement
  54357. * @param camera defines the camera to use (can be null)
  54358. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54359. * @param engine defines the hosting engine (can be ignore if camera is set)
  54360. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54361. */
  54362. constructor(name: string, _operator: TonemappingOperator,
  54363. /** Defines the required exposure adjustement */
  54364. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54365. }
  54366. }
  54367. declare module BABYLON {
  54368. /** @hidden */
  54369. export var depthVertexShader: {
  54370. name: string;
  54371. shader: string;
  54372. };
  54373. }
  54374. declare module BABYLON {
  54375. /** @hidden */
  54376. export var volumetricLightScatteringPixelShader: {
  54377. name: string;
  54378. shader: string;
  54379. };
  54380. }
  54381. declare module BABYLON {
  54382. /** @hidden */
  54383. export var volumetricLightScatteringPassPixelShader: {
  54384. name: string;
  54385. shader: string;
  54386. };
  54387. }
  54388. declare module BABYLON {
  54389. /**
  54390. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54391. */
  54392. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54393. private _volumetricLightScatteringPass;
  54394. private _volumetricLightScatteringRTT;
  54395. private _viewPort;
  54396. private _screenCoordinates;
  54397. private _cachedDefines;
  54398. /**
  54399. * If not undefined, the mesh position is computed from the attached node position
  54400. */
  54401. attachedNode: {
  54402. position: Vector3;
  54403. };
  54404. /**
  54405. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54406. */
  54407. customMeshPosition: Vector3;
  54408. /**
  54409. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54410. */
  54411. useCustomMeshPosition: boolean;
  54412. /**
  54413. * If the post-process should inverse the light scattering direction
  54414. */
  54415. invert: boolean;
  54416. /**
  54417. * The internal mesh used by the post-process
  54418. */
  54419. mesh: Mesh;
  54420. /**
  54421. * @hidden
  54422. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54423. */
  54424. useDiffuseColor: boolean;
  54425. /**
  54426. * Array containing the excluded meshes not rendered in the internal pass
  54427. */
  54428. excludedMeshes: AbstractMesh[];
  54429. /**
  54430. * Controls the overall intensity of the post-process
  54431. */
  54432. exposure: number;
  54433. /**
  54434. * Dissipates each sample's contribution in range [0, 1]
  54435. */
  54436. decay: number;
  54437. /**
  54438. * Controls the overall intensity of each sample
  54439. */
  54440. weight: number;
  54441. /**
  54442. * Controls the density of each sample
  54443. */
  54444. density: number;
  54445. /**
  54446. * @constructor
  54447. * @param name The post-process name
  54448. * @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)
  54449. * @param camera The camera that the post-process will be attached to
  54450. * @param mesh The mesh used to create the light scattering
  54451. * @param samples The post-process quality, default 100
  54452. * @param samplingModeThe post-process filtering mode
  54453. * @param engine The babylon engine
  54454. * @param reusable If the post-process is reusable
  54455. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54456. */
  54457. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54458. /**
  54459. * Returns the string "VolumetricLightScatteringPostProcess"
  54460. * @returns "VolumetricLightScatteringPostProcess"
  54461. */
  54462. getClassName(): string;
  54463. private _isReady;
  54464. /**
  54465. * Sets the new light position for light scattering effect
  54466. * @param position The new custom light position
  54467. */
  54468. setCustomMeshPosition(position: Vector3): void;
  54469. /**
  54470. * Returns the light position for light scattering effect
  54471. * @return Vector3 The custom light position
  54472. */
  54473. getCustomMeshPosition(): Vector3;
  54474. /**
  54475. * Disposes the internal assets and detaches the post-process from the camera
  54476. */
  54477. dispose(camera: Camera): void;
  54478. /**
  54479. * Returns the render target texture used by the post-process
  54480. * @return the render target texture used by the post-process
  54481. */
  54482. getPass(): RenderTargetTexture;
  54483. private _meshExcluded;
  54484. private _createPass;
  54485. private _updateMeshScreenCoordinates;
  54486. /**
  54487. * Creates a default mesh for the Volumeric Light Scattering post-process
  54488. * @param name The mesh name
  54489. * @param scene The scene where to create the mesh
  54490. * @return the default mesh
  54491. */
  54492. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54493. }
  54494. }
  54495. declare module BABYLON {
  54496. interface Scene {
  54497. /** @hidden (Backing field) */
  54498. _boundingBoxRenderer: BoundingBoxRenderer;
  54499. /** @hidden (Backing field) */
  54500. _forceShowBoundingBoxes: boolean;
  54501. /**
  54502. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54503. */
  54504. forceShowBoundingBoxes: boolean;
  54505. /**
  54506. * Gets the bounding box renderer associated with the scene
  54507. * @returns a BoundingBoxRenderer
  54508. */
  54509. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54510. }
  54511. interface AbstractMesh {
  54512. /** @hidden (Backing field) */
  54513. _showBoundingBox: boolean;
  54514. /**
  54515. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54516. */
  54517. showBoundingBox: boolean;
  54518. }
  54519. /**
  54520. * Component responsible of rendering the bounding box of the meshes in a scene.
  54521. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54522. */
  54523. export class BoundingBoxRenderer implements ISceneComponent {
  54524. /**
  54525. * The component name helpfull to identify the component in the list of scene components.
  54526. */
  54527. readonly name: string;
  54528. /**
  54529. * The scene the component belongs to.
  54530. */
  54531. scene: Scene;
  54532. /**
  54533. * Color of the bounding box lines placed in front of an object
  54534. */
  54535. frontColor: Color3;
  54536. /**
  54537. * Color of the bounding box lines placed behind an object
  54538. */
  54539. backColor: Color3;
  54540. /**
  54541. * Defines if the renderer should show the back lines or not
  54542. */
  54543. showBackLines: boolean;
  54544. /**
  54545. * @hidden
  54546. */
  54547. renderList: SmartArray<BoundingBox>;
  54548. private _colorShader;
  54549. private _vertexBuffers;
  54550. private _indexBuffer;
  54551. /**
  54552. * Instantiates a new bounding box renderer in a scene.
  54553. * @param scene the scene the renderer renders in
  54554. */
  54555. constructor(scene: Scene);
  54556. /**
  54557. * Registers the component in a given scene
  54558. */
  54559. register(): void;
  54560. private _evaluateSubMesh;
  54561. private _activeMesh;
  54562. private _prepareRessources;
  54563. private _createIndexBuffer;
  54564. /**
  54565. * Rebuilds the elements related to this component in case of
  54566. * context lost for instance.
  54567. */
  54568. rebuild(): void;
  54569. /**
  54570. * @hidden
  54571. */
  54572. reset(): void;
  54573. /**
  54574. * Render the bounding boxes of a specific rendering group
  54575. * @param renderingGroupId defines the rendering group to render
  54576. */
  54577. render(renderingGroupId: number): void;
  54578. /**
  54579. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54580. * @param mesh Define the mesh to render the occlusion bounding box for
  54581. */
  54582. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54583. /**
  54584. * Dispose and release the resources attached to this renderer.
  54585. */
  54586. dispose(): void;
  54587. }
  54588. }
  54589. declare module BABYLON {
  54590. /** @hidden */
  54591. export var depthPixelShader: {
  54592. name: string;
  54593. shader: string;
  54594. };
  54595. }
  54596. declare module BABYLON {
  54597. /**
  54598. * This represents a depth renderer in Babylon.
  54599. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54600. */
  54601. export class DepthRenderer {
  54602. private _scene;
  54603. private _depthMap;
  54604. private _effect;
  54605. private _cachedDefines;
  54606. private _camera;
  54607. /**
  54608. * Specifiess that the depth renderer will only be used within
  54609. * the camera it is created for.
  54610. * This can help forcing its rendering during the camera processing.
  54611. */
  54612. useOnlyInActiveCamera: boolean;
  54613. /** @hidden */
  54614. static _SceneComponentInitialization: (scene: Scene) => void;
  54615. /**
  54616. * Instantiates a depth renderer
  54617. * @param scene The scene the renderer belongs to
  54618. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54619. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54620. */
  54621. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54622. /**
  54623. * Creates the depth rendering effect and checks if the effect is ready.
  54624. * @param subMesh The submesh to be used to render the depth map of
  54625. * @param useInstances If multiple world instances should be used
  54626. * @returns if the depth renderer is ready to render the depth map
  54627. */
  54628. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54629. /**
  54630. * Gets the texture which the depth map will be written to.
  54631. * @returns The depth map texture
  54632. */
  54633. getDepthMap(): RenderTargetTexture;
  54634. /**
  54635. * Disposes of the depth renderer.
  54636. */
  54637. dispose(): void;
  54638. }
  54639. }
  54640. declare module BABYLON {
  54641. interface Scene {
  54642. /** @hidden (Backing field) */
  54643. _depthRenderer: {
  54644. [id: string]: DepthRenderer;
  54645. };
  54646. /**
  54647. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54648. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54649. * @returns the created depth renderer
  54650. */
  54651. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54652. /**
  54653. * Disables a depth renderer for a given camera
  54654. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54655. */
  54656. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54657. }
  54658. /**
  54659. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54660. * in several rendering techniques.
  54661. */
  54662. export class DepthRendererSceneComponent implements ISceneComponent {
  54663. /**
  54664. * The component name helpfull to identify the component in the list of scene components.
  54665. */
  54666. readonly name: string;
  54667. /**
  54668. * The scene the component belongs to.
  54669. */
  54670. scene: Scene;
  54671. /**
  54672. * Creates a new instance of the component for the given scene
  54673. * @param scene Defines the scene to register the component in
  54674. */
  54675. constructor(scene: Scene);
  54676. /**
  54677. * Registers the component in a given scene
  54678. */
  54679. register(): void;
  54680. /**
  54681. * Rebuilds the elements related to this component in case of
  54682. * context lost for instance.
  54683. */
  54684. rebuild(): void;
  54685. /**
  54686. * Disposes the component and the associated ressources
  54687. */
  54688. dispose(): void;
  54689. private _gatherRenderTargets;
  54690. private _gatherActiveCameraRenderTargets;
  54691. }
  54692. }
  54693. declare module BABYLON {
  54694. /** @hidden */
  54695. export var outlinePixelShader: {
  54696. name: string;
  54697. shader: string;
  54698. };
  54699. }
  54700. declare module BABYLON {
  54701. /** @hidden */
  54702. export var outlineVertexShader: {
  54703. name: string;
  54704. shader: string;
  54705. };
  54706. }
  54707. declare module BABYLON {
  54708. interface Scene {
  54709. /** @hidden */
  54710. _outlineRenderer: OutlineRenderer;
  54711. /**
  54712. * Gets the outline renderer associated with the scene
  54713. * @returns a OutlineRenderer
  54714. */
  54715. getOutlineRenderer(): OutlineRenderer;
  54716. }
  54717. interface AbstractMesh {
  54718. /** @hidden (Backing field) */
  54719. _renderOutline: boolean;
  54720. /**
  54721. * Gets or sets a boolean indicating if the outline must be rendered as well
  54722. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54723. */
  54724. renderOutline: boolean;
  54725. /** @hidden (Backing field) */
  54726. _renderOverlay: boolean;
  54727. /**
  54728. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54729. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54730. */
  54731. renderOverlay: boolean;
  54732. }
  54733. /**
  54734. * This class is responsible to draw bothe outline/overlay of meshes.
  54735. * It should not be used directly but through the available method on mesh.
  54736. */
  54737. export class OutlineRenderer implements ISceneComponent {
  54738. /**
  54739. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  54740. */
  54741. private static _StencilReference;
  54742. /**
  54743. * The name of the component. Each component must have a unique name.
  54744. */
  54745. name: string;
  54746. /**
  54747. * The scene the component belongs to.
  54748. */
  54749. scene: Scene;
  54750. /**
  54751. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54752. */
  54753. zOffset: number;
  54754. private _engine;
  54755. private _effect;
  54756. private _cachedDefines;
  54757. private _savedDepthWrite;
  54758. /**
  54759. * Instantiates a new outline renderer. (There could be only one per scene).
  54760. * @param scene Defines the scene it belongs to
  54761. */
  54762. constructor(scene: Scene);
  54763. /**
  54764. * Register the component to one instance of a scene.
  54765. */
  54766. register(): void;
  54767. /**
  54768. * Rebuilds the elements related to this component in case of
  54769. * context lost for instance.
  54770. */
  54771. rebuild(): void;
  54772. /**
  54773. * Disposes the component and the associated ressources.
  54774. */
  54775. dispose(): void;
  54776. /**
  54777. * Renders the outline in the canvas.
  54778. * @param subMesh Defines the sumesh to render
  54779. * @param batch Defines the batch of meshes in case of instances
  54780. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54781. */
  54782. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54783. /**
  54784. * Returns whether or not the outline renderer is ready for a given submesh.
  54785. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54786. * @param subMesh Defines the submesh to check readyness for
  54787. * @param useInstances Defines wheter wee are trying to render instances or not
  54788. * @returns true if ready otherwise false
  54789. */
  54790. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54791. private _beforeRenderingMesh;
  54792. private _afterRenderingMesh;
  54793. }
  54794. }
  54795. declare module BABYLON {
  54796. /**
  54797. * Defines the list of states available for a task inside a AssetsManager
  54798. */
  54799. export enum AssetTaskState {
  54800. /**
  54801. * Initialization
  54802. */
  54803. INIT = 0,
  54804. /**
  54805. * Running
  54806. */
  54807. RUNNING = 1,
  54808. /**
  54809. * Done
  54810. */
  54811. DONE = 2,
  54812. /**
  54813. * Error
  54814. */
  54815. ERROR = 3
  54816. }
  54817. /**
  54818. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54819. */
  54820. export abstract class AbstractAssetTask {
  54821. /**
  54822. * Task name
  54823. */ name: string;
  54824. /**
  54825. * Callback called when the task is successful
  54826. */
  54827. onSuccess: (task: any) => void;
  54828. /**
  54829. * Callback called when the task is not successful
  54830. */
  54831. onError: (task: any, message?: string, exception?: any) => void;
  54832. /**
  54833. * Creates a new AssetsManager
  54834. * @param name defines the name of the task
  54835. */
  54836. constructor(
  54837. /**
  54838. * Task name
  54839. */ name: string);
  54840. private _isCompleted;
  54841. private _taskState;
  54842. private _errorObject;
  54843. /**
  54844. * Get if the task is completed
  54845. */
  54846. readonly isCompleted: boolean;
  54847. /**
  54848. * Gets the current state of the task
  54849. */
  54850. readonly taskState: AssetTaskState;
  54851. /**
  54852. * Gets the current error object (if task is in error)
  54853. */
  54854. readonly errorObject: {
  54855. message?: string;
  54856. exception?: any;
  54857. };
  54858. /**
  54859. * Internal only
  54860. * @hidden
  54861. */
  54862. _setErrorObject(message?: string, exception?: any): void;
  54863. /**
  54864. * Execute the current task
  54865. * @param scene defines the scene where you want your assets to be loaded
  54866. * @param onSuccess is a callback called when the task is successfully executed
  54867. * @param onError is a callback called if an error occurs
  54868. */
  54869. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54870. /**
  54871. * Execute the current task
  54872. * @param scene defines the scene where you want your assets to be loaded
  54873. * @param onSuccess is a callback called when the task is successfully executed
  54874. * @param onError is a callback called if an error occurs
  54875. */
  54876. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54877. /**
  54878. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54879. * This can be used with failed tasks that have the reason for failure fixed.
  54880. */
  54881. reset(): void;
  54882. private onErrorCallback;
  54883. private onDoneCallback;
  54884. }
  54885. /**
  54886. * Define the interface used by progress events raised during assets loading
  54887. */
  54888. export interface IAssetsProgressEvent {
  54889. /**
  54890. * Defines the number of remaining tasks to process
  54891. */
  54892. remainingCount: number;
  54893. /**
  54894. * Defines the total number of tasks
  54895. */
  54896. totalCount: number;
  54897. /**
  54898. * Defines the task that was just processed
  54899. */
  54900. task: AbstractAssetTask;
  54901. }
  54902. /**
  54903. * Class used to share progress information about assets loading
  54904. */
  54905. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54906. /**
  54907. * Defines the number of remaining tasks to process
  54908. */
  54909. remainingCount: number;
  54910. /**
  54911. * Defines the total number of tasks
  54912. */
  54913. totalCount: number;
  54914. /**
  54915. * Defines the task that was just processed
  54916. */
  54917. task: AbstractAssetTask;
  54918. /**
  54919. * Creates a AssetsProgressEvent
  54920. * @param remainingCount defines the number of remaining tasks to process
  54921. * @param totalCount defines the total number of tasks
  54922. * @param task defines the task that was just processed
  54923. */
  54924. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54925. }
  54926. /**
  54927. * Define a task used by AssetsManager to load meshes
  54928. */
  54929. export class MeshAssetTask extends AbstractAssetTask {
  54930. /**
  54931. * Defines the name of the task
  54932. */
  54933. name: string;
  54934. /**
  54935. * Defines the list of mesh's names you want to load
  54936. */
  54937. meshesNames: any;
  54938. /**
  54939. * Defines the root url to use as a base to load your meshes and associated resources
  54940. */
  54941. rootUrl: string;
  54942. /**
  54943. * Defines the filename of the scene to load from
  54944. */
  54945. sceneFilename: string;
  54946. /**
  54947. * Gets the list of loaded meshes
  54948. */
  54949. loadedMeshes: Array<AbstractMesh>;
  54950. /**
  54951. * Gets the list of loaded particle systems
  54952. */
  54953. loadedParticleSystems: Array<IParticleSystem>;
  54954. /**
  54955. * Gets the list of loaded skeletons
  54956. */
  54957. loadedSkeletons: Array<Skeleton>;
  54958. /**
  54959. * Gets the list of loaded animation groups
  54960. */
  54961. loadedAnimationGroups: Array<AnimationGroup>;
  54962. /**
  54963. * Callback called when the task is successful
  54964. */
  54965. onSuccess: (task: MeshAssetTask) => void;
  54966. /**
  54967. * Callback called when the task is successful
  54968. */
  54969. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54970. /**
  54971. * Creates a new MeshAssetTask
  54972. * @param name defines the name of the task
  54973. * @param meshesNames defines the list of mesh's names you want to load
  54974. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54975. * @param sceneFilename defines the filename of the scene to load from
  54976. */
  54977. constructor(
  54978. /**
  54979. * Defines the name of the task
  54980. */
  54981. name: string,
  54982. /**
  54983. * Defines the list of mesh's names you want to load
  54984. */
  54985. meshesNames: any,
  54986. /**
  54987. * Defines the root url to use as a base to load your meshes and associated resources
  54988. */
  54989. rootUrl: string,
  54990. /**
  54991. * Defines the filename of the scene to load from
  54992. */
  54993. sceneFilename: string);
  54994. /**
  54995. * Execute the current task
  54996. * @param scene defines the scene where you want your assets to be loaded
  54997. * @param onSuccess is a callback called when the task is successfully executed
  54998. * @param onError is a callback called if an error occurs
  54999. */
  55000. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55001. }
  55002. /**
  55003. * Define a task used by AssetsManager to load text content
  55004. */
  55005. export class TextFileAssetTask extends AbstractAssetTask {
  55006. /**
  55007. * Defines the name of the task
  55008. */
  55009. name: string;
  55010. /**
  55011. * Defines the location of the file to load
  55012. */
  55013. url: string;
  55014. /**
  55015. * Gets the loaded text string
  55016. */
  55017. text: string;
  55018. /**
  55019. * Callback called when the task is successful
  55020. */
  55021. onSuccess: (task: TextFileAssetTask) => void;
  55022. /**
  55023. * Callback called when the task is successful
  55024. */
  55025. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55026. /**
  55027. * Creates a new TextFileAssetTask object
  55028. * @param name defines the name of the task
  55029. * @param url defines the location of the file to load
  55030. */
  55031. constructor(
  55032. /**
  55033. * Defines the name of the task
  55034. */
  55035. name: string,
  55036. /**
  55037. * Defines the location of the file to load
  55038. */
  55039. url: string);
  55040. /**
  55041. * Execute the current task
  55042. * @param scene defines the scene where you want your assets to be loaded
  55043. * @param onSuccess is a callback called when the task is successfully executed
  55044. * @param onError is a callback called if an error occurs
  55045. */
  55046. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55047. }
  55048. /**
  55049. * Define a task used by AssetsManager to load binary data
  55050. */
  55051. export class BinaryFileAssetTask extends AbstractAssetTask {
  55052. /**
  55053. * Defines the name of the task
  55054. */
  55055. name: string;
  55056. /**
  55057. * Defines the location of the file to load
  55058. */
  55059. url: string;
  55060. /**
  55061. * Gets the lodaded data (as an array buffer)
  55062. */
  55063. data: ArrayBuffer;
  55064. /**
  55065. * Callback called when the task is successful
  55066. */
  55067. onSuccess: (task: BinaryFileAssetTask) => void;
  55068. /**
  55069. * Callback called when the task is successful
  55070. */
  55071. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55072. /**
  55073. * Creates a new BinaryFileAssetTask object
  55074. * @param name defines the name of the new task
  55075. * @param url defines the location of the file to load
  55076. */
  55077. constructor(
  55078. /**
  55079. * Defines the name of the task
  55080. */
  55081. name: string,
  55082. /**
  55083. * Defines the location of the file to load
  55084. */
  55085. url: string);
  55086. /**
  55087. * Execute the current task
  55088. * @param scene defines the scene where you want your assets to be loaded
  55089. * @param onSuccess is a callback called when the task is successfully executed
  55090. * @param onError is a callback called if an error occurs
  55091. */
  55092. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55093. }
  55094. /**
  55095. * Define a task used by AssetsManager to load images
  55096. */
  55097. export class ImageAssetTask extends AbstractAssetTask {
  55098. /**
  55099. * Defines the name of the task
  55100. */
  55101. name: string;
  55102. /**
  55103. * Defines the location of the image to load
  55104. */
  55105. url: string;
  55106. /**
  55107. * Gets the loaded images
  55108. */
  55109. image: HTMLImageElement;
  55110. /**
  55111. * Callback called when the task is successful
  55112. */
  55113. onSuccess: (task: ImageAssetTask) => void;
  55114. /**
  55115. * Callback called when the task is successful
  55116. */
  55117. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55118. /**
  55119. * Creates a new ImageAssetTask
  55120. * @param name defines the name of the task
  55121. * @param url defines the location of the image to load
  55122. */
  55123. constructor(
  55124. /**
  55125. * Defines the name of the task
  55126. */
  55127. name: string,
  55128. /**
  55129. * Defines the location of the image to load
  55130. */
  55131. url: string);
  55132. /**
  55133. * Execute the current task
  55134. * @param scene defines the scene where you want your assets to be loaded
  55135. * @param onSuccess is a callback called when the task is successfully executed
  55136. * @param onError is a callback called if an error occurs
  55137. */
  55138. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55139. }
  55140. /**
  55141. * Defines the interface used by texture loading tasks
  55142. */
  55143. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55144. /**
  55145. * Gets the loaded texture
  55146. */
  55147. texture: TEX;
  55148. }
  55149. /**
  55150. * Define a task used by AssetsManager to load 2D textures
  55151. */
  55152. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55153. /**
  55154. * Defines the name of the task
  55155. */
  55156. name: string;
  55157. /**
  55158. * Defines the location of the file to load
  55159. */
  55160. url: string;
  55161. /**
  55162. * Defines if mipmap should not be generated (default is false)
  55163. */
  55164. noMipmap?: boolean | undefined;
  55165. /**
  55166. * Defines if texture must be inverted on Y axis (default is false)
  55167. */
  55168. invertY?: boolean | undefined;
  55169. /**
  55170. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55171. */
  55172. samplingMode: number;
  55173. /**
  55174. * Gets the loaded texture
  55175. */
  55176. texture: Texture;
  55177. /**
  55178. * Callback called when the task is successful
  55179. */
  55180. onSuccess: (task: TextureAssetTask) => void;
  55181. /**
  55182. * Callback called when the task is successful
  55183. */
  55184. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55185. /**
  55186. * Creates a new TextureAssetTask object
  55187. * @param name defines the name of the task
  55188. * @param url defines the location of the file to load
  55189. * @param noMipmap defines if mipmap should not be generated (default is false)
  55190. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55191. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55192. */
  55193. constructor(
  55194. /**
  55195. * Defines the name of the task
  55196. */
  55197. name: string,
  55198. /**
  55199. * Defines the location of the file to load
  55200. */
  55201. url: string,
  55202. /**
  55203. * Defines if mipmap should not be generated (default is false)
  55204. */
  55205. noMipmap?: boolean | undefined,
  55206. /**
  55207. * Defines if texture must be inverted on Y axis (default is false)
  55208. */
  55209. invertY?: boolean | undefined,
  55210. /**
  55211. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55212. */
  55213. samplingMode?: number);
  55214. /**
  55215. * Execute the current task
  55216. * @param scene defines the scene where you want your assets to be loaded
  55217. * @param onSuccess is a callback called when the task is successfully executed
  55218. * @param onError is a callback called if an error occurs
  55219. */
  55220. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55221. }
  55222. /**
  55223. * Define a task used by AssetsManager to load cube textures
  55224. */
  55225. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55226. /**
  55227. * Defines the name of the task
  55228. */
  55229. name: string;
  55230. /**
  55231. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55232. */
  55233. url: string;
  55234. /**
  55235. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55236. */
  55237. extensions?: string[] | undefined;
  55238. /**
  55239. * Defines if mipmaps should not be generated (default is false)
  55240. */
  55241. noMipmap?: boolean | undefined;
  55242. /**
  55243. * Defines the explicit list of files (undefined by default)
  55244. */
  55245. files?: string[] | undefined;
  55246. /**
  55247. * Gets the loaded texture
  55248. */
  55249. texture: CubeTexture;
  55250. /**
  55251. * Callback called when the task is successful
  55252. */
  55253. onSuccess: (task: CubeTextureAssetTask) => void;
  55254. /**
  55255. * Callback called when the task is successful
  55256. */
  55257. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55258. /**
  55259. * Creates a new CubeTextureAssetTask
  55260. * @param name defines the name of the task
  55261. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55262. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55263. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55264. * @param files defines the explicit list of files (undefined by default)
  55265. */
  55266. constructor(
  55267. /**
  55268. * Defines the name of the task
  55269. */
  55270. name: string,
  55271. /**
  55272. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55273. */
  55274. url: string,
  55275. /**
  55276. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55277. */
  55278. extensions?: string[] | undefined,
  55279. /**
  55280. * Defines if mipmaps should not be generated (default is false)
  55281. */
  55282. noMipmap?: boolean | undefined,
  55283. /**
  55284. * Defines the explicit list of files (undefined by default)
  55285. */
  55286. files?: string[] | undefined);
  55287. /**
  55288. * Execute the current task
  55289. * @param scene defines the scene where you want your assets to be loaded
  55290. * @param onSuccess is a callback called when the task is successfully executed
  55291. * @param onError is a callback called if an error occurs
  55292. */
  55293. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55294. }
  55295. /**
  55296. * Define a task used by AssetsManager to load HDR cube textures
  55297. */
  55298. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55299. /**
  55300. * Defines the name of the task
  55301. */
  55302. name: string;
  55303. /**
  55304. * Defines the location of the file to load
  55305. */
  55306. url: string;
  55307. /**
  55308. * Defines the desired size (the more it increases the longer the generation will be)
  55309. */
  55310. size: number;
  55311. /**
  55312. * Defines if mipmaps should not be generated (default is false)
  55313. */
  55314. noMipmap: boolean;
  55315. /**
  55316. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55317. */
  55318. generateHarmonics: boolean;
  55319. /**
  55320. * 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)
  55321. */
  55322. gammaSpace: boolean;
  55323. /**
  55324. * Internal Use Only
  55325. */
  55326. reserved: boolean;
  55327. /**
  55328. * Gets the loaded texture
  55329. */
  55330. texture: HDRCubeTexture;
  55331. /**
  55332. * Callback called when the task is successful
  55333. */
  55334. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55335. /**
  55336. * Callback called when the task is successful
  55337. */
  55338. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55339. /**
  55340. * Creates a new HDRCubeTextureAssetTask object
  55341. * @param name defines the name of the task
  55342. * @param url defines the location of the file to load
  55343. * @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.
  55344. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55345. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55346. * @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)
  55347. * @param reserved Internal use only
  55348. */
  55349. constructor(
  55350. /**
  55351. * Defines the name of the task
  55352. */
  55353. name: string,
  55354. /**
  55355. * Defines the location of the file to load
  55356. */
  55357. url: string,
  55358. /**
  55359. * Defines the desired size (the more it increases the longer the generation will be)
  55360. */
  55361. size: number,
  55362. /**
  55363. * Defines if mipmaps should not be generated (default is false)
  55364. */
  55365. noMipmap?: boolean,
  55366. /**
  55367. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55368. */
  55369. generateHarmonics?: boolean,
  55370. /**
  55371. * 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)
  55372. */
  55373. gammaSpace?: boolean,
  55374. /**
  55375. * Internal Use Only
  55376. */
  55377. reserved?: boolean);
  55378. /**
  55379. * Execute the current task
  55380. * @param scene defines the scene where you want your assets to be loaded
  55381. * @param onSuccess is a callback called when the task is successfully executed
  55382. * @param onError is a callback called if an error occurs
  55383. */
  55384. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55385. }
  55386. /**
  55387. * Define a task used by AssetsManager to load Equirectangular cube textures
  55388. */
  55389. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  55390. /**
  55391. * Defines the name of the task
  55392. */
  55393. name: string;
  55394. /**
  55395. * Defines the location of the file to load
  55396. */
  55397. url: string;
  55398. /**
  55399. * Defines the desired size (the more it increases the longer the generation will be)
  55400. */
  55401. size: number;
  55402. /**
  55403. * Defines if mipmaps should not be generated (default is false)
  55404. */
  55405. noMipmap: boolean;
  55406. /**
  55407. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55408. * but the standard material would require them in Gamma space) (default is true)
  55409. */
  55410. gammaSpace: boolean;
  55411. /**
  55412. * Gets the loaded texture
  55413. */
  55414. texture: EquiRectangularCubeTexture;
  55415. /**
  55416. * Callback called when the task is successful
  55417. */
  55418. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  55419. /**
  55420. * Callback called when the task is successful
  55421. */
  55422. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  55423. /**
  55424. * Creates a new EquiRectangularCubeTextureAssetTask object
  55425. * @param name defines the name of the task
  55426. * @param url defines the location of the file to load
  55427. * @param size defines the desired size (the more it increases the longer the generation will be)
  55428. * If the size is omitted this implies you are using a preprocessed cubemap.
  55429. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55430. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  55431. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  55432. * (default is true)
  55433. */
  55434. constructor(
  55435. /**
  55436. * Defines the name of the task
  55437. */
  55438. name: string,
  55439. /**
  55440. * Defines the location of the file to load
  55441. */
  55442. url: string,
  55443. /**
  55444. * Defines the desired size (the more it increases the longer the generation will be)
  55445. */
  55446. size: number,
  55447. /**
  55448. * Defines if mipmaps should not be generated (default is false)
  55449. */
  55450. noMipmap?: boolean,
  55451. /**
  55452. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55453. * but the standard material would require them in Gamma space) (default is true)
  55454. */
  55455. gammaSpace?: boolean);
  55456. /**
  55457. * Execute the current task
  55458. * @param scene defines the scene where you want your assets to be loaded
  55459. * @param onSuccess is a callback called when the task is successfully executed
  55460. * @param onError is a callback called if an error occurs
  55461. */
  55462. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55463. }
  55464. /**
  55465. * This class can be used to easily import assets into a scene
  55466. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55467. */
  55468. export class AssetsManager {
  55469. private _scene;
  55470. private _isLoading;
  55471. protected _tasks: AbstractAssetTask[];
  55472. protected _waitingTasksCount: number;
  55473. protected _totalTasksCount: number;
  55474. /**
  55475. * Callback called when all tasks are processed
  55476. */
  55477. onFinish: (tasks: AbstractAssetTask[]) => void;
  55478. /**
  55479. * Callback called when a task is successful
  55480. */
  55481. onTaskSuccess: (task: AbstractAssetTask) => void;
  55482. /**
  55483. * Callback called when a task had an error
  55484. */
  55485. onTaskError: (task: AbstractAssetTask) => void;
  55486. /**
  55487. * Callback called when a task is done (whatever the result is)
  55488. */
  55489. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55490. /**
  55491. * Observable called when all tasks are processed
  55492. */
  55493. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55494. /**
  55495. * Observable called when a task had an error
  55496. */
  55497. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55498. /**
  55499. * Observable called when all tasks were executed
  55500. */
  55501. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55502. /**
  55503. * Observable called when a task is done (whatever the result is)
  55504. */
  55505. onProgressObservable: Observable<IAssetsProgressEvent>;
  55506. /**
  55507. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55508. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55509. */
  55510. useDefaultLoadingScreen: boolean;
  55511. /**
  55512. * Creates a new AssetsManager
  55513. * @param scene defines the scene to work on
  55514. */
  55515. constructor(scene: Scene);
  55516. /**
  55517. * Add a MeshAssetTask to the list of active tasks
  55518. * @param taskName defines the name of the new task
  55519. * @param meshesNames defines the name of meshes to load
  55520. * @param rootUrl defines the root url to use to locate files
  55521. * @param sceneFilename defines the filename of the scene file
  55522. * @returns a new MeshAssetTask object
  55523. */
  55524. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55525. /**
  55526. * Add a TextFileAssetTask to the list of active tasks
  55527. * @param taskName defines the name of the new task
  55528. * @param url defines the url of the file to load
  55529. * @returns a new TextFileAssetTask object
  55530. */
  55531. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55532. /**
  55533. * Add a BinaryFileAssetTask to the list of active tasks
  55534. * @param taskName defines the name of the new task
  55535. * @param url defines the url of the file to load
  55536. * @returns a new BinaryFileAssetTask object
  55537. */
  55538. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55539. /**
  55540. * Add a ImageAssetTask to the list of active tasks
  55541. * @param taskName defines the name of the new task
  55542. * @param url defines the url of the file to load
  55543. * @returns a new ImageAssetTask object
  55544. */
  55545. addImageTask(taskName: string, url: string): ImageAssetTask;
  55546. /**
  55547. * Add a TextureAssetTask to the list of active tasks
  55548. * @param taskName defines the name of the new task
  55549. * @param url defines the url of the file to load
  55550. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55551. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55552. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55553. * @returns a new TextureAssetTask object
  55554. */
  55555. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55556. /**
  55557. * Add a CubeTextureAssetTask to the list of active tasks
  55558. * @param taskName defines the name of the new task
  55559. * @param url defines the url of the file to load
  55560. * @param extensions defines the extension to use to load the cube map (can be null)
  55561. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55562. * @param files defines the list of files to load (can be null)
  55563. * @returns a new CubeTextureAssetTask object
  55564. */
  55565. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55566. /**
  55567. *
  55568. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55569. * @param taskName defines the name of the new task
  55570. * @param url defines the url of the file to load
  55571. * @param size defines the size you want for the cubemap (can be null)
  55572. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55573. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55574. * @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)
  55575. * @param reserved Internal use only
  55576. * @returns a new HDRCubeTextureAssetTask object
  55577. */
  55578. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55579. /**
  55580. *
  55581. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  55582. * @param taskName defines the name of the new task
  55583. * @param url defines the url of the file to load
  55584. * @param size defines the size you want for the cubemap (can be null)
  55585. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55586. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55587. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55588. * @returns a new EquiRectangularCubeTextureAssetTask object
  55589. */
  55590. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  55591. /**
  55592. * Remove a task from the assets manager.
  55593. * @param task the task to remove
  55594. */
  55595. removeTask(task: AbstractAssetTask): void;
  55596. private _decreaseWaitingTasksCount;
  55597. private _runTask;
  55598. /**
  55599. * Reset the AssetsManager and remove all tasks
  55600. * @return the current instance of the AssetsManager
  55601. */
  55602. reset(): AssetsManager;
  55603. /**
  55604. * Start the loading process
  55605. * @return the current instance of the AssetsManager
  55606. */
  55607. load(): AssetsManager;
  55608. /**
  55609. * Start the loading process as an async operation
  55610. * @return a promise returning the list of failed tasks
  55611. */
  55612. loadAsync(): Promise<void>;
  55613. }
  55614. }
  55615. declare module BABYLON {
  55616. /**
  55617. * Wrapper class for promise with external resolve and reject.
  55618. */
  55619. export class Deferred<T> {
  55620. /**
  55621. * The promise associated with this deferred object.
  55622. */
  55623. readonly promise: Promise<T>;
  55624. private _resolve;
  55625. private _reject;
  55626. /**
  55627. * The resolve method of the promise associated with this deferred object.
  55628. */
  55629. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55630. /**
  55631. * The reject method of the promise associated with this deferred object.
  55632. */
  55633. readonly reject: (reason?: any) => void;
  55634. /**
  55635. * Constructor for this deferred object.
  55636. */
  55637. constructor();
  55638. }
  55639. }
  55640. declare module BABYLON {
  55641. /**
  55642. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  55643. */
  55644. export class MeshExploder {
  55645. private _centerMesh;
  55646. private _meshes;
  55647. private _meshesOrigins;
  55648. private _toCenterVectors;
  55649. private _scaledDirection;
  55650. private _newPosition;
  55651. private _centerPosition;
  55652. /**
  55653. * Explodes meshes from a center mesh.
  55654. * @param meshes The meshes to explode.
  55655. * @param centerMesh The mesh to be center of explosion.
  55656. */
  55657. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  55658. private _setCenterMesh;
  55659. /**
  55660. * Get class name
  55661. * @returns "MeshExploder"
  55662. */
  55663. getClassName(): string;
  55664. /**
  55665. * "Exploded meshes"
  55666. * @returns Array of meshes with the centerMesh at index 0.
  55667. */
  55668. getMeshes(): Array<Mesh>;
  55669. /**
  55670. * Explodes meshes giving a specific direction
  55671. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  55672. */
  55673. explode(direction?: number): void;
  55674. }
  55675. }
  55676. declare module BABYLON {
  55677. /**
  55678. * Class used to help managing file picking and drag'n'drop
  55679. */
  55680. export class FilesInput {
  55681. /**
  55682. * List of files ready to be loaded
  55683. */
  55684. static readonly FilesToLoad: {
  55685. [key: string]: File;
  55686. };
  55687. /**
  55688. * Callback called when a file is processed
  55689. */
  55690. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55691. private _engine;
  55692. private _currentScene;
  55693. private _sceneLoadedCallback;
  55694. private _progressCallback;
  55695. private _additionalRenderLoopLogicCallback;
  55696. private _textureLoadingCallback;
  55697. private _startingProcessingFilesCallback;
  55698. private _onReloadCallback;
  55699. private _errorCallback;
  55700. private _elementToMonitor;
  55701. private _sceneFileToLoad;
  55702. private _filesToLoad;
  55703. /**
  55704. * Creates a new FilesInput
  55705. * @param engine defines the rendering engine
  55706. * @param scene defines the hosting scene
  55707. * @param sceneLoadedCallback callback called when scene is loaded
  55708. * @param progressCallback callback called to track progress
  55709. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55710. * @param textureLoadingCallback callback called when a texture is loading
  55711. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55712. * @param onReloadCallback callback called when a reload is requested
  55713. * @param errorCallback callback call if an error occurs
  55714. */
  55715. 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);
  55716. private _dragEnterHandler;
  55717. private _dragOverHandler;
  55718. private _dropHandler;
  55719. /**
  55720. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55721. * @param elementToMonitor defines the DOM element to track
  55722. */
  55723. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55724. /**
  55725. * Release all associated resources
  55726. */
  55727. dispose(): void;
  55728. private renderFunction;
  55729. private drag;
  55730. private drop;
  55731. private _traverseFolder;
  55732. private _processFiles;
  55733. /**
  55734. * Load files from a drop event
  55735. * @param event defines the drop event to use as source
  55736. */
  55737. loadFiles(event: any): void;
  55738. private _processReload;
  55739. /**
  55740. * Reload the current scene from the loaded files
  55741. */
  55742. reload(): void;
  55743. }
  55744. }
  55745. declare module BABYLON {
  55746. /**
  55747. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55748. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55749. */
  55750. export class SceneOptimization {
  55751. /**
  55752. * Defines the priority of this optimization (0 by default which means first in the list)
  55753. */
  55754. priority: number;
  55755. /**
  55756. * Gets a string describing the action executed by the current optimization
  55757. * @returns description string
  55758. */
  55759. getDescription(): string;
  55760. /**
  55761. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55762. * @param scene defines the current scene where to apply this optimization
  55763. * @param optimizer defines the current optimizer
  55764. * @returns true if everything that can be done was applied
  55765. */
  55766. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55767. /**
  55768. * Creates the SceneOptimization object
  55769. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55770. * @param desc defines the description associated with the optimization
  55771. */
  55772. constructor(
  55773. /**
  55774. * Defines the priority of this optimization (0 by default which means first in the list)
  55775. */
  55776. priority?: number);
  55777. }
  55778. /**
  55779. * Defines an optimization used to reduce the size of render target textures
  55780. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55781. */
  55782. export class TextureOptimization extends SceneOptimization {
  55783. /**
  55784. * Defines the priority of this optimization (0 by default which means first in the list)
  55785. */
  55786. priority: number;
  55787. /**
  55788. * 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
  55789. */
  55790. maximumSize: number;
  55791. /**
  55792. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55793. */
  55794. step: number;
  55795. /**
  55796. * Gets a string describing the action executed by the current optimization
  55797. * @returns description string
  55798. */
  55799. getDescription(): string;
  55800. /**
  55801. * Creates the TextureOptimization object
  55802. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55803. * @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
  55804. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55805. */
  55806. constructor(
  55807. /**
  55808. * Defines the priority of this optimization (0 by default which means first in the list)
  55809. */
  55810. priority?: number,
  55811. /**
  55812. * 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
  55813. */
  55814. maximumSize?: number,
  55815. /**
  55816. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55817. */
  55818. step?: number);
  55819. /**
  55820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55821. * @param scene defines the current scene where to apply this optimization
  55822. * @param optimizer defines the current optimizer
  55823. * @returns true if everything that can be done was applied
  55824. */
  55825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55826. }
  55827. /**
  55828. * Defines an optimization used to increase or decrease the rendering resolution
  55829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55830. */
  55831. export class HardwareScalingOptimization extends SceneOptimization {
  55832. /**
  55833. * Defines the priority of this optimization (0 by default which means first in the list)
  55834. */
  55835. priority: number;
  55836. /**
  55837. * Defines the maximum scale to use (2 by default)
  55838. */
  55839. maximumScale: number;
  55840. /**
  55841. * Defines the step to use between two passes (0.5 by default)
  55842. */
  55843. step: number;
  55844. private _currentScale;
  55845. private _directionOffset;
  55846. /**
  55847. * Gets a string describing the action executed by the current optimization
  55848. * @return description string
  55849. */
  55850. getDescription(): string;
  55851. /**
  55852. * Creates the HardwareScalingOptimization object
  55853. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55854. * @param maximumScale defines the maximum scale to use (2 by default)
  55855. * @param step defines the step to use between two passes (0.5 by default)
  55856. */
  55857. constructor(
  55858. /**
  55859. * Defines the priority of this optimization (0 by default which means first in the list)
  55860. */
  55861. priority?: number,
  55862. /**
  55863. * Defines the maximum scale to use (2 by default)
  55864. */
  55865. maximumScale?: number,
  55866. /**
  55867. * Defines the step to use between two passes (0.5 by default)
  55868. */
  55869. step?: number);
  55870. /**
  55871. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55872. * @param scene defines the current scene where to apply this optimization
  55873. * @param optimizer defines the current optimizer
  55874. * @returns true if everything that can be done was applied
  55875. */
  55876. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55877. }
  55878. /**
  55879. * Defines an optimization used to remove shadows
  55880. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55881. */
  55882. export class ShadowsOptimization extends SceneOptimization {
  55883. /**
  55884. * Gets a string describing the action executed by the current optimization
  55885. * @return description string
  55886. */
  55887. getDescription(): string;
  55888. /**
  55889. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55890. * @param scene defines the current scene where to apply this optimization
  55891. * @param optimizer defines the current optimizer
  55892. * @returns true if everything that can be done was applied
  55893. */
  55894. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55895. }
  55896. /**
  55897. * Defines an optimization used to turn post-processes off
  55898. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55899. */
  55900. export class PostProcessesOptimization extends SceneOptimization {
  55901. /**
  55902. * Gets a string describing the action executed by the current optimization
  55903. * @return description string
  55904. */
  55905. getDescription(): string;
  55906. /**
  55907. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55908. * @param scene defines the current scene where to apply this optimization
  55909. * @param optimizer defines the current optimizer
  55910. * @returns true if everything that can be done was applied
  55911. */
  55912. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55913. }
  55914. /**
  55915. * Defines an optimization used to turn lens flares off
  55916. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55917. */
  55918. export class LensFlaresOptimization extends SceneOptimization {
  55919. /**
  55920. * Gets a string describing the action executed by the current optimization
  55921. * @return description string
  55922. */
  55923. getDescription(): string;
  55924. /**
  55925. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55926. * @param scene defines the current scene where to apply this optimization
  55927. * @param optimizer defines the current optimizer
  55928. * @returns true if everything that can be done was applied
  55929. */
  55930. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55931. }
  55932. /**
  55933. * Defines an optimization based on user defined callback.
  55934. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55935. */
  55936. export class CustomOptimization extends SceneOptimization {
  55937. /**
  55938. * Callback called to apply the custom optimization.
  55939. */
  55940. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55941. /**
  55942. * Callback called to get custom description
  55943. */
  55944. onGetDescription: () => string;
  55945. /**
  55946. * Gets a string describing the action executed by the current optimization
  55947. * @returns description string
  55948. */
  55949. getDescription(): string;
  55950. /**
  55951. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55952. * @param scene defines the current scene where to apply this optimization
  55953. * @param optimizer defines the current optimizer
  55954. * @returns true if everything that can be done was applied
  55955. */
  55956. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55957. }
  55958. /**
  55959. * Defines an optimization used to turn particles off
  55960. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55961. */
  55962. export class ParticlesOptimization extends SceneOptimization {
  55963. /**
  55964. * Gets a string describing the action executed by the current optimization
  55965. * @return description string
  55966. */
  55967. getDescription(): string;
  55968. /**
  55969. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55970. * @param scene defines the current scene where to apply this optimization
  55971. * @param optimizer defines the current optimizer
  55972. * @returns true if everything that can be done was applied
  55973. */
  55974. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55975. }
  55976. /**
  55977. * Defines an optimization used to turn render targets off
  55978. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55979. */
  55980. export class RenderTargetsOptimization extends SceneOptimization {
  55981. /**
  55982. * Gets a string describing the action executed by the current optimization
  55983. * @return description string
  55984. */
  55985. getDescription(): string;
  55986. /**
  55987. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55988. * @param scene defines the current scene where to apply this optimization
  55989. * @param optimizer defines the current optimizer
  55990. * @returns true if everything that can be done was applied
  55991. */
  55992. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55993. }
  55994. /**
  55995. * Defines an optimization used to merge meshes with compatible materials
  55996. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55997. */
  55998. export class MergeMeshesOptimization extends SceneOptimization {
  55999. private static _UpdateSelectionTree;
  56000. /**
  56001. * Gets or sets a boolean which defines if optimization octree has to be updated
  56002. */
  56003. /**
  56004. * Gets or sets a boolean which defines if optimization octree has to be updated
  56005. */
  56006. static UpdateSelectionTree: boolean;
  56007. /**
  56008. * Gets a string describing the action executed by the current optimization
  56009. * @return description string
  56010. */
  56011. getDescription(): string;
  56012. private _canBeMerged;
  56013. /**
  56014. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56015. * @param scene defines the current scene where to apply this optimization
  56016. * @param optimizer defines the current optimizer
  56017. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56018. * @returns true if everything that can be done was applied
  56019. */
  56020. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56021. }
  56022. /**
  56023. * Defines a list of options used by SceneOptimizer
  56024. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56025. */
  56026. export class SceneOptimizerOptions {
  56027. /**
  56028. * Defines the target frame rate to reach (60 by default)
  56029. */
  56030. targetFrameRate: number;
  56031. /**
  56032. * Defines the interval between two checkes (2000ms by default)
  56033. */
  56034. trackerDuration: number;
  56035. /**
  56036. * Gets the list of optimizations to apply
  56037. */
  56038. optimizations: SceneOptimization[];
  56039. /**
  56040. * Creates a new list of options used by SceneOptimizer
  56041. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56042. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56043. */
  56044. constructor(
  56045. /**
  56046. * Defines the target frame rate to reach (60 by default)
  56047. */
  56048. targetFrameRate?: number,
  56049. /**
  56050. * Defines the interval between two checkes (2000ms by default)
  56051. */
  56052. trackerDuration?: number);
  56053. /**
  56054. * Add a new optimization
  56055. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56056. * @returns the current SceneOptimizerOptions
  56057. */
  56058. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56059. /**
  56060. * Add a new custom optimization
  56061. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56062. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56063. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56064. * @returns the current SceneOptimizerOptions
  56065. */
  56066. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56067. /**
  56068. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56069. * @param targetFrameRate defines the target frame rate (60 by default)
  56070. * @returns a SceneOptimizerOptions object
  56071. */
  56072. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56073. /**
  56074. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56075. * @param targetFrameRate defines the target frame rate (60 by default)
  56076. * @returns a SceneOptimizerOptions object
  56077. */
  56078. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56079. /**
  56080. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56081. * @param targetFrameRate defines the target frame rate (60 by default)
  56082. * @returns a SceneOptimizerOptions object
  56083. */
  56084. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56085. }
  56086. /**
  56087. * Class used to run optimizations in order to reach a target frame rate
  56088. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56089. */
  56090. export class SceneOptimizer implements IDisposable {
  56091. private _isRunning;
  56092. private _options;
  56093. private _scene;
  56094. private _currentPriorityLevel;
  56095. private _targetFrameRate;
  56096. private _trackerDuration;
  56097. private _currentFrameRate;
  56098. private _sceneDisposeObserver;
  56099. private _improvementMode;
  56100. /**
  56101. * Defines an observable called when the optimizer reaches the target frame rate
  56102. */
  56103. onSuccessObservable: Observable<SceneOptimizer>;
  56104. /**
  56105. * Defines an observable called when the optimizer enables an optimization
  56106. */
  56107. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56108. /**
  56109. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56110. */
  56111. onFailureObservable: Observable<SceneOptimizer>;
  56112. /**
  56113. * Gets a boolean indicating if the optimizer is in improvement mode
  56114. */
  56115. readonly isInImprovementMode: boolean;
  56116. /**
  56117. * Gets the current priority level (0 at start)
  56118. */
  56119. readonly currentPriorityLevel: number;
  56120. /**
  56121. * Gets the current frame rate checked by the SceneOptimizer
  56122. */
  56123. readonly currentFrameRate: number;
  56124. /**
  56125. * Gets or sets the current target frame rate (60 by default)
  56126. */
  56127. /**
  56128. * Gets or sets the current target frame rate (60 by default)
  56129. */
  56130. targetFrameRate: number;
  56131. /**
  56132. * Gets or sets the current interval between two checks (every 2000ms by default)
  56133. */
  56134. /**
  56135. * Gets or sets the current interval between two checks (every 2000ms by default)
  56136. */
  56137. trackerDuration: number;
  56138. /**
  56139. * Gets the list of active optimizations
  56140. */
  56141. readonly optimizations: SceneOptimization[];
  56142. /**
  56143. * Creates a new SceneOptimizer
  56144. * @param scene defines the scene to work on
  56145. * @param options defines the options to use with the SceneOptimizer
  56146. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56147. * @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)
  56148. */
  56149. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56150. /**
  56151. * Stops the current optimizer
  56152. */
  56153. stop(): void;
  56154. /**
  56155. * Reset the optimizer to initial step (current priority level = 0)
  56156. */
  56157. reset(): void;
  56158. /**
  56159. * Start the optimizer. By default it will try to reach a specific framerate
  56160. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56161. */
  56162. start(): void;
  56163. private _checkCurrentState;
  56164. /**
  56165. * Release all resources
  56166. */
  56167. dispose(): void;
  56168. /**
  56169. * Helper function to create a SceneOptimizer with one single line of code
  56170. * @param scene defines the scene to work on
  56171. * @param options defines the options to use with the SceneOptimizer
  56172. * @param onSuccess defines a callback to call on success
  56173. * @param onFailure defines a callback to call on failure
  56174. * @returns the new SceneOptimizer object
  56175. */
  56176. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56177. }
  56178. }
  56179. declare module BABYLON {
  56180. /**
  56181. * Class used to serialize a scene into a string
  56182. */
  56183. export class SceneSerializer {
  56184. /**
  56185. * Clear cache used by a previous serialization
  56186. */
  56187. static ClearCache(): void;
  56188. /**
  56189. * Serialize a scene into a JSON compatible object
  56190. * @param scene defines the scene to serialize
  56191. * @returns a JSON compatible object
  56192. */
  56193. static Serialize(scene: Scene): any;
  56194. /**
  56195. * Serialize a mesh into a JSON compatible object
  56196. * @param toSerialize defines the mesh to serialize
  56197. * @param withParents defines if parents must be serialized as well
  56198. * @param withChildren defines if children must be serialized as well
  56199. * @returns a JSON compatible object
  56200. */
  56201. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56202. }
  56203. }
  56204. declare module BABYLON {
  56205. /**
  56206. * Class used to host texture specific utilities
  56207. */
  56208. export class TextureTools {
  56209. /**
  56210. * Uses the GPU to create a copy texture rescaled at a given size
  56211. * @param texture Texture to copy from
  56212. * @param width defines the desired width
  56213. * @param height defines the desired height
  56214. * @param useBilinearMode defines if bilinear mode has to be used
  56215. * @return the generated texture
  56216. */
  56217. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  56218. }
  56219. }
  56220. declare module BABYLON {
  56221. /**
  56222. * This represents the different options avilable for the video capture.
  56223. */
  56224. export interface VideoRecorderOptions {
  56225. /** Defines the mime type of the video */
  56226. mimeType: string;
  56227. /** Defines the video the video should be recorded at */
  56228. fps: number;
  56229. /** Defines the chunk size for the recording data */
  56230. recordChunckSize: number;
  56231. /** The audio tracks to attach to the record */
  56232. audioTracks?: MediaStreamTrack[];
  56233. }
  56234. /**
  56235. * This can helps recording videos from BabylonJS.
  56236. * This is based on the available WebRTC functionalities of the browser.
  56237. *
  56238. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56239. */
  56240. export class VideoRecorder {
  56241. private static readonly _defaultOptions;
  56242. /**
  56243. * Returns wehther or not the VideoRecorder is available in your browser.
  56244. * @param engine Defines the Babylon Engine to check the support for
  56245. * @returns true if supported otherwise false
  56246. */
  56247. static IsSupported(engine: Engine): boolean;
  56248. private readonly _options;
  56249. private _canvas;
  56250. private _mediaRecorder;
  56251. private _recordedChunks;
  56252. private _fileName;
  56253. private _resolve;
  56254. private _reject;
  56255. /**
  56256. * True wether a recording is already in progress.
  56257. */
  56258. readonly isRecording: boolean;
  56259. /**
  56260. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56261. * a video file.
  56262. * @param engine Defines the BabylonJS Engine you wish to record
  56263. * @param options Defines options that can be used to customized the capture
  56264. */
  56265. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56266. /**
  56267. * Stops the current recording before the default capture timeout passed in the startRecording
  56268. * functions.
  56269. */
  56270. stopRecording(): void;
  56271. /**
  56272. * Starts recording the canvas for a max duration specified in parameters.
  56273. * @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.
  56274. * @param maxDuration Defines the maximum recording time in seconds.
  56275. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56276. * @return a promise callback at the end of the recording with the video data in Blob.
  56277. */
  56278. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56279. /**
  56280. * Releases internal resources used during the recording.
  56281. */
  56282. dispose(): void;
  56283. private _handleDataAvailable;
  56284. private _handleError;
  56285. private _handleStop;
  56286. }
  56287. }
  56288. declare module BABYLON {
  56289. /**
  56290. * Class containing a set of static utilities functions for screenshots
  56291. */
  56292. export class ScreenshotTools {
  56293. /**
  56294. * Captures a screenshot of the current rendering
  56295. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56296. * @param engine defines the rendering engine
  56297. * @param camera defines the source camera
  56298. * @param size This parameter can be set to a single number or to an object with the
  56299. * following (optional) properties: precision, width, height. If a single number is passed,
  56300. * it will be used for both width and height. If an object is passed, the screenshot size
  56301. * will be derived from the parameters. The precision property is a multiplier allowing
  56302. * rendering at a higher or lower resolution
  56303. * @param successCallback defines the callback receives a single parameter which contains the
  56304. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56305. * src parameter of an <img> to display it
  56306. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56307. * Check your browser for supported MIME types
  56308. */
  56309. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56310. /**
  56311. * Generates an image screenshot from the specified camera.
  56312. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56313. * @param engine The engine to use for rendering
  56314. * @param camera The camera to use for rendering
  56315. * @param size This parameter can be set to a single number or to an object with the
  56316. * following (optional) properties: precision, width, height. If a single number is passed,
  56317. * it will be used for both width and height. If an object is passed, the screenshot size
  56318. * will be derived from the parameters. The precision property is a multiplier allowing
  56319. * rendering at a higher or lower resolution
  56320. * @param successCallback The callback receives a single parameter which contains the
  56321. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56322. * src parameter of an <img> to display it
  56323. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56324. * Check your browser for supported MIME types
  56325. * @param samples Texture samples (default: 1)
  56326. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56327. * @param fileName A name for for the downloaded file.
  56328. */
  56329. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56330. }
  56331. }
  56332. declare module BABYLON {
  56333. /**
  56334. * A cursor which tracks a point on a path
  56335. */
  56336. export class PathCursor {
  56337. private path;
  56338. /**
  56339. * Stores path cursor callbacks for when an onchange event is triggered
  56340. */
  56341. private _onchange;
  56342. /**
  56343. * The value of the path cursor
  56344. */
  56345. value: number;
  56346. /**
  56347. * The animation array of the path cursor
  56348. */
  56349. animations: Animation[];
  56350. /**
  56351. * Initializes the path cursor
  56352. * @param path The path to track
  56353. */
  56354. constructor(path: Path2);
  56355. /**
  56356. * Gets the cursor point on the path
  56357. * @returns A point on the path cursor at the cursor location
  56358. */
  56359. getPoint(): Vector3;
  56360. /**
  56361. * Moves the cursor ahead by the step amount
  56362. * @param step The amount to move the cursor forward
  56363. * @returns This path cursor
  56364. */
  56365. moveAhead(step?: number): PathCursor;
  56366. /**
  56367. * Moves the cursor behind by the step amount
  56368. * @param step The amount to move the cursor back
  56369. * @returns This path cursor
  56370. */
  56371. moveBack(step?: number): PathCursor;
  56372. /**
  56373. * Moves the cursor by the step amount
  56374. * If the step amount is greater than one, an exception is thrown
  56375. * @param step The amount to move the cursor
  56376. * @returns This path cursor
  56377. */
  56378. move(step: number): PathCursor;
  56379. /**
  56380. * Ensures that the value is limited between zero and one
  56381. * @returns This path cursor
  56382. */
  56383. private ensureLimits;
  56384. /**
  56385. * Runs onchange callbacks on change (used by the animation engine)
  56386. * @returns This path cursor
  56387. */
  56388. private raiseOnChange;
  56389. /**
  56390. * Executes a function on change
  56391. * @param f A path cursor onchange callback
  56392. * @returns This path cursor
  56393. */
  56394. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56395. }
  56396. }
  56397. declare module BABYLON {
  56398. /** @hidden */
  56399. export var blurPixelShader: {
  56400. name: string;
  56401. shader: string;
  56402. };
  56403. }
  56404. declare module BABYLON {
  56405. /** @hidden */
  56406. export var bones300Declaration: {
  56407. name: string;
  56408. shader: string;
  56409. };
  56410. }
  56411. declare module BABYLON {
  56412. /** @hidden */
  56413. export var instances300Declaration: {
  56414. name: string;
  56415. shader: string;
  56416. };
  56417. }
  56418. declare module BABYLON {
  56419. /** @hidden */
  56420. export var pointCloudVertexDeclaration: {
  56421. name: string;
  56422. shader: string;
  56423. };
  56424. }
  56425. // Mixins
  56426. interface Window {
  56427. mozIndexedDB: IDBFactory;
  56428. webkitIndexedDB: IDBFactory;
  56429. msIndexedDB: IDBFactory;
  56430. webkitURL: typeof URL;
  56431. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56432. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56433. WebGLRenderingContext: WebGLRenderingContext;
  56434. MSGesture: MSGesture;
  56435. CANNON: any;
  56436. AudioContext: AudioContext;
  56437. webkitAudioContext: AudioContext;
  56438. PointerEvent: any;
  56439. Math: Math;
  56440. Uint8Array: Uint8ArrayConstructor;
  56441. Float32Array: Float32ArrayConstructor;
  56442. mozURL: typeof URL;
  56443. msURL: typeof URL;
  56444. VRFrameData: any; // WebVR, from specs 1.1
  56445. DracoDecoderModule: any;
  56446. setImmediate(handler: (...args: any[]) => void): number;
  56447. }
  56448. interface HTMLCanvasElement {
  56449. requestPointerLock(): void;
  56450. msRequestPointerLock?(): void;
  56451. mozRequestPointerLock?(): void;
  56452. webkitRequestPointerLock?(): void;
  56453. /** Track wether a record is in progress */
  56454. isRecording: boolean;
  56455. /** Capture Stream method defined by some browsers */
  56456. captureStream(fps?: number): MediaStream;
  56457. }
  56458. interface CanvasRenderingContext2D {
  56459. msImageSmoothingEnabled: boolean;
  56460. }
  56461. interface MouseEvent {
  56462. mozMovementX: number;
  56463. mozMovementY: number;
  56464. webkitMovementX: number;
  56465. webkitMovementY: number;
  56466. msMovementX: number;
  56467. msMovementY: number;
  56468. }
  56469. interface Navigator {
  56470. mozGetVRDevices: (any: any) => any;
  56471. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56472. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56473. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56474. webkitGetGamepads(): Gamepad[];
  56475. msGetGamepads(): Gamepad[];
  56476. webkitGamepads(): Gamepad[];
  56477. }
  56478. interface HTMLVideoElement {
  56479. mozSrcObject: any;
  56480. }
  56481. interface Math {
  56482. fround(x: number): number;
  56483. imul(a: number, b: number): number;
  56484. }
  56485. interface WebGLRenderingContext {
  56486. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56487. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56488. vertexAttribDivisor(index: number, divisor: number): void;
  56489. createVertexArray(): any;
  56490. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56491. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56492. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56493. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56494. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56495. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56496. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56497. // Queries
  56498. createQuery(): WebGLQuery;
  56499. deleteQuery(query: WebGLQuery): void;
  56500. beginQuery(target: number, query: WebGLQuery): void;
  56501. endQuery(target: number): void;
  56502. getQueryParameter(query: WebGLQuery, pname: number): any;
  56503. getQuery(target: number, pname: number): any;
  56504. MAX_SAMPLES: number;
  56505. RGBA8: number;
  56506. READ_FRAMEBUFFER: number;
  56507. DRAW_FRAMEBUFFER: number;
  56508. UNIFORM_BUFFER: number;
  56509. HALF_FLOAT_OES: number;
  56510. RGBA16F: number;
  56511. RGBA32F: number;
  56512. R32F: number;
  56513. RG32F: number;
  56514. RGB32F: number;
  56515. R16F: number;
  56516. RG16F: number;
  56517. RGB16F: number;
  56518. RED: number;
  56519. RG: number;
  56520. R8: number;
  56521. RG8: number;
  56522. UNSIGNED_INT_24_8: number;
  56523. DEPTH24_STENCIL8: number;
  56524. /* Multiple Render Targets */
  56525. drawBuffers(buffers: number[]): void;
  56526. readBuffer(src: number): void;
  56527. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56528. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56529. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56530. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56531. // Occlusion Query
  56532. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56533. ANY_SAMPLES_PASSED: number;
  56534. QUERY_RESULT_AVAILABLE: number;
  56535. QUERY_RESULT: number;
  56536. }
  56537. interface WebGLProgram {
  56538. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56539. }
  56540. interface EXT_disjoint_timer_query {
  56541. QUERY_COUNTER_BITS_EXT: number;
  56542. TIME_ELAPSED_EXT: number;
  56543. TIMESTAMP_EXT: number;
  56544. GPU_DISJOINT_EXT: number;
  56545. QUERY_RESULT_EXT: number;
  56546. QUERY_RESULT_AVAILABLE_EXT: number;
  56547. queryCounterEXT(query: WebGLQuery, target: number): void;
  56548. createQueryEXT(): WebGLQuery;
  56549. beginQueryEXT(target: number, query: WebGLQuery): void;
  56550. endQueryEXT(target: number): void;
  56551. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56552. deleteQueryEXT(query: WebGLQuery): void;
  56553. }
  56554. interface WebGLUniformLocation {
  56555. _currentState: any;
  56556. }
  56557. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56558. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56559. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56560. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56561. interface WebGLRenderingContext {
  56562. readonly RASTERIZER_DISCARD: number;
  56563. readonly DEPTH_COMPONENT24: number;
  56564. readonly TEXTURE_3D: number;
  56565. readonly TEXTURE_2D_ARRAY: number;
  56566. readonly TEXTURE_COMPARE_FUNC: number;
  56567. readonly TEXTURE_COMPARE_MODE: number;
  56568. readonly COMPARE_REF_TO_TEXTURE: number;
  56569. readonly TEXTURE_WRAP_R: number;
  56570. readonly HALF_FLOAT: number;
  56571. readonly RGB8: number;
  56572. readonly RED_INTEGER: number;
  56573. readonly RG_INTEGER: number;
  56574. readonly RGB_INTEGER: number;
  56575. readonly RGBA_INTEGER: number;
  56576. readonly R8_SNORM: number;
  56577. readonly RG8_SNORM: number;
  56578. readonly RGB8_SNORM: number;
  56579. readonly RGBA8_SNORM: number;
  56580. readonly R8I: number;
  56581. readonly RG8I: number;
  56582. readonly RGB8I: number;
  56583. readonly RGBA8I: number;
  56584. readonly R8UI: number;
  56585. readonly RG8UI: number;
  56586. readonly RGB8UI: number;
  56587. readonly RGBA8UI: number;
  56588. readonly R16I: number;
  56589. readonly RG16I: number;
  56590. readonly RGB16I: number;
  56591. readonly RGBA16I: number;
  56592. readonly R16UI: number;
  56593. readonly RG16UI: number;
  56594. readonly RGB16UI: number;
  56595. readonly RGBA16UI: number;
  56596. readonly R32I: number;
  56597. readonly RG32I: number;
  56598. readonly RGB32I: number;
  56599. readonly RGBA32I: number;
  56600. readonly R32UI: number;
  56601. readonly RG32UI: number;
  56602. readonly RGB32UI: number;
  56603. readonly RGBA32UI: number;
  56604. readonly RGB10_A2UI: number;
  56605. readonly R11F_G11F_B10F: number;
  56606. readonly RGB9_E5: number;
  56607. readonly RGB10_A2: number;
  56608. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56609. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56610. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56611. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56612. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56613. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56614. 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;
  56615. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56616. readonly TRANSFORM_FEEDBACK: number;
  56617. readonly INTERLEAVED_ATTRIBS: number;
  56618. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56619. createTransformFeedback(): WebGLTransformFeedback;
  56620. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56621. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56622. beginTransformFeedback(primitiveMode: number): void;
  56623. endTransformFeedback(): void;
  56624. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56625. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56626. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56627. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56628. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56629. }
  56630. interface ImageBitmap {
  56631. readonly width: number;
  56632. readonly height: number;
  56633. close(): void;
  56634. }
  56635. interface WebGLQuery extends WebGLObject {
  56636. }
  56637. declare var WebGLQuery: {
  56638. prototype: WebGLQuery;
  56639. new(): WebGLQuery;
  56640. };
  56641. interface WebGLSampler extends WebGLObject {
  56642. }
  56643. declare var WebGLSampler: {
  56644. prototype: WebGLSampler;
  56645. new(): WebGLSampler;
  56646. };
  56647. interface WebGLSync extends WebGLObject {
  56648. }
  56649. declare var WebGLSync: {
  56650. prototype: WebGLSync;
  56651. new(): WebGLSync;
  56652. };
  56653. interface WebGLTransformFeedback extends WebGLObject {
  56654. }
  56655. declare var WebGLTransformFeedback: {
  56656. prototype: WebGLTransformFeedback;
  56657. new(): WebGLTransformFeedback;
  56658. };
  56659. interface WebGLVertexArrayObject extends WebGLObject {
  56660. }
  56661. declare var WebGLVertexArrayObject: {
  56662. prototype: WebGLVertexArrayObject;
  56663. new(): WebGLVertexArrayObject;
  56664. };
  56665. // Type definitions for WebVR API
  56666. // Project: https://w3c.github.io/webvr/
  56667. // Definitions by: six a <https://github.com/lostfictions>
  56668. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56669. interface VRDisplay extends EventTarget {
  56670. /**
  56671. * Dictionary of capabilities describing the VRDisplay.
  56672. */
  56673. readonly capabilities: VRDisplayCapabilities;
  56674. /**
  56675. * z-depth defining the far plane of the eye view frustum
  56676. * enables mapping of values in the render target depth
  56677. * attachment to scene coordinates. Initially set to 10000.0.
  56678. */
  56679. depthFar: number;
  56680. /**
  56681. * z-depth defining the near plane of the eye view frustum
  56682. * enables mapping of values in the render target depth
  56683. * attachment to scene coordinates. Initially set to 0.01.
  56684. */
  56685. depthNear: number;
  56686. /**
  56687. * An identifier for this distinct VRDisplay. Used as an
  56688. * association point in the Gamepad API.
  56689. */
  56690. readonly displayId: number;
  56691. /**
  56692. * A display name, a user-readable name identifying it.
  56693. */
  56694. readonly displayName: string;
  56695. readonly isConnected: boolean;
  56696. readonly isPresenting: boolean;
  56697. /**
  56698. * If this VRDisplay supports room-scale experiences, the optional
  56699. * stage attribute contains details on the room-scale parameters.
  56700. */
  56701. readonly stageParameters: VRStageParameters | null;
  56702. /**
  56703. * Passing the value returned by `requestAnimationFrame` to
  56704. * `cancelAnimationFrame` will unregister the callback.
  56705. * @param handle Define the hanle of the request to cancel
  56706. */
  56707. cancelAnimationFrame(handle: number): void;
  56708. /**
  56709. * Stops presenting to the VRDisplay.
  56710. * @returns a promise to know when it stopped
  56711. */
  56712. exitPresent(): Promise<void>;
  56713. /**
  56714. * Return the current VREyeParameters for the given eye.
  56715. * @param whichEye Define the eye we want the parameter for
  56716. * @returns the eye parameters
  56717. */
  56718. getEyeParameters(whichEye: string): VREyeParameters;
  56719. /**
  56720. * Populates the passed VRFrameData with the information required to render
  56721. * the current frame.
  56722. * @param frameData Define the data structure to populate
  56723. * @returns true if ok otherwise false
  56724. */
  56725. getFrameData(frameData: VRFrameData): boolean;
  56726. /**
  56727. * Get the layers currently being presented.
  56728. * @returns the list of VR layers
  56729. */
  56730. getLayers(): VRLayer[];
  56731. /**
  56732. * Return a VRPose containing the future predicted pose of the VRDisplay
  56733. * when the current frame will be presented. The value returned will not
  56734. * change until JavaScript has returned control to the browser.
  56735. *
  56736. * The VRPose will contain the position, orientation, velocity,
  56737. * and acceleration of each of these properties.
  56738. * @returns the pose object
  56739. */
  56740. getPose(): VRPose;
  56741. /**
  56742. * Return the current instantaneous pose of the VRDisplay, with no
  56743. * prediction applied.
  56744. * @returns the current instantaneous pose
  56745. */
  56746. getImmediatePose(): VRPose;
  56747. /**
  56748. * The callback passed to `requestAnimationFrame` will be called
  56749. * any time a new frame should be rendered. When the VRDisplay is
  56750. * presenting the callback will be called at the native refresh
  56751. * rate of the HMD. When not presenting this function acts
  56752. * identically to how window.requestAnimationFrame acts. Content should
  56753. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56754. * asynchronously from other displays and at differing refresh rates.
  56755. * @param callback Define the eaction to run next frame
  56756. * @returns the request handle it
  56757. */
  56758. requestAnimationFrame(callback: FrameRequestCallback): number;
  56759. /**
  56760. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56761. * Repeat calls while already presenting will update the VRLayers being displayed.
  56762. * @param layers Define the list of layer to present
  56763. * @returns a promise to know when the request has been fulfilled
  56764. */
  56765. requestPresent(layers: VRLayer[]): Promise<void>;
  56766. /**
  56767. * Reset the pose for this display, treating its current position and
  56768. * orientation as the "origin/zero" values. VRPose.position,
  56769. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56770. * updated when calling resetPose(). This should be called in only
  56771. * sitting-space experiences.
  56772. */
  56773. resetPose(): void;
  56774. /**
  56775. * The VRLayer provided to the VRDisplay will be captured and presented
  56776. * in the HMD. Calling this function has the same effect on the source
  56777. * canvas as any other operation that uses its source image, and canvases
  56778. * created without preserveDrawingBuffer set to true will be cleared.
  56779. * @param pose Define the pose to submit
  56780. */
  56781. submitFrame(pose?: VRPose): void;
  56782. }
  56783. declare var VRDisplay: {
  56784. prototype: VRDisplay;
  56785. new(): VRDisplay;
  56786. };
  56787. interface VRLayer {
  56788. leftBounds?: number[] | Float32Array | null;
  56789. rightBounds?: number[] | Float32Array | null;
  56790. source?: HTMLCanvasElement | null;
  56791. }
  56792. interface VRDisplayCapabilities {
  56793. readonly canPresent: boolean;
  56794. readonly hasExternalDisplay: boolean;
  56795. readonly hasOrientation: boolean;
  56796. readonly hasPosition: boolean;
  56797. readonly maxLayers: number;
  56798. }
  56799. interface VREyeParameters {
  56800. /** @deprecated */
  56801. readonly fieldOfView: VRFieldOfView;
  56802. readonly offset: Float32Array;
  56803. readonly renderHeight: number;
  56804. readonly renderWidth: number;
  56805. }
  56806. interface VRFieldOfView {
  56807. readonly downDegrees: number;
  56808. readonly leftDegrees: number;
  56809. readonly rightDegrees: number;
  56810. readonly upDegrees: number;
  56811. }
  56812. interface VRFrameData {
  56813. readonly leftProjectionMatrix: Float32Array;
  56814. readonly leftViewMatrix: Float32Array;
  56815. readonly pose: VRPose;
  56816. readonly rightProjectionMatrix: Float32Array;
  56817. readonly rightViewMatrix: Float32Array;
  56818. readonly timestamp: number;
  56819. }
  56820. interface VRPose {
  56821. readonly angularAcceleration: Float32Array | null;
  56822. readonly angularVelocity: Float32Array | null;
  56823. readonly linearAcceleration: Float32Array | null;
  56824. readonly linearVelocity: Float32Array | null;
  56825. readonly orientation: Float32Array | null;
  56826. readonly position: Float32Array | null;
  56827. readonly timestamp: number;
  56828. }
  56829. interface VRStageParameters {
  56830. sittingToStandingTransform?: Float32Array;
  56831. sizeX?: number;
  56832. sizeY?: number;
  56833. }
  56834. interface Navigator {
  56835. getVRDisplays(): Promise<VRDisplay[]>;
  56836. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56837. }
  56838. interface Window {
  56839. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56840. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56841. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56842. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56843. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56844. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56845. }
  56846. interface Gamepad {
  56847. readonly displayId: number;
  56848. }
  56849. interface XRDevice {
  56850. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56851. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56852. }
  56853. interface XRSession {
  56854. getInputSources(): Array<any>;
  56855. baseLayer: XRWebGLLayer;
  56856. requestFrameOfReference(type: string): Promise<void>;
  56857. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56858. end(): Promise<void>;
  56859. requestAnimationFrame: Function;
  56860. addEventListener: Function;
  56861. }
  56862. interface XRSessionCreationOptions {
  56863. outputContext?: WebGLRenderingContext | null;
  56864. immersive?: boolean;
  56865. environmentIntegration?: boolean;
  56866. }
  56867. interface XRLayer {
  56868. getViewport: Function;
  56869. framebufferWidth: number;
  56870. framebufferHeight: number;
  56871. }
  56872. interface XRView {
  56873. projectionMatrix: Float32Array;
  56874. }
  56875. interface XRFrame {
  56876. getDevicePose: Function;
  56877. getInputPose: Function;
  56878. views: Array<XRView>;
  56879. baseLayer: XRLayer;
  56880. }
  56881. interface XRFrameOfReference {
  56882. }
  56883. interface XRWebGLLayer extends XRLayer {
  56884. framebuffer: WebGLFramebuffer;
  56885. }
  56886. declare var XRWebGLLayer: {
  56887. prototype: XRWebGLLayer;
  56888. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56889. };