babylon.d.ts 2.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. export const Epsilon = 0.001;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Vector3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */
  1821. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1822. /**
  1823. * Unproject from screen space to object space
  1824. * @param source defines the screen space Vector3 to use
  1825. * @param viewportWidth defines the current width of the viewport
  1826. * @param viewportHeight defines the current height of the viewport
  1827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1828. * @param transform defines the transform (view x projection) matrix to use
  1829. * @returns the new Vector3
  1830. */
  1831. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1832. /**
  1833. * Unproject from screen space to object space
  1834. * @param source defines the screen space Vector3 to use
  1835. * @param viewportWidth defines the current width of the viewport
  1836. * @param viewportHeight defines the current height of the viewport
  1837. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1838. * @param view defines the view matrix to use
  1839. * @param projection defines the projection matrix to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1843. /**
  1844. * Unproject from screen space to object space
  1845. * @param source defines the screen space Vector3 to use
  1846. * @param viewportWidth defines the current width of the viewport
  1847. * @param viewportHeight defines the current height of the viewport
  1848. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1849. * @param view defines the view matrix to use
  1850. * @param projection defines the projection matrix to use
  1851. * @param result defines the Vector3 where to store the result
  1852. */
  1853. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param sourceX defines the screen space x coordinate to use
  1857. * @param sourceY defines the screen space y coordinate to use
  1858. * @param sourceZ defines the screen space z coordinate to use
  1859. * @param viewportWidth defines the current width of the viewport
  1860. * @param viewportHeight defines the current height of the viewport
  1861. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1862. * @param view defines the view matrix to use
  1863. * @param projection defines the projection matrix to use
  1864. * @param result defines the Vector3 where to store the result
  1865. */
  1866. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1867. /**
  1868. * Gets the minimal coordinate values between two Vector3
  1869. * @param left defines the first operand
  1870. * @param right defines the second operand
  1871. * @returns the new Vector3
  1872. */
  1873. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1874. /**
  1875. * Gets the maximal coordinate values between two Vector3
  1876. * @param left defines the first operand
  1877. * @param right defines the second operand
  1878. * @returns the new Vector3
  1879. */
  1880. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1881. /**
  1882. * Returns the distance between the vectors "value1" and "value2"
  1883. * @param value1 defines the first operand
  1884. * @param value2 defines the second operand
  1885. * @returns the distance
  1886. */
  1887. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1888. /**
  1889. * Returns the squared distance between the vectors "value1" and "value2"
  1890. * @param value1 defines the first operand
  1891. * @param value2 defines the second operand
  1892. * @returns the squared distance
  1893. */
  1894. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1895. /**
  1896. * Returns a new Vector3 located at the center between "value1" and "value2"
  1897. * @param value1 defines the first operand
  1898. * @param value2 defines the second operand
  1899. * @returns the new Vector3
  1900. */
  1901. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1902. /**
  1903. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1904. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1905. * to something in order to rotate it from its local system to the given target system
  1906. * Note: axis1, axis2 and axis3 are normalized during this operation
  1907. * @param axis1 defines the first axis
  1908. * @param axis2 defines the second axis
  1909. * @param axis3 defines the third axis
  1910. * @returns a new Vector3
  1911. */
  1912. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1913. /**
  1914. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1915. * @param axis1 defines the first axis
  1916. * @param axis2 defines the second axis
  1917. * @param axis3 defines the third axis
  1918. * @param ref defines the Vector3 where to store the result
  1919. */
  1920. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1921. }
  1922. /**
  1923. * Vector4 class created for EulerAngle class conversion to Quaternion
  1924. */
  1925. export class Vector4 {
  1926. /** x value of the vector */
  1927. x: number;
  1928. /** y value of the vector */
  1929. y: number;
  1930. /** z value of the vector */
  1931. z: number;
  1932. /** w value of the vector */
  1933. w: number;
  1934. /**
  1935. * Creates a Vector4 object from the given floats.
  1936. * @param x x value of the vector
  1937. * @param y y value of the vector
  1938. * @param z z value of the vector
  1939. * @param w w value of the vector
  1940. */
  1941. constructor(
  1942. /** x value of the vector */
  1943. x: number,
  1944. /** y value of the vector */
  1945. y: number,
  1946. /** z value of the vector */
  1947. z: number,
  1948. /** w value of the vector */
  1949. w: number);
  1950. /**
  1951. * Returns the string with the Vector4 coordinates.
  1952. * @returns a string containing all the vector values
  1953. */
  1954. toString(): string;
  1955. /**
  1956. * Returns the string "Vector4".
  1957. * @returns "Vector4"
  1958. */
  1959. getClassName(): string;
  1960. /**
  1961. * Returns the Vector4 hash code.
  1962. * @returns a unique hash code
  1963. */
  1964. getHashCode(): number;
  1965. /**
  1966. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1967. * @returns the resulting array
  1968. */
  1969. asArray(): number[];
  1970. /**
  1971. * Populates the given array from the given index with the Vector4 coordinates.
  1972. * @param array array to populate
  1973. * @param index index of the array to start at (default: 0)
  1974. * @returns the Vector4.
  1975. */
  1976. toArray(array: FloatArray, index?: number): Vector4;
  1977. /**
  1978. * Adds the given vector to the current Vector4.
  1979. * @param otherVector the vector to add
  1980. * @returns the updated Vector4.
  1981. */
  1982. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1983. /**
  1984. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1985. * @param otherVector the vector to add
  1986. * @returns the resulting vector
  1987. */
  1988. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1989. /**
  1990. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1991. * @param otherVector the vector to add
  1992. * @param result the vector to store the result
  1993. * @returns the current Vector4.
  1994. */
  1995. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1996. /**
  1997. * Subtract in place the given vector from the current Vector4.
  1998. * @param otherVector the vector to subtract
  1999. * @returns the updated Vector4.
  2000. */
  2001. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2002. /**
  2003. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the new vector with the result
  2006. */
  2007. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2010. * @param otherVector the vector to subtract
  2011. * @param result the vector to store the result
  2012. * @returns the current Vector4.
  2013. */
  2014. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2015. /**
  2016. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2017. */
  2018. /**
  2019. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2020. * @param x value to subtract
  2021. * @param y value to subtract
  2022. * @param z value to subtract
  2023. * @param w value to subtract
  2024. * @returns new vector containing the result
  2025. */
  2026. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2027. /**
  2028. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2029. * @param x value to subtract
  2030. * @param y value to subtract
  2031. * @param z value to subtract
  2032. * @param w value to subtract
  2033. * @param result the vector to store the result in
  2034. * @returns the current Vector4.
  2035. */
  2036. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2037. /**
  2038. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2039. * @returns a new vector with the negated values
  2040. */
  2041. negate(): Vector4;
  2042. /**
  2043. * Multiplies the current Vector4 coordinates by scale (float).
  2044. * @param scale the number to scale with
  2045. * @returns the updated Vector4.
  2046. */
  2047. scaleInPlace(scale: number): Vector4;
  2048. /**
  2049. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2050. * @param scale the number to scale with
  2051. * @returns a new vector with the result
  2052. */
  2053. scale(scale: number): Vector4;
  2054. /**
  2055. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2056. * @param scale the number to scale with
  2057. * @param result a vector to store the result in
  2058. * @returns the current Vector4.
  2059. */
  2060. scaleToRef(scale: number, result: Vector4): Vector4;
  2061. /**
  2062. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2063. * @param scale defines the scale factor
  2064. * @param result defines the Vector4 object where to store the result
  2065. * @returns the unmodified current Vector4
  2066. */
  2067. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2068. /**
  2069. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2070. * @param otherVector the vector to compare against
  2071. * @returns true if they are equal
  2072. */
  2073. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2074. /**
  2075. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2076. * @param otherVector vector to compare against
  2077. * @param epsilon (Default: very small number)
  2078. * @returns true if they are equal
  2079. */
  2080. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2081. /**
  2082. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2083. * @param x x value to compare against
  2084. * @param y y value to compare against
  2085. * @param z z value to compare against
  2086. * @param w w value to compare against
  2087. * @returns true if equal
  2088. */
  2089. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2090. /**
  2091. * Multiplies in place the current Vector4 by the given one.
  2092. * @param otherVector vector to multiple with
  2093. * @returns the updated Vector4.
  2094. */
  2095. multiplyInPlace(otherVector: Vector4): Vector4;
  2096. /**
  2097. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2098. * @param otherVector vector to multiple with
  2099. * @returns resulting new vector
  2100. */
  2101. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2102. /**
  2103. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2104. * @param otherVector vector to multiple with
  2105. * @param result vector to store the result
  2106. * @returns the current Vector4.
  2107. */
  2108. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2109. /**
  2110. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2111. * @param x x value multiply with
  2112. * @param y y value multiply with
  2113. * @param z z value multiply with
  2114. * @param w w value multiply with
  2115. * @returns resulting new vector
  2116. */
  2117. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2118. /**
  2119. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2120. * @param otherVector vector to devide with
  2121. * @returns resulting new vector
  2122. */
  2123. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2124. /**
  2125. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2126. * @param otherVector vector to devide with
  2127. * @param result vector to store the result
  2128. * @returns the current Vector4.
  2129. */
  2130. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2131. /**
  2132. * Divides the current Vector3 coordinates by the given ones.
  2133. * @param otherVector vector to devide with
  2134. * @returns the updated Vector3.
  2135. */
  2136. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2137. /**
  2138. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2139. * @param other defines the second operand
  2140. * @returns the current updated Vector4
  2141. */
  2142. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2143. /**
  2144. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2145. * @param other defines the second operand
  2146. * @returns the current updated Vector4
  2147. */
  2148. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Gets a new Vector4 from current Vector4 floored values
  2151. * @returns a new Vector4
  2152. */
  2153. floor(): Vector4;
  2154. /**
  2155. * Gets a new Vector4 from current Vector3 floored values
  2156. * @returns a new Vector4
  2157. */
  2158. fract(): Vector4;
  2159. /**
  2160. * Returns the Vector4 length (float).
  2161. * @returns the length
  2162. */
  2163. length(): number;
  2164. /**
  2165. * Returns the Vector4 squared length (float).
  2166. * @returns the length squared
  2167. */
  2168. lengthSquared(): number;
  2169. /**
  2170. * Normalizes in place the Vector4.
  2171. * @returns the updated Vector4.
  2172. */
  2173. normalize(): Vector4;
  2174. /**
  2175. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2176. * @returns this converted to a new vector3
  2177. */
  2178. toVector3(): Vector3;
  2179. /**
  2180. * Returns a new Vector4 copied from the current one.
  2181. * @returns the new cloned vector
  2182. */
  2183. clone(): Vector4;
  2184. /**
  2185. * Updates the current Vector4 with the given one coordinates.
  2186. * @param source the source vector to copy from
  2187. * @returns the updated Vector4.
  2188. */
  2189. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2190. /**
  2191. * Updates the current Vector4 coordinates with the given floats.
  2192. * @param x float to copy from
  2193. * @param y float to copy from
  2194. * @param z float to copy from
  2195. * @param w float to copy from
  2196. * @returns the updated Vector4.
  2197. */
  2198. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2199. /**
  2200. * Updates the current Vector4 coordinates with the given floats.
  2201. * @param x float to set from
  2202. * @param y float to set from
  2203. * @param z float to set from
  2204. * @param w float to set from
  2205. * @returns the updated Vector4.
  2206. */
  2207. set(x: number, y: number, z: number, w: number): Vector4;
  2208. /**
  2209. * Copies the given float to the current Vector3 coordinates
  2210. * @param v defines the x, y, z and w coordinates of the operand
  2211. * @returns the current updated Vector3
  2212. */
  2213. setAll(v: number): Vector4;
  2214. /**
  2215. * Returns a new Vector4 set from the starting index of the given array.
  2216. * @param array the array to pull values from
  2217. * @param offset the offset into the array to start at
  2218. * @returns the new vector
  2219. */
  2220. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2221. /**
  2222. * Updates the given vector "result" from the starting index of the given array.
  2223. * @param array the array to pull values from
  2224. * @param offset the offset into the array to start at
  2225. * @param result the vector to store the result in
  2226. */
  2227. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2228. /**
  2229. * Updates the given vector "result" from the starting index of the given Float32Array.
  2230. * @param array the array to pull values from
  2231. * @param offset the offset into the array to start at
  2232. * @param result the vector to store the result in
  2233. */
  2234. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2235. /**
  2236. * Updates the given vector "result" coordinates from the given floats.
  2237. * @param x float to set from
  2238. * @param y float to set from
  2239. * @param z float to set from
  2240. * @param w float to set from
  2241. * @param result the vector to the floats in
  2242. */
  2243. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2244. /**
  2245. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2246. * @returns the new vector
  2247. */
  2248. static Zero(): Vector4;
  2249. /**
  2250. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2251. * @returns the new vector
  2252. */
  2253. static One(): Vector4;
  2254. /**
  2255. * Returns a new normalized Vector4 from the given one.
  2256. * @param vector the vector to normalize
  2257. * @returns the vector
  2258. */
  2259. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2260. /**
  2261. * Updates the given vector "result" from the normalization of the given one.
  2262. * @param vector the vector to normalize
  2263. * @param result the vector to store the result in
  2264. */
  2265. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2266. /**
  2267. * Returns a vector with the minimum values from the left and right vectors
  2268. * @param left left vector to minimize
  2269. * @param right right vector to minimize
  2270. * @returns a new vector with the minimum of the left and right vector values
  2271. */
  2272. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2273. /**
  2274. * Returns a vector with the maximum values from the left and right vectors
  2275. * @param left left vector to maximize
  2276. * @param right right vector to maximize
  2277. * @returns a new vector with the maximum of the left and right vector values
  2278. */
  2279. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2280. /**
  2281. * Returns the distance (float) between the vectors "value1" and "value2".
  2282. * @param value1 value to calulate the distance between
  2283. * @param value2 value to calulate the distance between
  2284. * @return the distance between the two vectors
  2285. */
  2286. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2287. /**
  2288. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2289. * @param value1 value to calulate the distance between
  2290. * @param value2 value to calulate the distance between
  2291. * @return the distance between the two vectors squared
  2292. */
  2293. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2294. /**
  2295. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2296. * @param value1 value to calulate the center between
  2297. * @param value2 value to calulate the center between
  2298. * @return the center between the two vectors
  2299. */
  2300. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2301. /**
  2302. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2303. * This methods computes transformed normalized direction vectors only.
  2304. * @param vector the vector to transform
  2305. * @param transformation the transformation matrix to apply
  2306. * @returns the new vector
  2307. */
  2308. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2309. /**
  2310. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2311. * This methods computes transformed normalized direction vectors only.
  2312. * @param vector the vector to transform
  2313. * @param transformation the transformation matrix to apply
  2314. * @param result the vector to store the result in
  2315. */
  2316. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2317. /**
  2318. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2319. * This methods computes transformed normalized direction vectors only.
  2320. * @param x value to transform
  2321. * @param y value to transform
  2322. * @param z value to transform
  2323. * @param w value to transform
  2324. * @param transformation the transformation matrix to apply
  2325. * @param result the vector to store the results in
  2326. */
  2327. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2328. /**
  2329. * Creates a new Vector4 from a Vector3
  2330. * @param source defines the source data
  2331. * @param w defines the 4th component (default is 0)
  2332. * @returns a new Vector4
  2333. */
  2334. static FromVector3(source: Vector3, w?: number): Vector4;
  2335. }
  2336. /**
  2337. * Interface for the size containing width and height
  2338. */
  2339. export interface ISize {
  2340. /**
  2341. * Width
  2342. */
  2343. width: number;
  2344. /**
  2345. * Heighht
  2346. */
  2347. height: number;
  2348. }
  2349. /**
  2350. * Size containing widht and height
  2351. */
  2352. export class Size implements ISize {
  2353. /**
  2354. * Width
  2355. */
  2356. width: number;
  2357. /**
  2358. * Height
  2359. */
  2360. height: number;
  2361. /**
  2362. * Creates a Size object from the given width and height (floats).
  2363. * @param width width of the new size
  2364. * @param height height of the new size
  2365. */
  2366. constructor(width: number, height: number);
  2367. /**
  2368. * Returns a string with the Size width and height
  2369. * @returns a string with the Size width and height
  2370. */
  2371. toString(): string;
  2372. /**
  2373. * "Size"
  2374. * @returns the string "Size"
  2375. */
  2376. getClassName(): string;
  2377. /**
  2378. * Returns the Size hash code.
  2379. * @returns a hash code for a unique width and height
  2380. */
  2381. getHashCode(): number;
  2382. /**
  2383. * Updates the current size from the given one.
  2384. * @param src the given size
  2385. */
  2386. copyFrom(src: Size): void;
  2387. /**
  2388. * Updates in place the current Size from the given floats.
  2389. * @param width width of the new size
  2390. * @param height height of the new size
  2391. * @returns the updated Size.
  2392. */
  2393. copyFromFloats(width: number, height: number): Size;
  2394. /**
  2395. * Updates in place the current Size from the given floats.
  2396. * @param width width to set
  2397. * @param height height to set
  2398. * @returns the updated Size.
  2399. */
  2400. set(width: number, height: number): Size;
  2401. /**
  2402. * Multiplies the width and height by numbers
  2403. * @param w factor to multiple the width by
  2404. * @param h factor to multiple the height by
  2405. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2406. */
  2407. multiplyByFloats(w: number, h: number): Size;
  2408. /**
  2409. * Clones the size
  2410. * @returns a new Size copied from the given one.
  2411. */
  2412. clone(): Size;
  2413. /**
  2414. * True if the current Size and the given one width and height are strictly equal.
  2415. * @param other the other size to compare against
  2416. * @returns True if the current Size and the given one width and height are strictly equal.
  2417. */
  2418. equals(other: Size): boolean;
  2419. /**
  2420. * The surface of the Size : width * height (float).
  2421. */
  2422. readonly surface: number;
  2423. /**
  2424. * Create a new size of zero
  2425. * @returns a new Size set to (0.0, 0.0)
  2426. */
  2427. static Zero(): Size;
  2428. /**
  2429. * Sums the width and height of two sizes
  2430. * @param otherSize size to add to this size
  2431. * @returns a new Size set as the addition result of the current Size and the given one.
  2432. */
  2433. add(otherSize: Size): Size;
  2434. /**
  2435. * Subtracts the width and height of two
  2436. * @param otherSize size to subtract to this size
  2437. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2438. */
  2439. subtract(otherSize: Size): Size;
  2440. /**
  2441. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2442. * @param start starting size to lerp between
  2443. * @param end end size to lerp between
  2444. * @param amount amount to lerp between the start and end values
  2445. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2446. */
  2447. static Lerp(start: Size, end: Size, amount: number): Size;
  2448. }
  2449. /**
  2450. * Class used to store quaternion data
  2451. * @see https://en.wikipedia.org/wiki/Quaternion
  2452. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2453. */
  2454. export class Quaternion {
  2455. /** defines the first component (0 by default) */
  2456. x: number;
  2457. /** defines the second component (0 by default) */
  2458. y: number;
  2459. /** defines the third component (0 by default) */
  2460. z: number;
  2461. /** defines the fourth component (1.0 by default) */
  2462. w: number;
  2463. /**
  2464. * Creates a new Quaternion from the given floats
  2465. * @param x defines the first component (0 by default)
  2466. * @param y defines the second component (0 by default)
  2467. * @param z defines the third component (0 by default)
  2468. * @param w defines the fourth component (1.0 by default)
  2469. */
  2470. constructor(
  2471. /** defines the first component (0 by default) */
  2472. x?: number,
  2473. /** defines the second component (0 by default) */
  2474. y?: number,
  2475. /** defines the third component (0 by default) */
  2476. z?: number,
  2477. /** defines the fourth component (1.0 by default) */
  2478. w?: number);
  2479. /**
  2480. * Gets a string representation for the current quaternion
  2481. * @returns a string with the Quaternion coordinates
  2482. */
  2483. toString(): string;
  2484. /**
  2485. * Gets the class name of the quaternion
  2486. * @returns the string "Quaternion"
  2487. */
  2488. getClassName(): string;
  2489. /**
  2490. * Gets a hash code for this quaternion
  2491. * @returns the quaternion hash code
  2492. */
  2493. getHashCode(): number;
  2494. /**
  2495. * Copy the quaternion to an array
  2496. * @returns a new array populated with 4 elements from the quaternion coordinates
  2497. */
  2498. asArray(): number[];
  2499. /**
  2500. * Check if two quaternions are equals
  2501. * @param otherQuaternion defines the second operand
  2502. * @return true if the current quaternion and the given one coordinates are strictly equals
  2503. */
  2504. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2505. /**
  2506. * Clone the current quaternion
  2507. * @returns a new quaternion copied from the current one
  2508. */
  2509. clone(): Quaternion;
  2510. /**
  2511. * Copy a quaternion to the current one
  2512. * @param other defines the other quaternion
  2513. * @returns the updated current quaternion
  2514. */
  2515. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2516. /**
  2517. * Updates the current quaternion with the given float coordinates
  2518. * @param x defines the x coordinate
  2519. * @param y defines the y coordinate
  2520. * @param z defines the z coordinate
  2521. * @param w defines the w coordinate
  2522. * @returns the updated current quaternion
  2523. */
  2524. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2525. /**
  2526. * Updates the current quaternion from the given float coordinates
  2527. * @param x defines the x coordinate
  2528. * @param y defines the y coordinate
  2529. * @param z defines the z coordinate
  2530. * @param w defines the w coordinate
  2531. * @returns the updated current quaternion
  2532. */
  2533. set(x: number, y: number, z: number, w: number): Quaternion;
  2534. /**
  2535. * Adds two quaternions
  2536. * @param other defines the second operand
  2537. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2538. */
  2539. add(other: DeepImmutable<Quaternion>): Quaternion;
  2540. /**
  2541. * Add a quaternion to the current one
  2542. * @param other defines the quaternion to add
  2543. * @returns the current quaternion
  2544. */
  2545. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2546. /**
  2547. * Subtract two quaternions
  2548. * @param other defines the second operand
  2549. * @returns a new quaternion as the subtraction result of the given one from the current one
  2550. */
  2551. subtract(other: Quaternion): Quaternion;
  2552. /**
  2553. * Multiplies the current quaternion by a scale factor
  2554. * @param value defines the scale factor
  2555. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2556. */
  2557. scale(value: number): Quaternion;
  2558. /**
  2559. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2560. * @param scale defines the scale factor
  2561. * @param result defines the Quaternion object where to store the result
  2562. * @returns the unmodified current quaternion
  2563. */
  2564. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2565. /**
  2566. * Multiplies in place the current quaternion by a scale factor
  2567. * @param value defines the scale factor
  2568. * @returns the current modified quaternion
  2569. */
  2570. scaleInPlace(value: number): Quaternion;
  2571. /**
  2572. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2573. * @param scale defines the scale factor
  2574. * @param result defines the Quaternion object where to store the result
  2575. * @returns the unmodified current quaternion
  2576. */
  2577. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2578. /**
  2579. * Multiplies two quaternions
  2580. * @param q1 defines the second operand
  2581. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2582. */
  2583. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2584. /**
  2585. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2586. * @param q1 defines the second operand
  2587. * @param result defines the target quaternion
  2588. * @returns the current quaternion
  2589. */
  2590. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2591. /**
  2592. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2593. * @param q1 defines the second operand
  2594. * @returns the currentupdated quaternion
  2595. */
  2596. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2597. /**
  2598. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2599. * @param ref defines the target quaternion
  2600. * @returns the current quaternion
  2601. */
  2602. conjugateToRef(ref: Quaternion): Quaternion;
  2603. /**
  2604. * Conjugates in place (1-q) the current quaternion
  2605. * @returns the current updated quaternion
  2606. */
  2607. conjugateInPlace(): Quaternion;
  2608. /**
  2609. * Conjugates in place (1-q) the current quaternion
  2610. * @returns a new quaternion
  2611. */
  2612. conjugate(): Quaternion;
  2613. /**
  2614. * Gets length of current quaternion
  2615. * @returns the quaternion length (float)
  2616. */
  2617. length(): number;
  2618. /**
  2619. * Normalize in place the current quaternion
  2620. * @returns the current updated quaternion
  2621. */
  2622. normalize(): Quaternion;
  2623. /**
  2624. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2625. * @param order is a reserved parameter and is ignore for now
  2626. * @returns a new Vector3 containing the Euler angles
  2627. */
  2628. toEulerAngles(order?: string): Vector3;
  2629. /**
  2630. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2631. * @param result defines the vector which will be filled with the Euler angles
  2632. * @param order is a reserved parameter and is ignore for now
  2633. * @returns the current unchanged quaternion
  2634. */
  2635. toEulerAnglesToRef(result: Vector3): Quaternion;
  2636. /**
  2637. * Updates the given rotation matrix with the current quaternion values
  2638. * @param result defines the target matrix
  2639. * @returns the current unchanged quaternion
  2640. */
  2641. toRotationMatrix(result: Matrix): Quaternion;
  2642. /**
  2643. * Updates the current quaternion from the given rotation matrix values
  2644. * @param matrix defines the source matrix
  2645. * @returns the current updated quaternion
  2646. */
  2647. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2648. /**
  2649. * Creates a new quaternion from a rotation matrix
  2650. * @param matrix defines the source matrix
  2651. * @returns a new quaternion created from the given rotation matrix values
  2652. */
  2653. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2654. /**
  2655. * Updates the given quaternion with the given rotation matrix values
  2656. * @param matrix defines the source matrix
  2657. * @param result defines the target quaternion
  2658. */
  2659. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2660. /**
  2661. * Returns the dot product (float) between the quaternions "left" and "right"
  2662. * @param left defines the left operand
  2663. * @param right defines the right operand
  2664. * @returns the dot product
  2665. */
  2666. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2667. /**
  2668. * Checks if the two quaternions are close to each other
  2669. * @param quat0 defines the first quaternion to check
  2670. * @param quat1 defines the second quaternion to check
  2671. * @returns true if the two quaternions are close to each other
  2672. */
  2673. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2674. /**
  2675. * Creates an empty quaternion
  2676. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2677. */
  2678. static Zero(): Quaternion;
  2679. /**
  2680. * Inverse a given quaternion
  2681. * @param q defines the source quaternion
  2682. * @returns a new quaternion as the inverted current quaternion
  2683. */
  2684. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2685. /**
  2686. * Inverse a given quaternion
  2687. * @param q defines the source quaternion
  2688. * @param result the quaternion the result will be stored in
  2689. * @returns the result quaternion
  2690. */
  2691. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2692. /**
  2693. * Creates an identity quaternion
  2694. * @returns the identity quaternion
  2695. */
  2696. static Identity(): Quaternion;
  2697. /**
  2698. * Gets a boolean indicating if the given quaternion is identity
  2699. * @param quaternion defines the quaternion to check
  2700. * @returns true if the quaternion is identity
  2701. */
  2702. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2703. /**
  2704. * Creates a quaternion from a rotation around an axis
  2705. * @param axis defines the axis to use
  2706. * @param angle defines the angle to use
  2707. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2708. */
  2709. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2710. /**
  2711. * Creates a rotation around an axis and stores it into the given quaternion
  2712. * @param axis defines the axis to use
  2713. * @param angle defines the angle to use
  2714. * @param result defines the target quaternion
  2715. * @returns the target quaternion
  2716. */
  2717. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2718. /**
  2719. * Creates a new quaternion from data stored into an array
  2720. * @param array defines the data source
  2721. * @param offset defines the offset in the source array where the data starts
  2722. * @returns a new quaternion
  2723. */
  2724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2725. /**
  2726. * Create a quaternion from Euler rotation angles
  2727. * @param x Pitch
  2728. * @param y Yaw
  2729. * @param z Roll
  2730. * @returns the new Quaternion
  2731. */
  2732. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2733. /**
  2734. * Updates a quaternion from Euler rotation angles
  2735. * @param x Pitch
  2736. * @param y Yaw
  2737. * @param z Roll
  2738. * @param result the quaternion to store the result
  2739. * @returns the updated quaternion
  2740. */
  2741. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2742. /**
  2743. * Create a quaternion from Euler rotation vector
  2744. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2745. * @returns the new Quaternion
  2746. */
  2747. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2748. /**
  2749. * Updates a quaternion from Euler rotation vector
  2750. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2751. * @param result the quaternion to store the result
  2752. * @returns the updated quaternion
  2753. */
  2754. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2755. /**
  2756. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2757. * @param yaw defines the rotation around Y axis
  2758. * @param pitch defines the rotation around X axis
  2759. * @param roll defines the rotation around Z axis
  2760. * @returns the new quaternion
  2761. */
  2762. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2763. /**
  2764. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2765. * @param yaw defines the rotation around Y axis
  2766. * @param pitch defines the rotation around X axis
  2767. * @param roll defines the rotation around Z axis
  2768. * @param result defines the target quaternion
  2769. */
  2770. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2771. /**
  2772. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2773. * @param alpha defines the rotation around first axis
  2774. * @param beta defines the rotation around second axis
  2775. * @param gamma defines the rotation around third axis
  2776. * @returns the new quaternion
  2777. */
  2778. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2779. /**
  2780. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2781. * @param alpha defines the rotation around first axis
  2782. * @param beta defines the rotation around second axis
  2783. * @param gamma defines the rotation around third axis
  2784. * @param result defines the target quaternion
  2785. */
  2786. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2787. /**
  2788. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2789. * @param axis1 defines the first axis
  2790. * @param axis2 defines the second axis
  2791. * @param axis3 defines the third axis
  2792. * @returns the new quaternion
  2793. */
  2794. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2795. /**
  2796. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2797. * @param axis1 defines the first axis
  2798. * @param axis2 defines the second axis
  2799. * @param axis3 defines the third axis
  2800. * @param ref defines the target quaternion
  2801. */
  2802. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2803. /**
  2804. * Interpolates between two quaternions
  2805. * @param left defines first quaternion
  2806. * @param right defines second quaternion
  2807. * @param amount defines the gradient to use
  2808. * @returns the new interpolated quaternion
  2809. */
  2810. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2811. /**
  2812. * Interpolates between two quaternions and stores it into a target quaternion
  2813. * @param left defines first quaternion
  2814. * @param right defines second quaternion
  2815. * @param amount defines the gradient to use
  2816. * @param result defines the target quaternion
  2817. */
  2818. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2819. /**
  2820. * Interpolate between two quaternions using Hermite interpolation
  2821. * @param value1 defines first quaternion
  2822. * @param tangent1 defines the incoming tangent
  2823. * @param value2 defines second quaternion
  2824. * @param tangent2 defines the outgoing tangent
  2825. * @param amount defines the target quaternion
  2826. * @returns the new interpolated quaternion
  2827. */
  2828. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2829. }
  2830. /**
  2831. * Class used to store matrix data (4x4)
  2832. */
  2833. export class Matrix {
  2834. private static _updateFlagSeed;
  2835. private static _identityReadOnly;
  2836. private _isIdentity;
  2837. private _isIdentityDirty;
  2838. private _isIdentity3x2;
  2839. private _isIdentity3x2Dirty;
  2840. /**
  2841. * Gets the update flag of the matrix which is an unique number for the matrix.
  2842. * It will be incremented every time the matrix data change.
  2843. * You can use it to speed the comparison between two versions of the same matrix.
  2844. */
  2845. updateFlag: number;
  2846. private readonly _m;
  2847. /**
  2848. * Gets the internal data of the matrix
  2849. */
  2850. readonly m: DeepImmutable<Float32Array>;
  2851. /** @hidden */
  2852. _markAsUpdated(): void;
  2853. /** @hidden */
  2854. private _updateIdentityStatus;
  2855. /**
  2856. * Creates an empty matrix (filled with zeros)
  2857. */
  2858. constructor();
  2859. /**
  2860. * Check if the current matrix is identity
  2861. * @returns true is the matrix is the identity matrix
  2862. */
  2863. isIdentity(): boolean;
  2864. /**
  2865. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2866. * @returns true is the matrix is the identity matrix
  2867. */
  2868. isIdentityAs3x2(): boolean;
  2869. /**
  2870. * Gets the determinant of the matrix
  2871. * @returns the matrix determinant
  2872. */
  2873. determinant(): number;
  2874. /**
  2875. * Returns the matrix as a Float32Array
  2876. * @returns the matrix underlying array
  2877. */
  2878. toArray(): DeepImmutable<Float32Array>;
  2879. /**
  2880. * Returns the matrix as a Float32Array
  2881. * @returns the matrix underlying array.
  2882. */
  2883. asArray(): DeepImmutable<Float32Array>;
  2884. /**
  2885. * Inverts the current matrix in place
  2886. * @returns the current inverted matrix
  2887. */
  2888. invert(): Matrix;
  2889. /**
  2890. * Sets all the matrix elements to zero
  2891. * @returns the current matrix
  2892. */
  2893. reset(): Matrix;
  2894. /**
  2895. * Adds the current matrix with a second one
  2896. * @param other defines the matrix to add
  2897. * @returns a new matrix as the addition of the current matrix and the given one
  2898. */
  2899. add(other: DeepImmutable<Matrix>): Matrix;
  2900. /**
  2901. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2902. * @param other defines the matrix to add
  2903. * @param result defines the target matrix
  2904. * @returns the current matrix
  2905. */
  2906. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2907. /**
  2908. * Adds in place the given matrix to the current matrix
  2909. * @param other defines the second operand
  2910. * @returns the current updated matrix
  2911. */
  2912. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2913. /**
  2914. * Sets the given matrix to the current inverted Matrix
  2915. * @param other defines the target matrix
  2916. * @returns the unmodified current matrix
  2917. */
  2918. invertToRef(other: Matrix): Matrix;
  2919. /**
  2920. * add a value at the specified position in the current Matrix
  2921. * @param index the index of the value within the matrix. between 0 and 15.
  2922. * @param value the value to be added
  2923. * @returns the current updated matrix
  2924. */
  2925. addAtIndex(index: number, value: number): Matrix;
  2926. /**
  2927. * mutiply the specified position in the current Matrix by a value
  2928. * @param index the index of the value within the matrix. between 0 and 15.
  2929. * @param value the value to be added
  2930. * @returns the current updated matrix
  2931. */
  2932. multiplyAtIndex(index: number, value: number): Matrix;
  2933. /**
  2934. * Inserts the translation vector (using 3 floats) in the current matrix
  2935. * @param x defines the 1st component of the translation
  2936. * @param y defines the 2nd component of the translation
  2937. * @param z defines the 3rd component of the translation
  2938. * @returns the current updated matrix
  2939. */
  2940. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2941. /**
  2942. * Inserts the translation vector in the current matrix
  2943. * @param vector3 defines the translation to insert
  2944. * @returns the current updated matrix
  2945. */
  2946. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2947. /**
  2948. * Gets the translation value of the current matrix
  2949. * @returns a new Vector3 as the extracted translation from the matrix
  2950. */
  2951. getTranslation(): Vector3;
  2952. /**
  2953. * Fill a Vector3 with the extracted translation from the matrix
  2954. * @param result defines the Vector3 where to store the translation
  2955. * @returns the current matrix
  2956. */
  2957. getTranslationToRef(result: Vector3): Matrix;
  2958. /**
  2959. * Remove rotation and scaling part from the matrix
  2960. * @returns the updated matrix
  2961. */
  2962. removeRotationAndScaling(): Matrix;
  2963. /**
  2964. * Multiply two matrices
  2965. * @param other defines the second operand
  2966. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2967. */
  2968. multiply(other: DeepImmutable<Matrix>): Matrix;
  2969. /**
  2970. * Copy the current matrix from the given one
  2971. * @param other defines the source matrix
  2972. * @returns the current updated matrix
  2973. */
  2974. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2975. /**
  2976. * Populates the given array from the starting index with the current matrix values
  2977. * @param array defines the target array
  2978. * @param offset defines the offset in the target array where to start storing values
  2979. * @returns the current matrix
  2980. */
  2981. copyToArray(array: Float32Array, offset?: number): Matrix;
  2982. /**
  2983. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2984. * @param other defines the second operand
  2985. * @param result defines the matrix where to store the multiplication
  2986. * @returns the current matrix
  2987. */
  2988. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2989. /**
  2990. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2991. * @param other defines the second operand
  2992. * @param result defines the array where to store the multiplication
  2993. * @param offset defines the offset in the target array where to start storing values
  2994. * @returns the current matrix
  2995. */
  2996. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2997. /**
  2998. * Check equality between this matrix and a second one
  2999. * @param value defines the second matrix to compare
  3000. * @returns true is the current matrix and the given one values are strictly equal
  3001. */
  3002. equals(value: DeepImmutable<Matrix>): boolean;
  3003. /**
  3004. * Clone the current matrix
  3005. * @returns a new matrix from the current matrix
  3006. */
  3007. clone(): Matrix;
  3008. /**
  3009. * Returns the name of the current matrix class
  3010. * @returns the string "Matrix"
  3011. */
  3012. getClassName(): string;
  3013. /**
  3014. * Gets the hash code of the current matrix
  3015. * @returns the hash code
  3016. */
  3017. getHashCode(): number;
  3018. /**
  3019. * Decomposes the current Matrix into a translation, rotation and scaling components
  3020. * @param scale defines the scale vector3 given as a reference to update
  3021. * @param rotation defines the rotation quaternion given as a reference to update
  3022. * @param translation defines the translation vector3 given as a reference to update
  3023. * @returns true if operation was successful
  3024. */
  3025. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3026. /**
  3027. * Gets specific row of the matrix
  3028. * @param index defines the number of the row to get
  3029. * @returns the index-th row of the current matrix as a new Vector4
  3030. */
  3031. getRow(index: number): Nullable<Vector4>;
  3032. /**
  3033. * Sets the index-th row of the current matrix to the vector4 values
  3034. * @param index defines the number of the row to set
  3035. * @param row defines the target vector4
  3036. * @returns the updated current matrix
  3037. */
  3038. setRow(index: number, row: Vector4): Matrix;
  3039. /**
  3040. * Compute the transpose of the matrix
  3041. * @returns the new transposed matrix
  3042. */
  3043. transpose(): Matrix;
  3044. /**
  3045. * Compute the transpose of the matrix and store it in a given matrix
  3046. * @param result defines the target matrix
  3047. * @returns the current matrix
  3048. */
  3049. transposeToRef(result: Matrix): Matrix;
  3050. /**
  3051. * Sets the index-th row of the current matrix with the given 4 x float values
  3052. * @param index defines the row index
  3053. * @param x defines the x component to set
  3054. * @param y defines the y component to set
  3055. * @param z defines the z component to set
  3056. * @param w defines the w component to set
  3057. * @returns the updated current matrix
  3058. */
  3059. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3060. /**
  3061. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3062. * @param scale defines the scale factor
  3063. * @returns a new matrix
  3064. */
  3065. scale(scale: number): Matrix;
  3066. /**
  3067. * Scale the current matrix values by a factor to a given result matrix
  3068. * @param scale defines the scale factor
  3069. * @param result defines the matrix to store the result
  3070. * @returns the current matrix
  3071. */
  3072. scaleToRef(scale: number, result: Matrix): Matrix;
  3073. /**
  3074. * Scale the current matrix values by a factor and add the result to a given matrix
  3075. * @param scale defines the scale factor
  3076. * @param result defines the Matrix to store the result
  3077. * @returns the current matrix
  3078. */
  3079. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3080. /**
  3081. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3082. * @param ref matrix to store the result
  3083. */
  3084. toNormalMatrix(ref: Matrix): void;
  3085. /**
  3086. * Gets only rotation part of the current matrix
  3087. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3088. */
  3089. getRotationMatrix(): Matrix;
  3090. /**
  3091. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3092. * @param result defines the target matrix to store data to
  3093. * @returns the current matrix
  3094. */
  3095. getRotationMatrixToRef(result: Matrix): Matrix;
  3096. /**
  3097. * Toggles model matrix from being right handed to left handed in place and vice versa
  3098. */
  3099. toggleModelMatrixHandInPlace(): void;
  3100. /**
  3101. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3102. */
  3103. toggleProjectionMatrixHandInPlace(): void;
  3104. /**
  3105. * Creates a matrix from an array
  3106. * @param array defines the source array
  3107. * @param offset defines an offset in the source array
  3108. * @returns a new Matrix set from the starting index of the given array
  3109. */
  3110. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3111. /**
  3112. * Copy the content of an array into a given matrix
  3113. * @param array defines the source array
  3114. * @param offset defines an offset in the source array
  3115. * @param result defines the target matrix
  3116. */
  3117. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3118. /**
  3119. * Stores an array into a matrix after having multiplied each component by a given factor
  3120. * @param array defines the source array
  3121. * @param offset defines the offset in the source array
  3122. * @param scale defines the scaling factor
  3123. * @param result defines the target matrix
  3124. */
  3125. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3126. /**
  3127. * Gets an identity matrix that must not be updated
  3128. */
  3129. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3130. /**
  3131. * Stores a list of values (16) inside a given matrix
  3132. * @param initialM11 defines 1st value of 1st row
  3133. * @param initialM12 defines 2nd value of 1st row
  3134. * @param initialM13 defines 3rd value of 1st row
  3135. * @param initialM14 defines 4th value of 1st row
  3136. * @param initialM21 defines 1st value of 2nd row
  3137. * @param initialM22 defines 2nd value of 2nd row
  3138. * @param initialM23 defines 3rd value of 2nd row
  3139. * @param initialM24 defines 4th value of 2nd row
  3140. * @param initialM31 defines 1st value of 3rd row
  3141. * @param initialM32 defines 2nd value of 3rd row
  3142. * @param initialM33 defines 3rd value of 3rd row
  3143. * @param initialM34 defines 4th value of 3rd row
  3144. * @param initialM41 defines 1st value of 4th row
  3145. * @param initialM42 defines 2nd value of 4th row
  3146. * @param initialM43 defines 3rd value of 4th row
  3147. * @param initialM44 defines 4th value of 4th row
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3151. /**
  3152. * Creates new matrix from a list of values (16)
  3153. * @param initialM11 defines 1st value of 1st row
  3154. * @param initialM12 defines 2nd value of 1st row
  3155. * @param initialM13 defines 3rd value of 1st row
  3156. * @param initialM14 defines 4th value of 1st row
  3157. * @param initialM21 defines 1st value of 2nd row
  3158. * @param initialM22 defines 2nd value of 2nd row
  3159. * @param initialM23 defines 3rd value of 2nd row
  3160. * @param initialM24 defines 4th value of 2nd row
  3161. * @param initialM31 defines 1st value of 3rd row
  3162. * @param initialM32 defines 2nd value of 3rd row
  3163. * @param initialM33 defines 3rd value of 3rd row
  3164. * @param initialM34 defines 4th value of 3rd row
  3165. * @param initialM41 defines 1st value of 4th row
  3166. * @param initialM42 defines 2nd value of 4th row
  3167. * @param initialM43 defines 3rd value of 4th row
  3168. * @param initialM44 defines 4th value of 4th row
  3169. * @returns the new matrix
  3170. */
  3171. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3172. /**
  3173. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3174. * @param scale defines the scale vector3
  3175. * @param rotation defines the rotation quaternion
  3176. * @param translation defines the translation vector3
  3177. * @returns a new matrix
  3178. */
  3179. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3180. /**
  3181. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3182. * @param scale defines the scale vector3
  3183. * @param rotation defines the rotation quaternion
  3184. * @param translation defines the translation vector3
  3185. * @param result defines the target matrix
  3186. */
  3187. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3188. /**
  3189. * Creates a new identity matrix
  3190. * @returns a new identity matrix
  3191. */
  3192. static Identity(): Matrix;
  3193. /**
  3194. * Creates a new identity matrix and stores the result in a given matrix
  3195. * @param result defines the target matrix
  3196. */
  3197. static IdentityToRef(result: Matrix): void;
  3198. /**
  3199. * Creates a new zero matrix
  3200. * @returns a new zero matrix
  3201. */
  3202. static Zero(): Matrix;
  3203. /**
  3204. * Creates a new rotation matrix for "angle" radians around the X axis
  3205. * @param angle defines the angle (in radians) to use
  3206. * @return the new matrix
  3207. */
  3208. static RotationX(angle: number): Matrix;
  3209. /**
  3210. * Creates a new matrix as the invert of a given matrix
  3211. * @param source defines the source matrix
  3212. * @returns the new matrix
  3213. */
  3214. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3215. /**
  3216. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3217. * @param angle defines the angle (in radians) to use
  3218. * @param result defines the target matrix
  3219. */
  3220. static RotationXToRef(angle: number, result: Matrix): void;
  3221. /**
  3222. * Creates a new rotation matrix for "angle" radians around the Y axis
  3223. * @param angle defines the angle (in radians) to use
  3224. * @return the new matrix
  3225. */
  3226. static RotationY(angle: number): Matrix;
  3227. /**
  3228. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3229. * @param angle defines the angle (in radians) to use
  3230. * @param result defines the target matrix
  3231. */
  3232. static RotationYToRef(angle: number, result: Matrix): void;
  3233. /**
  3234. * Creates a new rotation matrix for "angle" radians around the Z axis
  3235. * @param angle defines the angle (in radians) to use
  3236. * @return the new matrix
  3237. */
  3238. static RotationZ(angle: number): Matrix;
  3239. /**
  3240. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3241. * @param angle defines the angle (in radians) to use
  3242. * @param result defines the target matrix
  3243. */
  3244. static RotationZToRef(angle: number, result: Matrix): void;
  3245. /**
  3246. * Creates a new rotation matrix for "angle" radians around the given axis
  3247. * @param axis defines the axis to use
  3248. * @param angle defines the angle (in radians) to use
  3249. * @return the new matrix
  3250. */
  3251. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3252. /**
  3253. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3254. * @param axis defines the axis to use
  3255. * @param angle defines the angle (in radians) to use
  3256. * @param result defines the target matrix
  3257. */
  3258. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3259. /**
  3260. * Creates a rotation matrix
  3261. * @param yaw defines the yaw angle in radians (Y axis)
  3262. * @param pitch defines the pitch angle in radians (X axis)
  3263. * @param roll defines the roll angle in radians (X axis)
  3264. * @returns the new rotation matrix
  3265. */
  3266. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3267. /**
  3268. * Creates a rotation matrix and stores it in a given matrix
  3269. * @param yaw defines the yaw angle in radians (Y axis)
  3270. * @param pitch defines the pitch angle in radians (X axis)
  3271. * @param roll defines the roll angle in radians (X axis)
  3272. * @param result defines the target matrix
  3273. */
  3274. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3275. /**
  3276. * Creates a scaling matrix
  3277. * @param x defines the scale factor on X axis
  3278. * @param y defines the scale factor on Y axis
  3279. * @param z defines the scale factor on Z axis
  3280. * @returns the new matrix
  3281. */
  3282. static Scaling(x: number, y: number, z: number): Matrix;
  3283. /**
  3284. * Creates a scaling matrix and stores it in a given matrix
  3285. * @param x defines the scale factor on X axis
  3286. * @param y defines the scale factor on Y axis
  3287. * @param z defines the scale factor on Z axis
  3288. * @param result defines the target matrix
  3289. */
  3290. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3291. /**
  3292. * Creates a translation matrix
  3293. * @param x defines the translation on X axis
  3294. * @param y defines the translation on Y axis
  3295. * @param z defines the translationon Z axis
  3296. * @returns the new matrix
  3297. */
  3298. static Translation(x: number, y: number, z: number): Matrix;
  3299. /**
  3300. * Creates a translation matrix and stores it in a given matrix
  3301. * @param x defines the translation on X axis
  3302. * @param y defines the translation on Y axis
  3303. * @param z defines the translationon Z axis
  3304. * @param result defines the target matrix
  3305. */
  3306. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3307. /**
  3308. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3309. * @param startValue defines the start value
  3310. * @param endValue defines the end value
  3311. * @param gradient defines the gradient factor
  3312. * @returns the new matrix
  3313. */
  3314. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3315. /**
  3316. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3317. * @param startValue defines the start value
  3318. * @param endValue defines the end value
  3319. * @param gradient defines the gradient factor
  3320. * @param result defines the Matrix object where to store data
  3321. */
  3322. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3323. /**
  3324. * Builds a new matrix whose values are computed by:
  3325. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3326. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3327. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3328. * @param startValue defines the first matrix
  3329. * @param endValue defines the second matrix
  3330. * @param gradient defines the gradient between the two matrices
  3331. * @returns the new matrix
  3332. */
  3333. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3334. /**
  3335. * Update a matrix to values which are computed by:
  3336. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3337. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3338. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3339. * @param startValue defines the first matrix
  3340. * @param endValue defines the second matrix
  3341. * @param gradient defines the gradient between the two matrices
  3342. * @param result defines the target matrix
  3343. */
  3344. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3345. /**
  3346. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3347. * This function works in left handed mode
  3348. * @param eye defines the final position of the entity
  3349. * @param target defines where the entity should look at
  3350. * @param up defines the up vector for the entity
  3351. * @returns the new matrix
  3352. */
  3353. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3354. /**
  3355. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3356. * This function works in left handed mode
  3357. * @param eye defines the final position of the entity
  3358. * @param target defines where the entity should look at
  3359. * @param up defines the up vector for the entity
  3360. * @param result defines the target matrix
  3361. */
  3362. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3363. /**
  3364. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3365. * This function works in right handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3374. * This function works in right handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * Create a left-handed orthographic projection matrix
  3383. * @param width defines the viewport width
  3384. * @param height defines the viewport height
  3385. * @param znear defines the near clip plane
  3386. * @param zfar defines the far clip plane
  3387. * @returns a new matrix as a left-handed orthographic projection matrix
  3388. */
  3389. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3390. /**
  3391. * Store a left-handed orthographic projection to a given matrix
  3392. * @param width defines the viewport width
  3393. * @param height defines the viewport height
  3394. * @param znear defines the near clip plane
  3395. * @param zfar defines the far clip plane
  3396. * @param result defines the target matrix
  3397. */
  3398. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param left defines the viewport left coordinate
  3402. * @param right defines the viewport right coordinate
  3403. * @param bottom defines the viewport bottom coordinate
  3404. * @param top defines the viewport top coordinate
  3405. * @param znear defines the near clip plane
  3406. * @param zfar defines the far clip plane
  3407. * @returns a new matrix as a left-handed orthographic projection matrix
  3408. */
  3409. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3410. /**
  3411. * Stores a left-handed orthographic projection into a given matrix
  3412. * @param left defines the viewport left coordinate
  3413. * @param right defines the viewport right coordinate
  3414. * @param bottom defines the viewport bottom coordinate
  3415. * @param top defines the viewport top coordinate
  3416. * @param znear defines the near clip plane
  3417. * @param zfar defines the far clip plane
  3418. * @param result defines the target matrix
  3419. */
  3420. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3421. /**
  3422. * Creates a right-handed orthographic projection matrix
  3423. * @param left defines the viewport left coordinate
  3424. * @param right defines the viewport right coordinate
  3425. * @param bottom defines the viewport bottom coordinate
  3426. * @param top defines the viewport top coordinate
  3427. * @param znear defines the near clip plane
  3428. * @param zfar defines the far clip plane
  3429. * @returns a new matrix as a right-handed orthographic projection matrix
  3430. */
  3431. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3432. /**
  3433. * Stores a right-handed orthographic projection into a given matrix
  3434. * @param left defines the viewport left coordinate
  3435. * @param right defines the viewport right coordinate
  3436. * @param bottom defines the viewport bottom coordinate
  3437. * @param top defines the viewport top coordinate
  3438. * @param znear defines the near clip plane
  3439. * @param zfar defines the far clip plane
  3440. * @param result defines the target matrix
  3441. */
  3442. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3443. /**
  3444. * Creates a left-handed perspective projection matrix
  3445. * @param width defines the viewport width
  3446. * @param height defines the viewport height
  3447. * @param znear defines the near clip plane
  3448. * @param zfar defines the far clip plane
  3449. * @returns a new matrix as a left-handed perspective projection matrix
  3450. */
  3451. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3452. /**
  3453. * Creates a left-handed perspective projection matrix
  3454. * @param fov defines the horizontal field of view
  3455. * @param aspect defines the aspect ratio
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @returns a new matrix as a left-handed perspective projection matrix
  3459. */
  3460. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3461. /**
  3462. * Stores a left-handed perspective projection into a given matrix
  3463. * @param fov defines the horizontal field of view
  3464. * @param aspect defines the aspect ratio
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @param result defines the target matrix
  3468. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3469. */
  3470. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3471. /**
  3472. * Creates a right-handed perspective projection matrix
  3473. * @param fov defines the horizontal field of view
  3474. * @param aspect defines the aspect ratio
  3475. * @param znear defines the near clip plane
  3476. * @param zfar defines the far clip plane
  3477. * @returns a new matrix as a right-handed perspective projection matrix
  3478. */
  3479. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3480. /**
  3481. * Stores a right-handed perspective projection into a given matrix
  3482. * @param fov defines the horizontal field of view
  3483. * @param aspect defines the aspect ratio
  3484. * @param znear defines the near clip plane
  3485. * @param zfar defines the far clip plane
  3486. * @param result defines the target matrix
  3487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3488. */
  3489. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3490. /**
  3491. * Stores a perspective projection for WebVR info a given matrix
  3492. * @param fov defines the field of view
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @param result defines the target matrix
  3496. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3497. */
  3498. static PerspectiveFovWebVRToRef(fov: {
  3499. upDegrees: number;
  3500. downDegrees: number;
  3501. leftDegrees: number;
  3502. rightDegrees: number;
  3503. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3504. /**
  3505. * Computes a complete transformation matrix
  3506. * @param viewport defines the viewport to use
  3507. * @param world defines the world matrix
  3508. * @param view defines the view matrix
  3509. * @param projection defines the projection matrix
  3510. * @param zmin defines the near clip plane
  3511. * @param zmax defines the far clip plane
  3512. * @returns the transformation matrix
  3513. */
  3514. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3515. /**
  3516. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3517. * @param matrix defines the matrix to use
  3518. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3519. */
  3520. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3521. /**
  3522. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3523. * @param matrix defines the matrix to use
  3524. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3525. */
  3526. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3527. /**
  3528. * Compute the transpose of a given matrix
  3529. * @param matrix defines the matrix to transpose
  3530. * @returns the new matrix
  3531. */
  3532. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3533. /**
  3534. * Compute the transpose of a matrix and store it in a target matrix
  3535. * @param matrix defines the matrix to transpose
  3536. * @param result defines the target matrix
  3537. */
  3538. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3539. /**
  3540. * Computes a reflection matrix from a plane
  3541. * @param plane defines the reflection plane
  3542. * @returns a new matrix
  3543. */
  3544. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3545. /**
  3546. * Computes a reflection matrix from a plane
  3547. * @param plane defines the reflection plane
  3548. * @param result defines the target matrix
  3549. */
  3550. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3551. /**
  3552. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3553. * @param xaxis defines the value of the 1st axis
  3554. * @param yaxis defines the value of the 2nd axis
  3555. * @param zaxis defines the value of the 3rd axis
  3556. * @param result defines the target matrix
  3557. */
  3558. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3559. /**
  3560. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3561. * @param quat defines the quaternion to use
  3562. * @param result defines the target matrix
  3563. */
  3564. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3565. }
  3566. /**
  3567. * Represens a plane by the equation ax + by + cz + d = 0
  3568. */
  3569. export class Plane {
  3570. /**
  3571. * Normal of the plane (a,b,c)
  3572. */
  3573. normal: Vector3;
  3574. /**
  3575. * d component of the plane
  3576. */
  3577. d: number;
  3578. /**
  3579. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3580. * @param a a component of the plane
  3581. * @param b b component of the plane
  3582. * @param c c component of the plane
  3583. * @param d d component of the plane
  3584. */
  3585. constructor(a: number, b: number, c: number, d: number);
  3586. /**
  3587. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3588. */
  3589. asArray(): number[];
  3590. /**
  3591. * @returns a new plane copied from the current Plane.
  3592. */
  3593. clone(): Plane;
  3594. /**
  3595. * @returns the string "Plane".
  3596. */
  3597. getClassName(): string;
  3598. /**
  3599. * @returns the Plane hash code.
  3600. */
  3601. getHashCode(): number;
  3602. /**
  3603. * Normalize the current Plane in place.
  3604. * @returns the updated Plane.
  3605. */
  3606. normalize(): Plane;
  3607. /**
  3608. * Applies a transformation the plane and returns the result
  3609. * @param transformation the transformation matrix to be applied to the plane
  3610. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3611. */
  3612. transform(transformation: DeepImmutable<Matrix>): Plane;
  3613. /**
  3614. * Calcualtte the dot product between the point and the plane normal
  3615. * @param point point to calculate the dot product with
  3616. * @returns the dot product (float) of the point coordinates and the plane normal.
  3617. */
  3618. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3619. /**
  3620. * Updates the current Plane from the plane defined by the three given points.
  3621. * @param point1 one of the points used to contruct the plane
  3622. * @param point2 one of the points used to contruct the plane
  3623. * @param point3 one of the points used to contruct the plane
  3624. * @returns the updated Plane.
  3625. */
  3626. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3627. /**
  3628. * Checks if the plane is facing a given direction
  3629. * @param direction the direction to check if the plane is facing
  3630. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3631. * @returns True is the vector "direction" is the same side than the plane normal.
  3632. */
  3633. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3634. /**
  3635. * Calculates the distance to a point
  3636. * @param point point to calculate distance to
  3637. * @returns the signed distance (float) from the given point to the Plane.
  3638. */
  3639. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3640. /**
  3641. * Creates a plane from an array
  3642. * @param array the array to create a plane from
  3643. * @returns a new Plane from the given array.
  3644. */
  3645. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3646. /**
  3647. * Creates a plane from three points
  3648. * @param point1 point used to create the plane
  3649. * @param point2 point used to create the plane
  3650. * @param point3 point used to create the plane
  3651. * @returns a new Plane defined by the three given points.
  3652. */
  3653. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3654. /**
  3655. * Creates a plane from an origin point and a normal
  3656. * @param origin origin of the plane to be constructed
  3657. * @param normal normal of the plane to be constructed
  3658. * @returns a new Plane the normal vector to this plane at the given origin point.
  3659. * Note : the vector "normal" is updated because normalized.
  3660. */
  3661. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3662. /**
  3663. * Calculates the distance from a plane and a point
  3664. * @param origin origin of the plane to be constructed
  3665. * @param normal normal of the plane to be constructed
  3666. * @param point point to calculate distance to
  3667. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3668. */
  3669. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3670. }
  3671. /**
  3672. * Class used to represent a viewport on screen
  3673. */
  3674. export class Viewport {
  3675. /** viewport left coordinate */
  3676. x: number;
  3677. /** viewport top coordinate */
  3678. y: number;
  3679. /**viewport width */
  3680. width: number;
  3681. /** viewport height */
  3682. height: number;
  3683. /**
  3684. * Creates a Viewport object located at (x, y) and sized (width, height)
  3685. * @param x defines viewport left coordinate
  3686. * @param y defines viewport top coordinate
  3687. * @param width defines the viewport width
  3688. * @param height defines the viewport height
  3689. */
  3690. constructor(
  3691. /** viewport left coordinate */
  3692. x: number,
  3693. /** viewport top coordinate */
  3694. y: number,
  3695. /**viewport width */
  3696. width: number,
  3697. /** viewport height */
  3698. height: number);
  3699. /**
  3700. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3701. * @param renderWidth defines the rendering width
  3702. * @param renderHeight defines the rendering height
  3703. * @returns a new Viewport
  3704. */
  3705. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3706. /**
  3707. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3708. * @param renderWidth defines the rendering width
  3709. * @param renderHeight defines the rendering height
  3710. * @param ref defines the target viewport
  3711. * @returns the current viewport
  3712. */
  3713. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3714. /**
  3715. * Returns a new Viewport copied from the current one
  3716. * @returns a new Viewport
  3717. */
  3718. clone(): Viewport;
  3719. }
  3720. /**
  3721. * Reprasents a camera frustum
  3722. */
  3723. export class Frustum {
  3724. /**
  3725. * Gets the planes representing the frustum
  3726. * @param transform matrix to be applied to the returned planes
  3727. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3728. */
  3729. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3730. /**
  3731. * Gets the near frustum plane transformed by the transform matrix
  3732. * @param transform transformation matrix to be applied to the resulting frustum plane
  3733. * @param frustumPlane the resuling frustum plane
  3734. */
  3735. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3736. /**
  3737. * Gets the far frustum plane transformed by the transform matrix
  3738. * @param transform transformation matrix to be applied to the resulting frustum plane
  3739. * @param frustumPlane the resuling frustum plane
  3740. */
  3741. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3742. /**
  3743. * Gets the left frustum plane transformed by the transform matrix
  3744. * @param transform transformation matrix to be applied to the resulting frustum plane
  3745. * @param frustumPlane the resuling frustum plane
  3746. */
  3747. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3748. /**
  3749. * Gets the right frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the top frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the bottom frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3768. * @param transform transformation matrix to be applied to the resulting frustum planes
  3769. * @param frustumPlanes the resuling frustum planes
  3770. */
  3771. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3772. }
  3773. /** Defines supported spaces */
  3774. export enum Space {
  3775. /** Local (object) space */
  3776. LOCAL = 0,
  3777. /** World space */
  3778. WORLD = 1,
  3779. /** Bone space */
  3780. BONE = 2
  3781. }
  3782. /** Defines the 3 main axes */
  3783. export class Axis {
  3784. /** X axis */
  3785. static X: Vector3;
  3786. /** Y axis */
  3787. static Y: Vector3;
  3788. /** Z axis */
  3789. static Z: Vector3;
  3790. }
  3791. /** Class used to represent a Bezier curve */
  3792. export class BezierCurve {
  3793. /**
  3794. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3795. * @param t defines the time
  3796. * @param x1 defines the left coordinate on X axis
  3797. * @param y1 defines the left coordinate on Y axis
  3798. * @param x2 defines the right coordinate on X axis
  3799. * @param y2 defines the right coordinate on Y axis
  3800. * @returns the interpolated value
  3801. */
  3802. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3803. }
  3804. /**
  3805. * Defines potential orientation for back face culling
  3806. */
  3807. export enum Orientation {
  3808. /**
  3809. * Clockwise
  3810. */
  3811. CW = 0,
  3812. /** Counter clockwise */
  3813. CCW = 1
  3814. }
  3815. /**
  3816. * Defines angle representation
  3817. */
  3818. export class Angle {
  3819. private _radians;
  3820. /**
  3821. * Creates an Angle object of "radians" radians (float).
  3822. * @param radians the angle in radians
  3823. */
  3824. constructor(radians: number);
  3825. /**
  3826. * Get value in degrees
  3827. * @returns the Angle value in degrees (float)
  3828. */
  3829. degrees(): number;
  3830. /**
  3831. * Get value in radians
  3832. * @returns the Angle value in radians (float)
  3833. */
  3834. radians(): number;
  3835. /**
  3836. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3837. * @param a defines first vector
  3838. * @param b defines second vector
  3839. * @returns a new Angle
  3840. */
  3841. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3842. /**
  3843. * Gets a new Angle object from the given float in radians
  3844. * @param radians defines the angle value in radians
  3845. * @returns a new Angle
  3846. */
  3847. static FromRadians(radians: number): Angle;
  3848. /**
  3849. * Gets a new Angle object from the given float in degrees
  3850. * @param degrees defines the angle value in degrees
  3851. * @returns a new Angle
  3852. */
  3853. static FromDegrees(degrees: number): Angle;
  3854. }
  3855. /**
  3856. * This represents an arc in a 2d space.
  3857. */
  3858. export class Arc2 {
  3859. /** Defines the start point of the arc */
  3860. startPoint: Vector2;
  3861. /** Defines the mid point of the arc */
  3862. midPoint: Vector2;
  3863. /** Defines the end point of the arc */
  3864. endPoint: Vector2;
  3865. /**
  3866. * Defines the center point of the arc.
  3867. */
  3868. centerPoint: Vector2;
  3869. /**
  3870. * Defines the radius of the arc.
  3871. */
  3872. radius: number;
  3873. /**
  3874. * Defines the angle of the arc (from mid point to end point).
  3875. */
  3876. angle: Angle;
  3877. /**
  3878. * Defines the start angle of the arc (from start point to middle point).
  3879. */
  3880. startAngle: Angle;
  3881. /**
  3882. * Defines the orientation of the arc (clock wise/counter clock wise).
  3883. */
  3884. orientation: Orientation;
  3885. /**
  3886. * Creates an Arc object from the three given points : start, middle and end.
  3887. * @param startPoint Defines the start point of the arc
  3888. * @param midPoint Defines the midlle point of the arc
  3889. * @param endPoint Defines the end point of the arc
  3890. */
  3891. constructor(
  3892. /** Defines the start point of the arc */
  3893. startPoint: Vector2,
  3894. /** Defines the mid point of the arc */
  3895. midPoint: Vector2,
  3896. /** Defines the end point of the arc */
  3897. endPoint: Vector2);
  3898. }
  3899. /**
  3900. * Represents a 2D path made up of multiple 2D points
  3901. */
  3902. export class Path2 {
  3903. private _points;
  3904. private _length;
  3905. /**
  3906. * If the path start and end point are the same
  3907. */
  3908. closed: boolean;
  3909. /**
  3910. * Creates a Path2 object from the starting 2D coordinates x and y.
  3911. * @param x the starting points x value
  3912. * @param y the starting points y value
  3913. */
  3914. constructor(x: number, y: number);
  3915. /**
  3916. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3917. * @param x the added points x value
  3918. * @param y the added points y value
  3919. * @returns the updated Path2.
  3920. */
  3921. addLineTo(x: number, y: number): Path2;
  3922. /**
  3923. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3924. * @param midX middle point x value
  3925. * @param midY middle point y value
  3926. * @param endX end point x value
  3927. * @param endY end point y value
  3928. * @param numberOfSegments (default: 36)
  3929. * @returns the updated Path2.
  3930. */
  3931. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3932. /**
  3933. * Closes the Path2.
  3934. * @returns the Path2.
  3935. */
  3936. close(): Path2;
  3937. /**
  3938. * Gets the sum of the distance between each sequential point in the path
  3939. * @returns the Path2 total length (float).
  3940. */
  3941. length(): number;
  3942. /**
  3943. * Gets the points which construct the path
  3944. * @returns the Path2 internal array of points.
  3945. */
  3946. getPoints(): Vector2[];
  3947. /**
  3948. * Retreives the point at the distance aways from the starting point
  3949. * @param normalizedLengthPosition the length along the path to retreive the point from
  3950. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3951. */
  3952. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3953. /**
  3954. * Creates a new path starting from an x and y position
  3955. * @param x starting x value
  3956. * @param y starting y value
  3957. * @returns a new Path2 starting at the coordinates (x, y).
  3958. */
  3959. static StartingAt(x: number, y: number): Path2;
  3960. }
  3961. /**
  3962. * Represents a 3D path made up of multiple 3D points
  3963. */
  3964. export class Path3D {
  3965. /**
  3966. * an array of Vector3, the curve axis of the Path3D
  3967. */
  3968. path: Vector3[];
  3969. private _curve;
  3970. private _distances;
  3971. private _tangents;
  3972. private _normals;
  3973. private _binormals;
  3974. private _raw;
  3975. /**
  3976. * new Path3D(path, normal, raw)
  3977. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3978. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3979. * @param path an array of Vector3, the curve axis of the Path3D
  3980. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3981. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3982. */
  3983. constructor(
  3984. /**
  3985. * an array of Vector3, the curve axis of the Path3D
  3986. */
  3987. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3988. /**
  3989. * Returns the Path3D array of successive Vector3 designing its curve.
  3990. * @returns the Path3D array of successive Vector3 designing its curve.
  3991. */
  3992. getCurve(): Vector3[];
  3993. /**
  3994. * Returns an array populated with tangent vectors on each Path3D curve point.
  3995. * @returns an array populated with tangent vectors on each Path3D curve point.
  3996. */
  3997. getTangents(): Vector3[];
  3998. /**
  3999. * Returns an array populated with normal vectors on each Path3D curve point.
  4000. * @returns an array populated with normal vectors on each Path3D curve point.
  4001. */
  4002. getNormals(): Vector3[];
  4003. /**
  4004. * Returns an array populated with binormal vectors on each Path3D curve point.
  4005. * @returns an array populated with binormal vectors on each Path3D curve point.
  4006. */
  4007. getBinormals(): Vector3[];
  4008. /**
  4009. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4010. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. */
  4012. getDistances(): number[];
  4013. /**
  4014. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4015. * @param path path which all values are copied into the curves points
  4016. * @param firstNormal which should be projected onto the curve
  4017. * @returns the same object updated.
  4018. */
  4019. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4020. private _compute;
  4021. private _getFirstNonNullVector;
  4022. private _getLastNonNullVector;
  4023. private _normalVector;
  4024. }
  4025. /**
  4026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4027. * A Curve3 is designed from a series of successive Vector3.
  4028. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4029. */
  4030. export class Curve3 {
  4031. private _points;
  4032. private _length;
  4033. /**
  4034. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4035. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4036. * @param v1 (Vector3) the control point
  4037. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4038. * @param nbPoints (integer) the wanted number of points in the curve
  4039. * @returns the created Curve3
  4040. */
  4041. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4042. /**
  4043. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4044. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4045. * @param v1 (Vector3) the first control point
  4046. * @param v2 (Vector3) the second control point
  4047. * @param v3 (Vector3) the end point of the Cubic Bezier
  4048. * @param nbPoints (integer) the wanted number of points in the curve
  4049. * @returns the created Curve3
  4050. */
  4051. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4052. /**
  4053. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4054. * @param p1 (Vector3) the origin point of the Hermite Spline
  4055. * @param t1 (Vector3) the tangent vector at the origin point
  4056. * @param p2 (Vector3) the end point of the Hermite Spline
  4057. * @param t2 (Vector3) the tangent vector at the end point
  4058. * @param nbPoints (integer) the wanted number of points in the curve
  4059. * @returns the created Curve3
  4060. */
  4061. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4062. /**
  4063. * Returns a Curve3 object along a CatmullRom Spline curve :
  4064. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4065. * @param nbPoints (integer) the wanted number of points between each curve control points
  4066. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4070. /**
  4071. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4072. * A Curve3 is designed from a series of successive Vector3.
  4073. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4074. * @param points points which make up the curve
  4075. */
  4076. constructor(points: Vector3[]);
  4077. /**
  4078. * @returns the Curve3 stored array of successive Vector3
  4079. */
  4080. getPoints(): Vector3[];
  4081. /**
  4082. * @returns the computed length (float) of the curve.
  4083. */
  4084. length(): number;
  4085. /**
  4086. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4087. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4088. * curveA and curveB keep unchanged.
  4089. * @param curve the curve to continue from this curve
  4090. * @returns the newly constructed curve
  4091. */
  4092. continue(curve: DeepImmutable<Curve3>): Curve3;
  4093. private _computeLength;
  4094. }
  4095. /**
  4096. * Contains position and normal vectors for a vertex
  4097. */
  4098. export class PositionNormalVertex {
  4099. /** the position of the vertex (defaut: 0,0,0) */
  4100. position: Vector3;
  4101. /** the normal of the vertex (defaut: 0,1,0) */
  4102. normal: Vector3;
  4103. /**
  4104. * Creates a PositionNormalVertex
  4105. * @param position the position of the vertex (defaut: 0,0,0)
  4106. * @param normal the normal of the vertex (defaut: 0,1,0)
  4107. */
  4108. constructor(
  4109. /** the position of the vertex (defaut: 0,0,0) */
  4110. position?: Vector3,
  4111. /** the normal of the vertex (defaut: 0,1,0) */
  4112. normal?: Vector3);
  4113. /**
  4114. * Clones the PositionNormalVertex
  4115. * @returns the cloned PositionNormalVertex
  4116. */
  4117. clone(): PositionNormalVertex;
  4118. }
  4119. /**
  4120. * Contains position, normal and uv vectors for a vertex
  4121. */
  4122. export class PositionNormalTextureVertex {
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position: Vector3;
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal: Vector3;
  4127. /** the uv of the vertex (default: 0,0) */
  4128. uv: Vector2;
  4129. /**
  4130. * Creates a PositionNormalTextureVertex
  4131. * @param position the position of the vertex (defaut: 0,0,0)
  4132. * @param normal the normal of the vertex (defaut: 0,1,0)
  4133. * @param uv the uv of the vertex (default: 0,0)
  4134. */
  4135. constructor(
  4136. /** the position of the vertex (defaut: 0,0,0) */
  4137. position?: Vector3,
  4138. /** the normal of the vertex (defaut: 0,1,0) */
  4139. normal?: Vector3,
  4140. /** the uv of the vertex (default: 0,0) */
  4141. uv?: Vector2);
  4142. /**
  4143. * Clones the PositionNormalTextureVertex
  4144. * @returns the cloned PositionNormalTextureVertex
  4145. */
  4146. clone(): PositionNormalTextureVertex;
  4147. }
  4148. /**
  4149. * @hidden
  4150. */
  4151. export class Tmp {
  4152. static Color3: Color3[];
  4153. static Color4: Color4[];
  4154. static Vector2: Vector2[];
  4155. static Vector3: Vector3[];
  4156. static Vector4: Vector4[];
  4157. static Quaternion: Quaternion[];
  4158. static Matrix: Matrix[];
  4159. }
  4160. }
  4161. declare module BABYLON {
  4162. /**
  4163. * Class used to enable access to offline support
  4164. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4165. */
  4166. export interface IOfflineProvider {
  4167. /**
  4168. * Gets a boolean indicating if scene must be saved in the database
  4169. */
  4170. enableSceneOffline: boolean;
  4171. /**
  4172. * Gets a boolean indicating if textures must be saved in the database
  4173. */
  4174. enableTexturesOffline: boolean;
  4175. /**
  4176. * Open the offline support and make it available
  4177. * @param successCallback defines the callback to call on success
  4178. * @param errorCallback defines the callback to call on error
  4179. */
  4180. open(successCallback: () => void, errorCallback: () => void): void;
  4181. /**
  4182. * Loads an image from the offline support
  4183. * @param url defines the url to load from
  4184. * @param image defines the target DOM image
  4185. */
  4186. loadImage(url: string, image: HTMLImageElement): void;
  4187. /**
  4188. * Loads a file from offline support
  4189. * @param url defines the URL to load from
  4190. * @param sceneLoaded defines a callback to call on success
  4191. * @param progressCallBack defines a callback to call when progress changed
  4192. * @param errorCallback defines a callback to call on error
  4193. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4194. */
  4195. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4196. }
  4197. }
  4198. declare module BABYLON {
  4199. /**
  4200. * A class serves as a medium between the observable and its observers
  4201. */
  4202. export class EventState {
  4203. /**
  4204. * Create a new EventState
  4205. * @param mask defines the mask associated with this state
  4206. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4207. * @param target defines the original target of the state
  4208. * @param currentTarget defines the current target of the state
  4209. */
  4210. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4211. /**
  4212. * Initialize the current event state
  4213. * @param mask defines the mask associated with this state
  4214. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4215. * @param target defines the original target of the state
  4216. * @param currentTarget defines the current target of the state
  4217. * @returns the current event state
  4218. */
  4219. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4220. /**
  4221. * An Observer can set this property to true to prevent subsequent observers of being notified
  4222. */
  4223. skipNextObservers: boolean;
  4224. /**
  4225. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4226. */
  4227. mask: number;
  4228. /**
  4229. * The object that originally notified the event
  4230. */
  4231. target?: any;
  4232. /**
  4233. * The current object in the bubbling phase
  4234. */
  4235. currentTarget?: any;
  4236. /**
  4237. * This will be populated with the return value of the last function that was executed.
  4238. * If it is the first function in the callback chain it will be the event data.
  4239. */
  4240. lastReturnValue?: any;
  4241. }
  4242. /**
  4243. * Represent an Observer registered to a given Observable object.
  4244. */
  4245. export class Observer<T> {
  4246. /**
  4247. * Defines the callback to call when the observer is notified
  4248. */
  4249. callback: (eventData: T, eventState: EventState) => void;
  4250. /**
  4251. * Defines the mask of the observer (used to filter notifications)
  4252. */
  4253. mask: number;
  4254. /**
  4255. * Defines the current scope used to restore the JS context
  4256. */
  4257. scope: any;
  4258. /** @hidden */
  4259. _willBeUnregistered: boolean;
  4260. /**
  4261. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4262. */
  4263. unregisterOnNextCall: boolean;
  4264. /**
  4265. * Creates a new observer
  4266. * @param callback defines the callback to call when the observer is notified
  4267. * @param mask defines the mask of the observer (used to filter notifications)
  4268. * @param scope defines the current scope used to restore the JS context
  4269. */
  4270. constructor(
  4271. /**
  4272. * Defines the callback to call when the observer is notified
  4273. */
  4274. callback: (eventData: T, eventState: EventState) => void,
  4275. /**
  4276. * Defines the mask of the observer (used to filter notifications)
  4277. */
  4278. mask: number,
  4279. /**
  4280. * Defines the current scope used to restore the JS context
  4281. */
  4282. scope?: any);
  4283. }
  4284. /**
  4285. * Represent a list of observers registered to multiple Observables object.
  4286. */
  4287. export class MultiObserver<T> {
  4288. private _observers;
  4289. private _observables;
  4290. /**
  4291. * Release associated resources
  4292. */
  4293. dispose(): void;
  4294. /**
  4295. * Raise a callback when one of the observable will notify
  4296. * @param observables defines a list of observables to watch
  4297. * @param callback defines the callback to call on notification
  4298. * @param mask defines the mask used to filter notifications
  4299. * @param scope defines the current scope used to restore the JS context
  4300. * @returns the new MultiObserver
  4301. */
  4302. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4303. }
  4304. /**
  4305. * The Observable class is a simple implementation of the Observable pattern.
  4306. *
  4307. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4308. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4309. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4310. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4311. */
  4312. export class Observable<T> {
  4313. private _observers;
  4314. private _eventState;
  4315. private _onObserverAdded;
  4316. /**
  4317. * Creates a new observable
  4318. * @param onObserverAdded defines a callback to call when a new observer is added
  4319. */
  4320. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4321. /**
  4322. * Create a new Observer with the specified callback
  4323. * @param callback the callback that will be executed for that Observer
  4324. * @param mask the mask used to filter observers
  4325. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4326. * @param scope optional scope for the callback to be called from
  4327. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4328. * @returns the new observer created for the callback
  4329. */
  4330. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4331. /**
  4332. * Create a new Observer with the specified callback and unregisters after the next notification
  4333. * @param callback the callback that will be executed for that Observer
  4334. * @returns the new observer created for the callback
  4335. */
  4336. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4337. /**
  4338. * Remove an Observer from the Observable object
  4339. * @param observer the instance of the Observer to remove
  4340. * @returns false if it doesn't belong to this Observable
  4341. */
  4342. remove(observer: Nullable<Observer<T>>): boolean;
  4343. /**
  4344. * Remove a callback from the Observable object
  4345. * @param callback the callback to remove
  4346. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4347. * @returns false if it doesn't belong to this Observable
  4348. */
  4349. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4350. private _deferUnregister;
  4351. private _remove;
  4352. /**
  4353. * Notify all Observers by calling their respective callback with the given data
  4354. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4355. * @param eventData defines the data to send to all observers
  4356. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4357. * @param target defines the original target of the state
  4358. * @param currentTarget defines the current target of the state
  4359. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4360. */
  4361. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4362. /**
  4363. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4364. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4365. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4366. * and it is crucial that all callbacks will be executed.
  4367. * The order of the callbacks is kept, callbacks are not executed parallel.
  4368. *
  4369. * @param eventData The data to be sent to each callback
  4370. * @param mask is used to filter observers defaults to -1
  4371. * @param target defines the callback target (see EventState)
  4372. * @param currentTarget defines he current object in the bubbling phase
  4373. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4374. */
  4375. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4376. /**
  4377. * Notify a specific observer
  4378. * @param observer defines the observer to notify
  4379. * @param eventData defines the data to be sent to each callback
  4380. * @param mask is used to filter observers defaults to -1
  4381. */
  4382. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4383. /**
  4384. * Gets a boolean indicating if the observable has at least one observer
  4385. * @returns true is the Observable has at least one Observer registered
  4386. */
  4387. hasObservers(): boolean;
  4388. /**
  4389. * Clear the list of observers
  4390. */
  4391. clear(): void;
  4392. /**
  4393. * Clone the current observable
  4394. * @returns a new observable
  4395. */
  4396. clone(): Observable<T>;
  4397. /**
  4398. * Does this observable handles observer registered with a given mask
  4399. * @param mask defines the mask to be tested
  4400. * @return whether or not one observer registered with the given mask is handeled
  4401. **/
  4402. hasSpecificMask(mask?: number): boolean;
  4403. }
  4404. }
  4405. declare module BABYLON {
  4406. /**
  4407. * Class used to help managing file picking and drag'n'drop
  4408. * File Storage
  4409. */
  4410. export class FilesInputStore {
  4411. /**
  4412. * List of files ready to be loaded
  4413. */
  4414. static FilesToLoad: {
  4415. [key: string]: File;
  4416. };
  4417. }
  4418. }
  4419. declare module BABYLON {
  4420. /** Defines the cross module used constants to avoid circular dependncies */
  4421. export class Constants {
  4422. /** Defines that alpha blending is disabled */
  4423. static readonly ALPHA_DISABLE: number;
  4424. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4425. static readonly ALPHA_ADD: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4427. static readonly ALPHA_COMBINE: number;
  4428. /** Defines that alpha blending to DEST - SRC * DEST */
  4429. static readonly ALPHA_SUBTRACT: number;
  4430. /** Defines that alpha blending to SRC * DEST */
  4431. static readonly ALPHA_MULTIPLY: number;
  4432. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4433. static readonly ALPHA_MAXIMIZED: number;
  4434. /** Defines that alpha blending to SRC + DEST */
  4435. static readonly ALPHA_ONEONE: number;
  4436. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4437. static readonly ALPHA_PREMULTIPLIED: number;
  4438. /**
  4439. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4440. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4441. */
  4442. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4443. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4444. static readonly ALPHA_INTERPOLATE: number;
  4445. /**
  4446. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4447. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4448. */
  4449. static readonly ALPHA_SCREENMODE: number;
  4450. /** Defines that the ressource is not delayed*/
  4451. static readonly DELAYLOADSTATE_NONE: number;
  4452. /** Defines that the ressource was successfully delay loaded */
  4453. static readonly DELAYLOADSTATE_LOADED: number;
  4454. /** Defines that the ressource is currently delay loading */
  4455. static readonly DELAYLOADSTATE_LOADING: number;
  4456. /** Defines that the ressource is delayed and has not started loading */
  4457. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4458. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4459. static readonly NEVER: number;
  4460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4461. static readonly ALWAYS: number;
  4462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4463. static readonly LESS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4465. static readonly EQUAL: number;
  4466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4467. static readonly LEQUAL: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4469. static readonly GREATER: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4471. static readonly GEQUAL: number;
  4472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4473. static readonly NOTEQUAL: number;
  4474. /** Passed to stencilOperation to specify that stencil value must be kept */
  4475. static readonly KEEP: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4477. static readonly REPLACE: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4479. static readonly INCR: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4481. static readonly DECR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4483. static readonly INVERT: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4485. static readonly INCR_WRAP: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4487. static readonly DECR_WRAP: number;
  4488. /** Texture is not repeating outside of 0..1 UVs */
  4489. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4490. /** Texture is repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4492. /** Texture is repeating and mirrored */
  4493. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4494. /** ALPHA */
  4495. static readonly TEXTUREFORMAT_ALPHA: number;
  4496. /** LUMINANCE */
  4497. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4498. /** LUMINANCE_ALPHA */
  4499. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4500. /** RGB */
  4501. static readonly TEXTUREFORMAT_RGB: number;
  4502. /** RGBA */
  4503. static readonly TEXTUREFORMAT_RGBA: number;
  4504. /** RED */
  4505. static readonly TEXTUREFORMAT_RED: number;
  4506. /** RED (2nd reference) */
  4507. static readonly TEXTUREFORMAT_R: number;
  4508. /** RG */
  4509. static readonly TEXTUREFORMAT_RG: number;
  4510. /** RED_INTEGER */
  4511. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4512. /** RED_INTEGER (2nd reference) */
  4513. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4514. /** RG_INTEGER */
  4515. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4516. /** RGB_INTEGER */
  4517. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4518. /** RGBA_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4520. /** UNSIGNED_BYTE */
  4521. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4522. /** UNSIGNED_BYTE (2nd reference) */
  4523. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4524. /** FLOAT */
  4525. static readonly TEXTURETYPE_FLOAT: number;
  4526. /** HALF_FLOAT */
  4527. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4528. /** BYTE */
  4529. static readonly TEXTURETYPE_BYTE: number;
  4530. /** SHORT */
  4531. static readonly TEXTURETYPE_SHORT: number;
  4532. /** UNSIGNED_SHORT */
  4533. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4534. /** INT */
  4535. static readonly TEXTURETYPE_INT: number;
  4536. /** UNSIGNED_INT */
  4537. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4538. /** UNSIGNED_SHORT_4_4_4_4 */
  4539. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4540. /** UNSIGNED_SHORT_5_5_5_1 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4542. /** UNSIGNED_SHORT_5_6_5 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4544. /** UNSIGNED_INT_2_10_10_10_REV */
  4545. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4546. /** UNSIGNED_INT_24_8 */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4548. /** UNSIGNED_INT_10F_11F_11F_REV */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4550. /** UNSIGNED_INT_5_9_9_9_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4552. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4553. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4554. /** nearest is mag = nearest and min = nearest and mip = linear */
  4555. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4556. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4557. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4558. /** Trilinear is mag = linear and min = linear and mip = linear */
  4559. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4560. /** nearest is mag = nearest and min = nearest and mip = linear */
  4561. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4562. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4563. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4564. /** Trilinear is mag = linear and min = linear and mip = linear */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4566. /** mag = nearest and min = nearest and mip = nearest */
  4567. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4568. /** mag = nearest and min = linear and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = linear */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4572. /** mag = nearest and min = linear and mip = none */
  4573. static readonly TEXTURE_NEAREST_LINEAR: number;
  4574. /** mag = nearest and min = nearest and mip = none */
  4575. static readonly TEXTURE_NEAREST_NEAREST: number;
  4576. /** mag = linear and min = nearest and mip = nearest */
  4577. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4578. /** mag = linear and min = nearest and mip = linear */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4580. /** mag = linear and min = linear and mip = none */
  4581. static readonly TEXTURE_LINEAR_LINEAR: number;
  4582. /** mag = linear and min = nearest and mip = none */
  4583. static readonly TEXTURE_LINEAR_NEAREST: number;
  4584. /** Explicit coordinates mode */
  4585. static readonly TEXTURE_EXPLICIT_MODE: number;
  4586. /** Spherical coordinates mode */
  4587. static readonly TEXTURE_SPHERICAL_MODE: number;
  4588. /** Planar coordinates mode */
  4589. static readonly TEXTURE_PLANAR_MODE: number;
  4590. /** Cubic coordinates mode */
  4591. static readonly TEXTURE_CUBIC_MODE: number;
  4592. /** Projection coordinates mode */
  4593. static readonly TEXTURE_PROJECTION_MODE: number;
  4594. /** Skybox coordinates mode */
  4595. static readonly TEXTURE_SKYBOX_MODE: number;
  4596. /** Inverse Cubic coordinates mode */
  4597. static readonly TEXTURE_INVCUBIC_MODE: number;
  4598. /** Equirectangular coordinates mode */
  4599. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4600. /** Equirectangular Fixed coordinates mode */
  4601. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed Mirrored coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4604. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4605. static readonly SCALEMODE_FLOOR: number;
  4606. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4607. static readonly SCALEMODE_NEAREST: number;
  4608. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4609. static readonly SCALEMODE_CEILING: number;
  4610. /**
  4611. * The dirty texture flag value
  4612. */
  4613. static readonly MATERIAL_TextureDirtyFlag: number;
  4614. /**
  4615. * The dirty light flag value
  4616. */
  4617. static readonly MATERIAL_LightDirtyFlag: number;
  4618. /**
  4619. * The dirty fresnel flag value
  4620. */
  4621. static readonly MATERIAL_FresnelDirtyFlag: number;
  4622. /**
  4623. * The dirty attribute flag value
  4624. */
  4625. static readonly MATERIAL_AttributesDirtyFlag: number;
  4626. /**
  4627. * The dirty misc flag value
  4628. */
  4629. static readonly MATERIAL_MiscDirtyFlag: number;
  4630. /**
  4631. * The all dirty flag value
  4632. */
  4633. static readonly MATERIAL_AllDirtyFlag: number;
  4634. /**
  4635. * Returns the triangle fill mode
  4636. */
  4637. static readonly MATERIAL_TriangleFillMode: number;
  4638. /**
  4639. * Returns the wireframe mode
  4640. */
  4641. static readonly MATERIAL_WireFrameFillMode: number;
  4642. /**
  4643. * Returns the point fill mode
  4644. */
  4645. static readonly MATERIAL_PointFillMode: number;
  4646. /**
  4647. * Returns the point list draw mode
  4648. */
  4649. static readonly MATERIAL_PointListDrawMode: number;
  4650. /**
  4651. * Returns the line list draw mode
  4652. */
  4653. static readonly MATERIAL_LineListDrawMode: number;
  4654. /**
  4655. * Returns the line loop draw mode
  4656. */
  4657. static readonly MATERIAL_LineLoopDrawMode: number;
  4658. /**
  4659. * Returns the line strip draw mode
  4660. */
  4661. static readonly MATERIAL_LineStripDrawMode: number;
  4662. /**
  4663. * Returns the triangle strip draw mode
  4664. */
  4665. static readonly MATERIAL_TriangleStripDrawMode: number;
  4666. /**
  4667. * Returns the triangle fan draw mode
  4668. */
  4669. static readonly MATERIAL_TriangleFanDrawMode: number;
  4670. /**
  4671. * Stores the clock-wise side orientation
  4672. */
  4673. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4674. /**
  4675. * Stores the counter clock-wise side orientation
  4676. */
  4677. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4678. /**
  4679. * Nothing
  4680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4681. */
  4682. static readonly ACTION_NothingTrigger: number;
  4683. /**
  4684. * On pick
  4685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4686. */
  4687. static readonly ACTION_OnPickTrigger: number;
  4688. /**
  4689. * On left pick
  4690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4691. */
  4692. static readonly ACTION_OnLeftPickTrigger: number;
  4693. /**
  4694. * On right pick
  4695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4696. */
  4697. static readonly ACTION_OnRightPickTrigger: number;
  4698. /**
  4699. * On center pick
  4700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4701. */
  4702. static readonly ACTION_OnCenterPickTrigger: number;
  4703. /**
  4704. * On pick down
  4705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4706. */
  4707. static readonly ACTION_OnPickDownTrigger: number;
  4708. /**
  4709. * On double pick
  4710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4711. */
  4712. static readonly ACTION_OnDoublePickTrigger: number;
  4713. /**
  4714. * On pick up
  4715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4716. */
  4717. static readonly ACTION_OnPickUpTrigger: number;
  4718. /**
  4719. * On pick out.
  4720. * This trigger will only be raised if you also declared a OnPickDown
  4721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4722. */
  4723. static readonly ACTION_OnPickOutTrigger: number;
  4724. /**
  4725. * On long press
  4726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4727. */
  4728. static readonly ACTION_OnLongPressTrigger: number;
  4729. /**
  4730. * On pointer over
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPointerOverTrigger: number;
  4734. /**
  4735. * On pointer out
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnPointerOutTrigger: number;
  4739. /**
  4740. * On every frame
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnEveryFrameTrigger: number;
  4744. /**
  4745. * On intersection enter
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4749. /**
  4750. * On intersection exit
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnIntersectionExitTrigger: number;
  4754. /**
  4755. * On key down
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnKeyDownTrigger: number;
  4759. /**
  4760. * On key up
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnKeyUpTrigger: number;
  4764. /**
  4765. * Billboard mode will only apply to Y axis
  4766. */
  4767. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4768. /**
  4769. * Billboard mode will apply to all axes
  4770. */
  4771. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4772. /**
  4773. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4774. */
  4775. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4776. /**
  4777. * Gets or sets base Assets URL
  4778. */
  4779. static readonly PARTICLES_BaseAssetsUrl: string;
  4780. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4781. * Test order :
  4782. * Is the bounding sphere outside the frustum ?
  4783. * If not, are the bounding box vertices outside the frustum ?
  4784. * It not, then the cullable object is in the frustum.
  4785. */
  4786. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4787. /** Culling strategy : Bounding Sphere Only.
  4788. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4789. * It's also less accurate than the standard because some not visible objects can still be selected.
  4790. * Test : is the bounding sphere outside the frustum ?
  4791. * If not, then the cullable object is in the frustum.
  4792. */
  4793. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4794. /** Culling strategy : Optimistic Inclusion.
  4795. * This in an inclusion test first, then the standard exclusion test.
  4796. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4797. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4798. * Anyway, it's as accurate as the standard strategy.
  4799. * Test :
  4800. * Is the cullable object bounding sphere center in the frustum ?
  4801. * If not, apply the default culling strategy.
  4802. */
  4803. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4804. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4805. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4806. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4807. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4808. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4809. * Test :
  4810. * Is the cullable object bounding sphere center in the frustum ?
  4811. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4812. */
  4813. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4814. /**
  4815. * No logging while loading
  4816. */
  4817. static readonly SCENELOADER_NO_LOGGING: number;
  4818. /**
  4819. * Minimal logging while loading
  4820. */
  4821. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4822. /**
  4823. * Summary logging while loading
  4824. */
  4825. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4826. /**
  4827. * Detailled logging while loading
  4828. */
  4829. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4830. }
  4831. }
  4832. declare module BABYLON {
  4833. /**
  4834. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4835. * Babylon.js
  4836. */
  4837. export class DomManagement {
  4838. /**
  4839. * Checks if the window object exists
  4840. * @returns true if the window object exists
  4841. */
  4842. static IsWindowObjectExist(): boolean;
  4843. /**
  4844. * Extracts text content from a DOM element hierarchy
  4845. * @param element defines the root element
  4846. * @returns a string
  4847. */
  4848. static GetDOMTextContent(element: HTMLElement): string;
  4849. }
  4850. }
  4851. declare module BABYLON {
  4852. /**
  4853. * Logger used througouht the application to allow configuration of
  4854. * the log level required for the messages.
  4855. */
  4856. export class Logger {
  4857. /**
  4858. * No log
  4859. */
  4860. static readonly NoneLogLevel: number;
  4861. /**
  4862. * Only message logs
  4863. */
  4864. static readonly MessageLogLevel: number;
  4865. /**
  4866. * Only warning logs
  4867. */
  4868. static readonly WarningLogLevel: number;
  4869. /**
  4870. * Only error logs
  4871. */
  4872. static readonly ErrorLogLevel: number;
  4873. /**
  4874. * All logs
  4875. */
  4876. static readonly AllLogLevel: number;
  4877. private static _LogCache;
  4878. /**
  4879. * Gets a value indicating the number of loading errors
  4880. * @ignorenaming
  4881. */
  4882. static errorsCount: number;
  4883. /**
  4884. * Callback called when a new log is added
  4885. */
  4886. static OnNewCacheEntry: (entry: string) => void;
  4887. private static _AddLogEntry;
  4888. private static _FormatMessage;
  4889. private static _LogDisabled;
  4890. private static _LogEnabled;
  4891. private static _WarnDisabled;
  4892. private static _WarnEnabled;
  4893. private static _ErrorDisabled;
  4894. private static _ErrorEnabled;
  4895. /**
  4896. * Log a message to the console
  4897. */
  4898. static Log: (message: string) => void;
  4899. /**
  4900. * Write a warning message to the console
  4901. */
  4902. static Warn: (message: string) => void;
  4903. /**
  4904. * Write an error message to the console
  4905. */
  4906. static Error: (message: string) => void;
  4907. /**
  4908. * Gets current log cache (list of logs)
  4909. */
  4910. static readonly LogCache: string;
  4911. /**
  4912. * Clears the log cache
  4913. */
  4914. static ClearLogCache(): void;
  4915. /**
  4916. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4917. */
  4918. static LogLevels: number;
  4919. }
  4920. }
  4921. declare module BABYLON {
  4922. /** @hidden */
  4923. export class _TypeStore {
  4924. /** @hidden */
  4925. static RegisteredTypes: {
  4926. [key: string]: Object;
  4927. };
  4928. /** @hidden */
  4929. static GetClass(fqdn: string): any;
  4930. }
  4931. }
  4932. declare module BABYLON {
  4933. /**
  4934. * Class containing a set of static utilities functions for deep copy.
  4935. */
  4936. export class DeepCopier {
  4937. /**
  4938. * Tries to copy an object by duplicating every property
  4939. * @param source defines the source object
  4940. * @param destination defines the target object
  4941. * @param doNotCopyList defines a list of properties to avoid
  4942. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4943. */
  4944. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4945. }
  4946. }
  4947. declare module BABYLON {
  4948. /**
  4949. * Class containing a set of static utilities functions for precision date
  4950. */
  4951. export class PrecisionDate {
  4952. /**
  4953. * Gets either window.performance.now() if supported or Date.now() else
  4954. */
  4955. static readonly Now: number;
  4956. }
  4957. }
  4958. declare module BABYLON {
  4959. /** @hidden */
  4960. export class _DevTools {
  4961. static WarnImport(name: string): string;
  4962. }
  4963. }
  4964. declare module BABYLON {
  4965. /**
  4966. * Class used to evalaute queries containing `and` and `or` operators
  4967. */
  4968. export class AndOrNotEvaluator {
  4969. /**
  4970. * Evaluate a query
  4971. * @param query defines the query to evaluate
  4972. * @param evaluateCallback defines the callback used to filter result
  4973. * @returns true if the query matches
  4974. */
  4975. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4976. private static _HandleParenthesisContent;
  4977. private static _SimplifyNegation;
  4978. }
  4979. }
  4980. declare module BABYLON {
  4981. /**
  4982. * Class used to store custom tags
  4983. */
  4984. export class Tags {
  4985. /**
  4986. * Adds support for tags on the given object
  4987. * @param obj defines the object to use
  4988. */
  4989. static EnableFor(obj: any): void;
  4990. /**
  4991. * Removes tags support
  4992. * @param obj defines the object to use
  4993. */
  4994. static DisableFor(obj: any): void;
  4995. /**
  4996. * Gets a boolean indicating if the given object has tags
  4997. * @param obj defines the object to use
  4998. * @returns a boolean
  4999. */
  5000. static HasTags(obj: any): boolean;
  5001. /**
  5002. * Gets the tags available on a given object
  5003. * @param obj defines the object to use
  5004. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5005. * @returns the tags
  5006. */
  5007. static GetTags(obj: any, asString?: boolean): any;
  5008. /**
  5009. * Adds tags to an object
  5010. * @param obj defines the object to use
  5011. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5012. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5013. */
  5014. static AddTagsTo(obj: any, tagsString: string): void;
  5015. /**
  5016. * @hidden
  5017. */
  5018. static _AddTagTo(obj: any, tag: string): void;
  5019. /**
  5020. * Removes specific tags from a specific object
  5021. * @param obj defines the object to use
  5022. * @param tagsString defines the tags to remove
  5023. */
  5024. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5025. /**
  5026. * @hidden
  5027. */
  5028. static _RemoveTagFrom(obj: any, tag: string): void;
  5029. /**
  5030. * Defines if tags hosted on an object match a given query
  5031. * @param obj defines the object to use
  5032. * @param tagsQuery defines the tag query
  5033. * @returns a boolean
  5034. */
  5035. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5036. }
  5037. }
  5038. declare module BABYLON {
  5039. /**
  5040. * Manages the defines for the Material
  5041. */
  5042. export class MaterialDefines {
  5043. private _keys;
  5044. private _isDirty;
  5045. /** @hidden */
  5046. _renderId: number;
  5047. /** @hidden */
  5048. _areLightsDirty: boolean;
  5049. /** @hidden */
  5050. _areAttributesDirty: boolean;
  5051. /** @hidden */
  5052. _areTexturesDirty: boolean;
  5053. /** @hidden */
  5054. _areFresnelDirty: boolean;
  5055. /** @hidden */
  5056. _areMiscDirty: boolean;
  5057. /** @hidden */
  5058. _areImageProcessingDirty: boolean;
  5059. /** @hidden */
  5060. _normals: boolean;
  5061. /** @hidden */
  5062. _uvs: boolean;
  5063. /** @hidden */
  5064. _needNormals: boolean;
  5065. /** @hidden */
  5066. _needUVs: boolean;
  5067. /**
  5068. * Specifies if the material needs to be re-calculated
  5069. */
  5070. readonly isDirty: boolean;
  5071. /**
  5072. * Marks the material to indicate that it has been re-calculated
  5073. */
  5074. markAsProcessed(): void;
  5075. /**
  5076. * Marks the material to indicate that it needs to be re-calculated
  5077. */
  5078. markAsUnprocessed(): void;
  5079. /**
  5080. * Marks the material to indicate all of its defines need to be re-calculated
  5081. */
  5082. markAllAsDirty(): void;
  5083. /**
  5084. * Marks the material to indicate that image processing needs to be re-calculated
  5085. */
  5086. markAsImageProcessingDirty(): void;
  5087. /**
  5088. * Marks the material to indicate the lights need to be re-calculated
  5089. */
  5090. markAsLightDirty(): void;
  5091. /**
  5092. * Marks the attribute state as changed
  5093. */
  5094. markAsAttributesDirty(): void;
  5095. /**
  5096. * Marks the texture state as changed
  5097. */
  5098. markAsTexturesDirty(): void;
  5099. /**
  5100. * Marks the fresnel state as changed
  5101. */
  5102. markAsFresnelDirty(): void;
  5103. /**
  5104. * Marks the misc state as changed
  5105. */
  5106. markAsMiscDirty(): void;
  5107. /**
  5108. * Rebuilds the material defines
  5109. */
  5110. rebuild(): void;
  5111. /**
  5112. * Specifies if two material defines are equal
  5113. * @param other - A material define instance to compare to
  5114. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5115. */
  5116. isEqual(other: MaterialDefines): boolean;
  5117. /**
  5118. * Clones this instance's defines to another instance
  5119. * @param other - material defines to clone values to
  5120. */
  5121. cloneTo(other: MaterialDefines): void;
  5122. /**
  5123. * Resets the material define values
  5124. */
  5125. reset(): void;
  5126. /**
  5127. * Converts the material define values to a string
  5128. * @returns - String of material define information
  5129. */
  5130. toString(): string;
  5131. }
  5132. }
  5133. declare module BABYLON {
  5134. /**
  5135. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5136. */
  5137. export class PerformanceMonitor {
  5138. private _enabled;
  5139. private _rollingFrameTime;
  5140. private _lastFrameTimeMs;
  5141. /**
  5142. * constructor
  5143. * @param frameSampleSize The number of samples required to saturate the sliding window
  5144. */
  5145. constructor(frameSampleSize?: number);
  5146. /**
  5147. * Samples current frame
  5148. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5149. */
  5150. sampleFrame(timeMs?: number): void;
  5151. /**
  5152. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5153. */
  5154. readonly averageFrameTime: number;
  5155. /**
  5156. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5157. */
  5158. readonly averageFrameTimeVariance: number;
  5159. /**
  5160. * Returns the frame time of the most recent frame
  5161. */
  5162. readonly instantaneousFrameTime: number;
  5163. /**
  5164. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5165. */
  5166. readonly averageFPS: number;
  5167. /**
  5168. * Returns the average framerate in frames per second using the most recent frame time
  5169. */
  5170. readonly instantaneousFPS: number;
  5171. /**
  5172. * Returns true if enough samples have been taken to completely fill the sliding window
  5173. */
  5174. readonly isSaturated: boolean;
  5175. /**
  5176. * Enables contributions to the sliding window sample set
  5177. */
  5178. enable(): void;
  5179. /**
  5180. * Disables contributions to the sliding window sample set
  5181. * Samples will not be interpolated over the disabled period
  5182. */
  5183. disable(): void;
  5184. /**
  5185. * Returns true if sampling is enabled
  5186. */
  5187. readonly isEnabled: boolean;
  5188. /**
  5189. * Resets performance monitor
  5190. */
  5191. reset(): void;
  5192. }
  5193. /**
  5194. * RollingAverage
  5195. *
  5196. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5197. */
  5198. export class RollingAverage {
  5199. /**
  5200. * Current average
  5201. */
  5202. average: number;
  5203. /**
  5204. * Current variance
  5205. */
  5206. variance: number;
  5207. protected _samples: Array<number>;
  5208. protected _sampleCount: number;
  5209. protected _pos: number;
  5210. protected _m2: number;
  5211. /**
  5212. * constructor
  5213. * @param length The number of samples required to saturate the sliding window
  5214. */
  5215. constructor(length: number);
  5216. /**
  5217. * Adds a sample to the sample set
  5218. * @param v The sample value
  5219. */
  5220. add(v: number): void;
  5221. /**
  5222. * Returns previously added values or null if outside of history or outside the sliding window domain
  5223. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5224. * @return Value previously recorded with add() or null if outside of range
  5225. */
  5226. history(i: number): number;
  5227. /**
  5228. * Returns true if enough samples have been taken to completely fill the sliding window
  5229. * @return true if sample-set saturated
  5230. */
  5231. isSaturated(): boolean;
  5232. /**
  5233. * Resets the rolling average (equivalent to 0 samples taken so far)
  5234. */
  5235. reset(): void;
  5236. /**
  5237. * Wraps a value around the sample range boundaries
  5238. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5239. * @return Wrapped position in sample range
  5240. */
  5241. protected _wrapPosition(i: number): number;
  5242. }
  5243. }
  5244. declare module BABYLON {
  5245. /**
  5246. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5247. * The underlying implementation relies on an associative array to ensure the best performances.
  5248. * The value can be anything including 'null' but except 'undefined'
  5249. */
  5250. export class StringDictionary<T> {
  5251. /**
  5252. * This will clear this dictionary and copy the content from the 'source' one.
  5253. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5254. * @param source the dictionary to take the content from and copy to this dictionary
  5255. */
  5256. copyFrom(source: StringDictionary<T>): void;
  5257. /**
  5258. * Get a value based from its key
  5259. * @param key the given key to get the matching value from
  5260. * @return the value if found, otherwise undefined is returned
  5261. */
  5262. get(key: string): T | undefined;
  5263. /**
  5264. * Get a value from its key or add it if it doesn't exist.
  5265. * This method will ensure you that a given key/data will be present in the dictionary.
  5266. * @param key the given key to get the matching value from
  5267. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5268. * The factory will only be invoked if there's no data for the given key.
  5269. * @return the value corresponding to the key.
  5270. */
  5271. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5272. /**
  5273. * Get a value from its key if present in the dictionary otherwise add it
  5274. * @param key the key to get the value from
  5275. * @param val if there's no such key/value pair in the dictionary add it with this value
  5276. * @return the value corresponding to the key
  5277. */
  5278. getOrAdd(key: string, val: T): T;
  5279. /**
  5280. * Check if there's a given key in the dictionary
  5281. * @param key the key to check for
  5282. * @return true if the key is present, false otherwise
  5283. */
  5284. contains(key: string): boolean;
  5285. /**
  5286. * Add a new key and its corresponding value
  5287. * @param key the key to add
  5288. * @param value the value corresponding to the key
  5289. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5290. */
  5291. add(key: string, value: T): boolean;
  5292. /**
  5293. * Update a specific value associated to a key
  5294. * @param key defines the key to use
  5295. * @param value defines the value to store
  5296. * @returns true if the value was updated (or false if the key was not found)
  5297. */
  5298. set(key: string, value: T): boolean;
  5299. /**
  5300. * Get the element of the given key and remove it from the dictionary
  5301. * @param key defines the key to search
  5302. * @returns the value associated with the key or null if not found
  5303. */
  5304. getAndRemove(key: string): Nullable<T>;
  5305. /**
  5306. * Remove a key/value from the dictionary.
  5307. * @param key the key to remove
  5308. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5309. */
  5310. remove(key: string): boolean;
  5311. /**
  5312. * Clear the whole content of the dictionary
  5313. */
  5314. clear(): void;
  5315. /**
  5316. * Gets the current count
  5317. */
  5318. readonly count: number;
  5319. /**
  5320. * Execute a callback on each key/val of the dictionary.
  5321. * Note that you can remove any element in this dictionary in the callback implementation
  5322. * @param callback the callback to execute on a given key/value pair
  5323. */
  5324. forEach(callback: (key: string, val: T) => void): void;
  5325. /**
  5326. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5327. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5328. * Note that you can remove any element in this dictionary in the callback implementation
  5329. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5330. * @returns the first item
  5331. */
  5332. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5333. private _count;
  5334. private _data;
  5335. }
  5336. }
  5337. declare module BABYLON {
  5338. /**
  5339. * Helper class that provides a small promise polyfill
  5340. */
  5341. export class PromisePolyfill {
  5342. /**
  5343. * Static function used to check if the polyfill is required
  5344. * If this is the case then the function will inject the polyfill to window.Promise
  5345. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5346. */
  5347. static Apply(force?: boolean): void;
  5348. }
  5349. }
  5350. declare module BABYLON {
  5351. /**
  5352. * Class used to store data that will be store in GPU memory
  5353. */
  5354. export class Buffer {
  5355. private _engine;
  5356. private _buffer;
  5357. /** @hidden */
  5358. _data: Nullable<DataArray>;
  5359. private _updatable;
  5360. private _instanced;
  5361. /**
  5362. * Gets the byte stride.
  5363. */
  5364. readonly byteStride: number;
  5365. /**
  5366. * Constructor
  5367. * @param engine the engine
  5368. * @param data the data to use for this buffer
  5369. * @param updatable whether the data is updatable
  5370. * @param stride the stride (optional)
  5371. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5372. * @param instanced whether the buffer is instanced (optional)
  5373. * @param useBytes set to true if the stride in in bytes (optional)
  5374. */
  5375. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5376. /**
  5377. * Create a new VertexBuffer based on the current buffer
  5378. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5379. * @param offset defines offset in the buffer (0 by default)
  5380. * @param size defines the size in floats of attributes (position is 3 for instance)
  5381. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5382. * @param instanced defines if the vertex buffer contains indexed data
  5383. * @param useBytes defines if the offset and stride are in bytes
  5384. * @returns the new vertex buffer
  5385. */
  5386. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5387. /**
  5388. * Gets a boolean indicating if the Buffer is updatable?
  5389. * @returns true if the buffer is updatable
  5390. */
  5391. isUpdatable(): boolean;
  5392. /**
  5393. * Gets current buffer's data
  5394. * @returns a DataArray or null
  5395. */
  5396. getData(): Nullable<DataArray>;
  5397. /**
  5398. * Gets underlying native buffer
  5399. * @returns underlying native buffer
  5400. */
  5401. getBuffer(): Nullable<WebGLBuffer>;
  5402. /**
  5403. * Gets the stride in float32 units (i.e. byte stride / 4).
  5404. * May not be an integer if the byte stride is not divisible by 4.
  5405. * DEPRECATED. Use byteStride instead.
  5406. * @returns the stride in float32 units
  5407. */
  5408. getStrideSize(): number;
  5409. /**
  5410. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5411. * @param data defines the data to store
  5412. */
  5413. create(data?: Nullable<DataArray>): void;
  5414. /** @hidden */
  5415. _rebuild(): void;
  5416. /**
  5417. * Update current buffer data
  5418. * @param data defines the data to store
  5419. */
  5420. update(data: DataArray): void;
  5421. /**
  5422. * Updates the data directly.
  5423. * @param data the new data
  5424. * @param offset the new offset
  5425. * @param vertexCount the vertex count (optional)
  5426. * @param useBytes set to true if the offset is in bytes
  5427. */
  5428. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5429. /**
  5430. * Release all resources
  5431. */
  5432. dispose(): void;
  5433. }
  5434. /**
  5435. * Specialized buffer used to store vertex data
  5436. */
  5437. export class VertexBuffer {
  5438. /** @hidden */
  5439. _buffer: Buffer;
  5440. private _kind;
  5441. private _size;
  5442. private _ownsBuffer;
  5443. private _instanced;
  5444. private _instanceDivisor;
  5445. /**
  5446. * The byte type.
  5447. */
  5448. static readonly BYTE: number;
  5449. /**
  5450. * The unsigned byte type.
  5451. */
  5452. static readonly UNSIGNED_BYTE: number;
  5453. /**
  5454. * The short type.
  5455. */
  5456. static readonly SHORT: number;
  5457. /**
  5458. * The unsigned short type.
  5459. */
  5460. static readonly UNSIGNED_SHORT: number;
  5461. /**
  5462. * The integer type.
  5463. */
  5464. static readonly INT: number;
  5465. /**
  5466. * The unsigned integer type.
  5467. */
  5468. static readonly UNSIGNED_INT: number;
  5469. /**
  5470. * The float type.
  5471. */
  5472. static readonly FLOAT: number;
  5473. /**
  5474. * Gets or sets the instance divisor when in instanced mode
  5475. */
  5476. instanceDivisor: number;
  5477. /**
  5478. * Gets the byte stride.
  5479. */
  5480. readonly byteStride: number;
  5481. /**
  5482. * Gets the byte offset.
  5483. */
  5484. readonly byteOffset: number;
  5485. /**
  5486. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5487. */
  5488. readonly normalized: boolean;
  5489. /**
  5490. * Gets the data type of each component in the array.
  5491. */
  5492. readonly type: number;
  5493. /**
  5494. * Constructor
  5495. * @param engine the engine
  5496. * @param data the data to use for this vertex buffer
  5497. * @param kind the vertex buffer kind
  5498. * @param updatable whether the data is updatable
  5499. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5500. * @param stride the stride (optional)
  5501. * @param instanced whether the buffer is instanced (optional)
  5502. * @param offset the offset of the data (optional)
  5503. * @param size the number of components (optional)
  5504. * @param type the type of the component (optional)
  5505. * @param normalized whether the data contains normalized data (optional)
  5506. * @param useBytes set to true if stride and offset are in bytes (optional)
  5507. */
  5508. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5509. /** @hidden */
  5510. _rebuild(): void;
  5511. /**
  5512. * Returns the kind of the VertexBuffer (string)
  5513. * @returns a string
  5514. */
  5515. getKind(): string;
  5516. /**
  5517. * Gets a boolean indicating if the VertexBuffer is updatable?
  5518. * @returns true if the buffer is updatable
  5519. */
  5520. isUpdatable(): boolean;
  5521. /**
  5522. * Gets current buffer's data
  5523. * @returns a DataArray or null
  5524. */
  5525. getData(): Nullable<DataArray>;
  5526. /**
  5527. * Gets underlying native buffer
  5528. * @returns underlying native buffer
  5529. */
  5530. getBuffer(): Nullable<WebGLBuffer>;
  5531. /**
  5532. * Gets the stride in float32 units (i.e. byte stride / 4).
  5533. * May not be an integer if the byte stride is not divisible by 4.
  5534. * DEPRECATED. Use byteStride instead.
  5535. * @returns the stride in float32 units
  5536. */
  5537. getStrideSize(): number;
  5538. /**
  5539. * Returns the offset as a multiple of the type byte length.
  5540. * DEPRECATED. Use byteOffset instead.
  5541. * @returns the offset in bytes
  5542. */
  5543. getOffset(): number;
  5544. /**
  5545. * Returns the number of components per vertex attribute (integer)
  5546. * @returns the size in float
  5547. */
  5548. getSize(): number;
  5549. /**
  5550. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5551. * @returns true if this buffer is instanced
  5552. */
  5553. getIsInstanced(): boolean;
  5554. /**
  5555. * Returns the instancing divisor, zero for non-instanced (integer).
  5556. * @returns a number
  5557. */
  5558. getInstanceDivisor(): number;
  5559. /**
  5560. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5561. * @param data defines the data to store
  5562. */
  5563. create(data?: DataArray): void;
  5564. /**
  5565. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5566. * This function will create a new buffer if the current one is not updatable
  5567. * @param data defines the data to store
  5568. */
  5569. update(data: DataArray): void;
  5570. /**
  5571. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5572. * Returns the directly updated WebGLBuffer.
  5573. * @param data the new data
  5574. * @param offset the new offset
  5575. * @param useBytes set to true if the offset is in bytes
  5576. */
  5577. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5578. /**
  5579. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5580. */
  5581. dispose(): void;
  5582. /**
  5583. * Enumerates each value of this vertex buffer as numbers.
  5584. * @param count the number of values to enumerate
  5585. * @param callback the callback function called for each value
  5586. */
  5587. forEach(count: number, callback: (value: number, index: number) => void): void;
  5588. /**
  5589. * Positions
  5590. */
  5591. static readonly PositionKind: string;
  5592. /**
  5593. * Normals
  5594. */
  5595. static readonly NormalKind: string;
  5596. /**
  5597. * Tangents
  5598. */
  5599. static readonly TangentKind: string;
  5600. /**
  5601. * Texture coordinates
  5602. */
  5603. static readonly UVKind: string;
  5604. /**
  5605. * Texture coordinates 2
  5606. */
  5607. static readonly UV2Kind: string;
  5608. /**
  5609. * Texture coordinates 3
  5610. */
  5611. static readonly UV3Kind: string;
  5612. /**
  5613. * Texture coordinates 4
  5614. */
  5615. static readonly UV4Kind: string;
  5616. /**
  5617. * Texture coordinates 5
  5618. */
  5619. static readonly UV5Kind: string;
  5620. /**
  5621. * Texture coordinates 6
  5622. */
  5623. static readonly UV6Kind: string;
  5624. /**
  5625. * Colors
  5626. */
  5627. static readonly ColorKind: string;
  5628. /**
  5629. * Matrix indices (for bones)
  5630. */
  5631. static readonly MatricesIndicesKind: string;
  5632. /**
  5633. * Matrix weights (for bones)
  5634. */
  5635. static readonly MatricesWeightsKind: string;
  5636. /**
  5637. * Additional matrix indices (for bones)
  5638. */
  5639. static readonly MatricesIndicesExtraKind: string;
  5640. /**
  5641. * Additional matrix weights (for bones)
  5642. */
  5643. static readonly MatricesWeightsExtraKind: string;
  5644. /**
  5645. * Deduces the stride given a kind.
  5646. * @param kind The kind string to deduce
  5647. * @returns The deduced stride
  5648. */
  5649. static DeduceStride(kind: string): number;
  5650. /**
  5651. * Gets the byte length of the given type.
  5652. * @param type the type
  5653. * @returns the number of bytes
  5654. */
  5655. static GetTypeByteLength(type: number): number;
  5656. /**
  5657. * Enumerates each value of the given parameters as numbers.
  5658. * @param data the data to enumerate
  5659. * @param byteOffset the byte offset of the data
  5660. * @param byteStride the byte stride of the data
  5661. * @param componentCount the number of components per element
  5662. * @param componentType the type of the component
  5663. * @param count the total number of components
  5664. * @param normalized whether the data is normalized
  5665. * @param callback the callback function called for each value
  5666. */
  5667. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5668. private static _GetFloatValue;
  5669. }
  5670. }
  5671. declare module BABYLON {
  5672. /**
  5673. * Class representing spherical polynomial coefficients to the 3rd degree
  5674. */
  5675. export class SphericalPolynomial {
  5676. /**
  5677. * The x coefficients of the spherical polynomial
  5678. */
  5679. x: Vector3;
  5680. /**
  5681. * The y coefficients of the spherical polynomial
  5682. */
  5683. y: Vector3;
  5684. /**
  5685. * The z coefficients of the spherical polynomial
  5686. */
  5687. z: Vector3;
  5688. /**
  5689. * The xx coefficients of the spherical polynomial
  5690. */
  5691. xx: Vector3;
  5692. /**
  5693. * The yy coefficients of the spherical polynomial
  5694. */
  5695. yy: Vector3;
  5696. /**
  5697. * The zz coefficients of the spherical polynomial
  5698. */
  5699. zz: Vector3;
  5700. /**
  5701. * The xy coefficients of the spherical polynomial
  5702. */
  5703. xy: Vector3;
  5704. /**
  5705. * The yz coefficients of the spherical polynomial
  5706. */
  5707. yz: Vector3;
  5708. /**
  5709. * The zx coefficients of the spherical polynomial
  5710. */
  5711. zx: Vector3;
  5712. /**
  5713. * Adds an ambient color to the spherical polynomial
  5714. * @param color the color to add
  5715. */
  5716. addAmbient(color: Color3): void;
  5717. /**
  5718. * Scales the spherical polynomial by the given amount
  5719. * @param scale the amount to scale
  5720. */
  5721. scale(scale: number): void;
  5722. /**
  5723. * Gets the spherical polynomial from harmonics
  5724. * @param harmonics the spherical harmonics
  5725. * @returns the spherical polynomial
  5726. */
  5727. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5728. /**
  5729. * Constructs a spherical polynomial from an array.
  5730. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5731. * @returns the spherical polynomial
  5732. */
  5733. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5734. }
  5735. /**
  5736. * Class representing spherical harmonics coefficients to the 3rd degree
  5737. */
  5738. export class SphericalHarmonics {
  5739. /**
  5740. * The l0,0 coefficients of the spherical harmonics
  5741. */
  5742. l00: Vector3;
  5743. /**
  5744. * The l1,-1 coefficients of the spherical harmonics
  5745. */
  5746. l1_1: Vector3;
  5747. /**
  5748. * The l1,0 coefficients of the spherical harmonics
  5749. */
  5750. l10: Vector3;
  5751. /**
  5752. * The l1,1 coefficients of the spherical harmonics
  5753. */
  5754. l11: Vector3;
  5755. /**
  5756. * The l2,-2 coefficients of the spherical harmonics
  5757. */
  5758. l2_2: Vector3;
  5759. /**
  5760. * The l2,-1 coefficients of the spherical harmonics
  5761. */
  5762. l2_1: Vector3;
  5763. /**
  5764. * The l2,0 coefficients of the spherical harmonics
  5765. */
  5766. l20: Vector3;
  5767. /**
  5768. * The l2,1 coefficients of the spherical harmonics
  5769. */
  5770. l21: Vector3;
  5771. /**
  5772. * The l2,2 coefficients of the spherical harmonics
  5773. */
  5774. lL22: Vector3;
  5775. /**
  5776. * Adds a light to the spherical harmonics
  5777. * @param direction the direction of the light
  5778. * @param color the color of the light
  5779. * @param deltaSolidAngle the delta solid angle of the light
  5780. */
  5781. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5782. /**
  5783. * Scales the spherical harmonics by the given amount
  5784. * @param scale the amount to scale
  5785. */
  5786. scale(scale: number): void;
  5787. /**
  5788. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5789. *
  5790. * ```
  5791. * E_lm = A_l * L_lm
  5792. * ```
  5793. *
  5794. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5795. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5796. * the scaling factors are given in equation 9.
  5797. */
  5798. convertIncidentRadianceToIrradiance(): void;
  5799. /**
  5800. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5801. *
  5802. * ```
  5803. * L = (1/pi) * E * rho
  5804. * ```
  5805. *
  5806. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5807. */
  5808. convertIrradianceToLambertianRadiance(): void;
  5809. /**
  5810. * Gets the spherical harmonics from polynomial
  5811. * @param polynomial the spherical polynomial
  5812. * @returns the spherical harmonics
  5813. */
  5814. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5815. /**
  5816. * Constructs a spherical harmonics from an array.
  5817. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5818. * @returns the spherical harmonics
  5819. */
  5820. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5821. }
  5822. }
  5823. declare module BABYLON {
  5824. /**
  5825. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5826. */
  5827. export interface CubeMapInfo {
  5828. /**
  5829. * The pixel array for the front face.
  5830. * This is stored in format, left to right, up to down format.
  5831. */
  5832. front: Nullable<ArrayBufferView>;
  5833. /**
  5834. * The pixel array for the back face.
  5835. * This is stored in format, left to right, up to down format.
  5836. */
  5837. back: Nullable<ArrayBufferView>;
  5838. /**
  5839. * The pixel array for the left face.
  5840. * This is stored in format, left to right, up to down format.
  5841. */
  5842. left: Nullable<ArrayBufferView>;
  5843. /**
  5844. * The pixel array for the right face.
  5845. * This is stored in format, left to right, up to down format.
  5846. */
  5847. right: Nullable<ArrayBufferView>;
  5848. /**
  5849. * The pixel array for the up face.
  5850. * This is stored in format, left to right, up to down format.
  5851. */
  5852. up: Nullable<ArrayBufferView>;
  5853. /**
  5854. * The pixel array for the down face.
  5855. * This is stored in format, left to right, up to down format.
  5856. */
  5857. down: Nullable<ArrayBufferView>;
  5858. /**
  5859. * The size of the cubemap stored.
  5860. *
  5861. * Each faces will be size * size pixels.
  5862. */
  5863. size: number;
  5864. /**
  5865. * The format of the texture.
  5866. *
  5867. * RGBA, RGB.
  5868. */
  5869. format: number;
  5870. /**
  5871. * The type of the texture data.
  5872. *
  5873. * UNSIGNED_INT, FLOAT.
  5874. */
  5875. type: number;
  5876. /**
  5877. * Specifies whether the texture is in gamma space.
  5878. */
  5879. gammaSpace: boolean;
  5880. }
  5881. /**
  5882. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5883. */
  5884. export class PanoramaToCubeMapTools {
  5885. private static FACE_FRONT;
  5886. private static FACE_BACK;
  5887. private static FACE_RIGHT;
  5888. private static FACE_LEFT;
  5889. private static FACE_DOWN;
  5890. private static FACE_UP;
  5891. /**
  5892. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5893. *
  5894. * @param float32Array The source data.
  5895. * @param inputWidth The width of the input panorama.
  5896. * @param inputHeight The height of the input panorama.
  5897. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5898. * @return The cubemap data
  5899. */
  5900. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5901. private static CreateCubemapTexture;
  5902. private static CalcProjectionSpherical;
  5903. }
  5904. }
  5905. declare module BABYLON {
  5906. /**
  5907. * Helper class dealing with the extraction of spherical polynomial dataArray
  5908. * from a cube map.
  5909. */
  5910. export class CubeMapToSphericalPolynomialTools {
  5911. private static FileFaces;
  5912. /**
  5913. * Converts a texture to the according Spherical Polynomial data.
  5914. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5915. *
  5916. * @param texture The texture to extract the information from.
  5917. * @return The Spherical Polynomial data.
  5918. */
  5919. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5920. /**
  5921. * Converts a cubemap to the according Spherical Polynomial data.
  5922. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5923. *
  5924. * @param cubeInfo The Cube map to extract the information from.
  5925. * @return The Spherical Polynomial data.
  5926. */
  5927. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5928. }
  5929. }
  5930. declare module BABYLON {
  5931. /**
  5932. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5933. * during the life time of the application.
  5934. */
  5935. export class EngineStore {
  5936. /** Gets the list of created engines */
  5937. static Instances: Engine[];
  5938. /**
  5939. * Gets the latest created engine
  5940. */
  5941. static readonly LastCreatedEngine: Nullable<Engine>;
  5942. /**
  5943. * Gets the latest created scene
  5944. */
  5945. static readonly LastCreatedScene: Nullable<Scene>;
  5946. }
  5947. }
  5948. declare module BABYLON {
  5949. /**
  5950. * Define options used to create a render target texture
  5951. */
  5952. export class RenderTargetCreationOptions {
  5953. /**
  5954. * Specifies is mipmaps must be generated
  5955. */
  5956. generateMipMaps?: boolean;
  5957. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5958. generateDepthBuffer?: boolean;
  5959. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5960. generateStencilBuffer?: boolean;
  5961. /** Defines texture type (int by default) */
  5962. type?: number;
  5963. /** Defines sampling mode (trilinear by default) */
  5964. samplingMode?: number;
  5965. /** Defines format (RGBA by default) */
  5966. format?: number;
  5967. }
  5968. }
  5969. declare module BABYLON {
  5970. /**
  5971. * @hidden
  5972. **/
  5973. export class _AlphaState {
  5974. private _isAlphaBlendDirty;
  5975. private _isBlendFunctionParametersDirty;
  5976. private _isBlendEquationParametersDirty;
  5977. private _isBlendConstantsDirty;
  5978. private _alphaBlend;
  5979. private _blendFunctionParameters;
  5980. private _blendEquationParameters;
  5981. private _blendConstants;
  5982. /**
  5983. * Initializes the state.
  5984. */
  5985. constructor();
  5986. readonly isDirty: boolean;
  5987. alphaBlend: boolean;
  5988. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5989. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5990. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5991. reset(): void;
  5992. apply(gl: WebGLRenderingContext): void;
  5993. }
  5994. }
  5995. declare module BABYLON {
  5996. /**
  5997. * @hidden
  5998. **/
  5999. export class _DepthCullingState {
  6000. private _isDepthTestDirty;
  6001. private _isDepthMaskDirty;
  6002. private _isDepthFuncDirty;
  6003. private _isCullFaceDirty;
  6004. private _isCullDirty;
  6005. private _isZOffsetDirty;
  6006. private _isFrontFaceDirty;
  6007. private _depthTest;
  6008. private _depthMask;
  6009. private _depthFunc;
  6010. private _cull;
  6011. private _cullFace;
  6012. private _zOffset;
  6013. private _frontFace;
  6014. /**
  6015. * Initializes the state.
  6016. */
  6017. constructor();
  6018. readonly isDirty: boolean;
  6019. zOffset: number;
  6020. cullFace: Nullable<number>;
  6021. cull: Nullable<boolean>;
  6022. depthFunc: Nullable<number>;
  6023. depthMask: boolean;
  6024. depthTest: boolean;
  6025. frontFace: Nullable<number>;
  6026. reset(): void;
  6027. apply(gl: WebGLRenderingContext): void;
  6028. }
  6029. }
  6030. declare module BABYLON {
  6031. /**
  6032. * @hidden
  6033. **/
  6034. export class _StencilState {
  6035. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6036. static readonly ALWAYS: number;
  6037. /** Passed to stencilOperation to specify that stencil value must be kept */
  6038. static readonly KEEP: number;
  6039. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6040. static readonly REPLACE: number;
  6041. private _isStencilTestDirty;
  6042. private _isStencilMaskDirty;
  6043. private _isStencilFuncDirty;
  6044. private _isStencilOpDirty;
  6045. private _stencilTest;
  6046. private _stencilMask;
  6047. private _stencilFunc;
  6048. private _stencilFuncRef;
  6049. private _stencilFuncMask;
  6050. private _stencilOpStencilFail;
  6051. private _stencilOpDepthFail;
  6052. private _stencilOpStencilDepthPass;
  6053. readonly isDirty: boolean;
  6054. stencilFunc: number;
  6055. stencilFuncRef: number;
  6056. stencilFuncMask: number;
  6057. stencilOpStencilFail: number;
  6058. stencilOpDepthFail: number;
  6059. stencilOpStencilDepthPass: number;
  6060. stencilMask: number;
  6061. stencilTest: boolean;
  6062. constructor();
  6063. reset(): void;
  6064. apply(gl: WebGLRenderingContext): void;
  6065. }
  6066. }
  6067. declare module BABYLON {
  6068. /**
  6069. * @hidden
  6070. **/
  6071. export class _TimeToken {
  6072. _startTimeQuery: Nullable<WebGLQuery>;
  6073. _endTimeQuery: Nullable<WebGLQuery>;
  6074. _timeElapsedQuery: Nullable<WebGLQuery>;
  6075. _timeElapsedQueryEnded: boolean;
  6076. }
  6077. }
  6078. declare module BABYLON {
  6079. /**
  6080. * Internal interface used to track InternalTexture already bound to the GL context
  6081. */
  6082. export interface IInternalTextureTracker {
  6083. /**
  6084. * Gets or set the previous tracker in the list
  6085. */
  6086. previous: Nullable<IInternalTextureTracker>;
  6087. /**
  6088. * Gets or set the next tracker in the list
  6089. */
  6090. next: Nullable<IInternalTextureTracker>;
  6091. }
  6092. /**
  6093. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6094. */
  6095. export class DummyInternalTextureTracker {
  6096. /**
  6097. * Gets or set the previous tracker in the list
  6098. */
  6099. previous: Nullable<IInternalTextureTracker>;
  6100. /**
  6101. * Gets or set the next tracker in the list
  6102. */
  6103. next: Nullable<IInternalTextureTracker>;
  6104. }
  6105. }
  6106. declare module BABYLON {
  6107. /**
  6108. * Class used to store data associated with WebGL texture data for the engine
  6109. * This class should not be used directly
  6110. */
  6111. export class InternalTexture implements IInternalTextureTracker {
  6112. /** hidden */
  6113. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6114. /**
  6115. * The source of the texture data is unknown
  6116. */
  6117. static DATASOURCE_UNKNOWN: number;
  6118. /**
  6119. * Texture data comes from an URL
  6120. */
  6121. static DATASOURCE_URL: number;
  6122. /**
  6123. * Texture data is only used for temporary storage
  6124. */
  6125. static DATASOURCE_TEMP: number;
  6126. /**
  6127. * Texture data comes from raw data (ArrayBuffer)
  6128. */
  6129. static DATASOURCE_RAW: number;
  6130. /**
  6131. * Texture content is dynamic (video or dynamic texture)
  6132. */
  6133. static DATASOURCE_DYNAMIC: number;
  6134. /**
  6135. * Texture content is generated by rendering to it
  6136. */
  6137. static DATASOURCE_RENDERTARGET: number;
  6138. /**
  6139. * Texture content is part of a multi render target process
  6140. */
  6141. static DATASOURCE_MULTIRENDERTARGET: number;
  6142. /**
  6143. * Texture data comes from a cube data file
  6144. */
  6145. static DATASOURCE_CUBE: number;
  6146. /**
  6147. * Texture data comes from a raw cube data
  6148. */
  6149. static DATASOURCE_CUBERAW: number;
  6150. /**
  6151. * Texture data come from a prefiltered cube data file
  6152. */
  6153. static DATASOURCE_CUBEPREFILTERED: number;
  6154. /**
  6155. * Texture content is raw 3D data
  6156. */
  6157. static DATASOURCE_RAW3D: number;
  6158. /**
  6159. * Texture content is a depth texture
  6160. */
  6161. static DATASOURCE_DEPTHTEXTURE: number;
  6162. /**
  6163. * Texture data comes from a raw cube data encoded with RGBD
  6164. */
  6165. static DATASOURCE_CUBERAW_RGBD: number;
  6166. /**
  6167. * Defines if the texture is ready
  6168. */
  6169. isReady: boolean;
  6170. /**
  6171. * Defines if the texture is a cube texture
  6172. */
  6173. isCube: boolean;
  6174. /**
  6175. * Defines if the texture contains 3D data
  6176. */
  6177. is3D: boolean;
  6178. /**
  6179. * Gets the URL used to load this texture
  6180. */
  6181. url: string;
  6182. /**
  6183. * Gets the sampling mode of the texture
  6184. */
  6185. samplingMode: number;
  6186. /**
  6187. * Gets a boolean indicating if the texture needs mipmaps generation
  6188. */
  6189. generateMipMaps: boolean;
  6190. /**
  6191. * Gets the number of samples used by the texture (WebGL2+ only)
  6192. */
  6193. samples: number;
  6194. /**
  6195. * Gets the type of the texture (int, float...)
  6196. */
  6197. type: number;
  6198. /**
  6199. * Gets the format of the texture (RGB, RGBA...)
  6200. */
  6201. format: number;
  6202. /**
  6203. * Observable called when the texture is loaded
  6204. */
  6205. onLoadedObservable: Observable<InternalTexture>;
  6206. /**
  6207. * Gets the width of the texture
  6208. */
  6209. width: number;
  6210. /**
  6211. * Gets the height of the texture
  6212. */
  6213. height: number;
  6214. /**
  6215. * Gets the depth of the texture
  6216. */
  6217. depth: number;
  6218. /**
  6219. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6220. */
  6221. baseWidth: number;
  6222. /**
  6223. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6224. */
  6225. baseHeight: number;
  6226. /**
  6227. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6228. */
  6229. baseDepth: number;
  6230. /**
  6231. * Gets a boolean indicating if the texture is inverted on Y axis
  6232. */
  6233. invertY: boolean;
  6234. /**
  6235. * Gets or set the previous tracker in the list
  6236. */
  6237. previous: Nullable<IInternalTextureTracker>;
  6238. /**
  6239. * Gets or set the next tracker in the list
  6240. */
  6241. next: Nullable<IInternalTextureTracker>;
  6242. /** @hidden */
  6243. _invertVScale: boolean;
  6244. /** @hidden */
  6245. _initialSlot: number;
  6246. /** @hidden */
  6247. _designatedSlot: number;
  6248. /** @hidden */
  6249. _dataSource: number;
  6250. /** @hidden */
  6251. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6252. /** @hidden */
  6253. _bufferView: Nullable<ArrayBufferView>;
  6254. /** @hidden */
  6255. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6256. /** @hidden */
  6257. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6258. /** @hidden */
  6259. _size: number;
  6260. /** @hidden */
  6261. _extension: string;
  6262. /** @hidden */
  6263. _files: Nullable<string[]>;
  6264. /** @hidden */
  6265. _workingCanvas: HTMLCanvasElement;
  6266. /** @hidden */
  6267. _workingContext: CanvasRenderingContext2D;
  6268. /** @hidden */
  6269. _framebuffer: Nullable<WebGLFramebuffer>;
  6270. /** @hidden */
  6271. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6272. /** @hidden */
  6273. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6274. /** @hidden */
  6275. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6276. /** @hidden */
  6277. _attachments: Nullable<number[]>;
  6278. /** @hidden */
  6279. _cachedCoordinatesMode: Nullable<number>;
  6280. /** @hidden */
  6281. _cachedWrapU: Nullable<number>;
  6282. /** @hidden */
  6283. _cachedWrapV: Nullable<number>;
  6284. /** @hidden */
  6285. _cachedWrapR: Nullable<number>;
  6286. /** @hidden */
  6287. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6288. /** @hidden */
  6289. _isDisabled: boolean;
  6290. /** @hidden */
  6291. _compression: Nullable<string>;
  6292. /** @hidden */
  6293. _generateStencilBuffer: boolean;
  6294. /** @hidden */
  6295. _generateDepthBuffer: boolean;
  6296. /** @hidden */
  6297. _comparisonFunction: number;
  6298. /** @hidden */
  6299. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6300. /** @hidden */
  6301. _lodGenerationScale: number;
  6302. /** @hidden */
  6303. _lodGenerationOffset: number;
  6304. /** @hidden */
  6305. _lodTextureHigh: BaseTexture;
  6306. /** @hidden */
  6307. _lodTextureMid: BaseTexture;
  6308. /** @hidden */
  6309. _lodTextureLow: BaseTexture;
  6310. /** @hidden */
  6311. _isRGBD: boolean;
  6312. /** @hidden */
  6313. _webGLTexture: Nullable<WebGLTexture>;
  6314. /** @hidden */
  6315. _references: number;
  6316. private _engine;
  6317. /**
  6318. * Gets the Engine the texture belongs to.
  6319. * @returns The babylon engine
  6320. */
  6321. getEngine(): Engine;
  6322. /**
  6323. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6324. */
  6325. readonly dataSource: number;
  6326. /**
  6327. * Creates a new InternalTexture
  6328. * @param engine defines the engine to use
  6329. * @param dataSource defines the type of data that will be used
  6330. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6331. */
  6332. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6333. /**
  6334. * Increments the number of references (ie. the number of Texture that point to it)
  6335. */
  6336. incrementReferences(): void;
  6337. /**
  6338. * Change the size of the texture (not the size of the content)
  6339. * @param width defines the new width
  6340. * @param height defines the new height
  6341. * @param depth defines the new depth (1 by default)
  6342. */
  6343. updateSize(width: int, height: int, depth?: int): void;
  6344. /** @hidden */
  6345. _rebuild(): void;
  6346. /** @hidden */
  6347. _swapAndDie(target: InternalTexture): void;
  6348. /**
  6349. * Dispose the current allocated resources
  6350. */
  6351. dispose(): void;
  6352. }
  6353. }
  6354. declare module BABYLON {
  6355. /**
  6356. * This represents the main contract an easing function should follow.
  6357. * Easing functions are used throughout the animation system.
  6358. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6359. */
  6360. export interface IEasingFunction {
  6361. /**
  6362. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6363. * of the easing function.
  6364. * The link below provides some of the most common examples of easing functions.
  6365. * @see https://easings.net/
  6366. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6367. * @returns the corresponding value on the curve defined by the easing function
  6368. */
  6369. ease(gradient: number): number;
  6370. }
  6371. /**
  6372. * Base class used for every default easing function.
  6373. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6374. */
  6375. export class EasingFunction implements IEasingFunction {
  6376. /**
  6377. * Interpolation follows the mathematical formula associated with the easing function.
  6378. */
  6379. static readonly EASINGMODE_EASEIN: number;
  6380. /**
  6381. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6382. */
  6383. static readonly EASINGMODE_EASEOUT: number;
  6384. /**
  6385. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6386. */
  6387. static readonly EASINGMODE_EASEINOUT: number;
  6388. private _easingMode;
  6389. /**
  6390. * Sets the easing mode of the current function.
  6391. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6392. */
  6393. setEasingMode(easingMode: number): void;
  6394. /**
  6395. * Gets the current easing mode.
  6396. * @returns the easing mode
  6397. */
  6398. getEasingMode(): number;
  6399. /**
  6400. * @hidden
  6401. */
  6402. easeInCore(gradient: number): number;
  6403. /**
  6404. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6405. * of the easing function.
  6406. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6407. * @returns the corresponding value on the curve defined by the easing function
  6408. */
  6409. ease(gradient: number): number;
  6410. }
  6411. /**
  6412. * Easing function with a circle shape (see link below).
  6413. * @see https://easings.net/#easeInCirc
  6414. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6415. */
  6416. export class CircleEase extends EasingFunction implements IEasingFunction {
  6417. /** @hidden */
  6418. easeInCore(gradient: number): number;
  6419. }
  6420. /**
  6421. * Easing function with a ease back shape (see link below).
  6422. * @see https://easings.net/#easeInBack
  6423. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6424. */
  6425. export class BackEase extends EasingFunction implements IEasingFunction {
  6426. /** Defines the amplitude of the function */
  6427. amplitude: number;
  6428. /**
  6429. * Instantiates a back ease easing
  6430. * @see https://easings.net/#easeInBack
  6431. * @param amplitude Defines the amplitude of the function
  6432. */
  6433. constructor(
  6434. /** Defines the amplitude of the function */
  6435. amplitude?: number);
  6436. /** @hidden */
  6437. easeInCore(gradient: number): number;
  6438. }
  6439. /**
  6440. * Easing function with a bouncing shape (see link below).
  6441. * @see https://easings.net/#easeInBounce
  6442. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6443. */
  6444. export class BounceEase extends EasingFunction implements IEasingFunction {
  6445. /** Defines the number of bounces */
  6446. bounces: number;
  6447. /** Defines the amplitude of the bounce */
  6448. bounciness: number;
  6449. /**
  6450. * Instantiates a bounce easing
  6451. * @see https://easings.net/#easeInBounce
  6452. * @param bounces Defines the number of bounces
  6453. * @param bounciness Defines the amplitude of the bounce
  6454. */
  6455. constructor(
  6456. /** Defines the number of bounces */
  6457. bounces?: number,
  6458. /** Defines the amplitude of the bounce */
  6459. bounciness?: number);
  6460. /** @hidden */
  6461. easeInCore(gradient: number): number;
  6462. }
  6463. /**
  6464. * Easing function with a power of 3 shape (see link below).
  6465. * @see https://easings.net/#easeInCubic
  6466. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6467. */
  6468. export class CubicEase extends EasingFunction implements IEasingFunction {
  6469. /** @hidden */
  6470. easeInCore(gradient: number): number;
  6471. }
  6472. /**
  6473. * Easing function with an elastic shape (see link below).
  6474. * @see https://easings.net/#easeInElastic
  6475. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6476. */
  6477. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6478. /** Defines the number of oscillations*/
  6479. oscillations: number;
  6480. /** Defines the amplitude of the oscillations*/
  6481. springiness: number;
  6482. /**
  6483. * Instantiates an elastic easing function
  6484. * @see https://easings.net/#easeInElastic
  6485. * @param oscillations Defines the number of oscillations
  6486. * @param springiness Defines the amplitude of the oscillations
  6487. */
  6488. constructor(
  6489. /** Defines the number of oscillations*/
  6490. oscillations?: number,
  6491. /** Defines the amplitude of the oscillations*/
  6492. springiness?: number);
  6493. /** @hidden */
  6494. easeInCore(gradient: number): number;
  6495. }
  6496. /**
  6497. * Easing function with an exponential shape (see link below).
  6498. * @see https://easings.net/#easeInExpo
  6499. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6500. */
  6501. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6502. /** Defines the exponent of the function */
  6503. exponent: number;
  6504. /**
  6505. * Instantiates an exponential easing function
  6506. * @see https://easings.net/#easeInExpo
  6507. * @param exponent Defines the exponent of the function
  6508. */
  6509. constructor(
  6510. /** Defines the exponent of the function */
  6511. exponent?: number);
  6512. /** @hidden */
  6513. easeInCore(gradient: number): number;
  6514. }
  6515. /**
  6516. * Easing function with a power shape (see link below).
  6517. * @see https://easings.net/#easeInQuad
  6518. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6519. */
  6520. export class PowerEase extends EasingFunction implements IEasingFunction {
  6521. /** Defines the power of the function */
  6522. power: number;
  6523. /**
  6524. * Instantiates an power base easing function
  6525. * @see https://easings.net/#easeInQuad
  6526. * @param power Defines the power of the function
  6527. */
  6528. constructor(
  6529. /** Defines the power of the function */
  6530. power?: number);
  6531. /** @hidden */
  6532. easeInCore(gradient: number): number;
  6533. }
  6534. /**
  6535. * Easing function with a power of 2 shape (see link below).
  6536. * @see https://easings.net/#easeInQuad
  6537. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6538. */
  6539. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6540. /** @hidden */
  6541. easeInCore(gradient: number): number;
  6542. }
  6543. /**
  6544. * Easing function with a power of 4 shape (see link below).
  6545. * @see https://easings.net/#easeInQuart
  6546. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6547. */
  6548. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6549. /** @hidden */
  6550. easeInCore(gradient: number): number;
  6551. }
  6552. /**
  6553. * Easing function with a power of 5 shape (see link below).
  6554. * @see https://easings.net/#easeInQuint
  6555. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6556. */
  6557. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6558. /** @hidden */
  6559. easeInCore(gradient: number): number;
  6560. }
  6561. /**
  6562. * Easing function with a sin shape (see link below).
  6563. * @see https://easings.net/#easeInSine
  6564. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6565. */
  6566. export class SineEase extends EasingFunction implements IEasingFunction {
  6567. /** @hidden */
  6568. easeInCore(gradient: number): number;
  6569. }
  6570. /**
  6571. * Easing function with a bezier shape (see link below).
  6572. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6573. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6574. */
  6575. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6576. /** Defines the x component of the start tangent in the bezier curve */
  6577. x1: number;
  6578. /** Defines the y component of the start tangent in the bezier curve */
  6579. y1: number;
  6580. /** Defines the x component of the end tangent in the bezier curve */
  6581. x2: number;
  6582. /** Defines the y component of the end tangent in the bezier curve */
  6583. y2: number;
  6584. /**
  6585. * Instantiates a bezier function
  6586. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6587. * @param x1 Defines the x component of the start tangent in the bezier curve
  6588. * @param y1 Defines the y component of the start tangent in the bezier curve
  6589. * @param x2 Defines the x component of the end tangent in the bezier curve
  6590. * @param y2 Defines the y component of the end tangent in the bezier curve
  6591. */
  6592. constructor(
  6593. /** Defines the x component of the start tangent in the bezier curve */
  6594. x1?: number,
  6595. /** Defines the y component of the start tangent in the bezier curve */
  6596. y1?: number,
  6597. /** Defines the x component of the end tangent in the bezier curve */
  6598. x2?: number,
  6599. /** Defines the y component of the end tangent in the bezier curve */
  6600. y2?: number);
  6601. /** @hidden */
  6602. easeInCore(gradient: number): number;
  6603. }
  6604. }
  6605. declare module BABYLON {
  6606. /**
  6607. * Defines an interface which represents an animation key frame
  6608. */
  6609. export interface IAnimationKey {
  6610. /**
  6611. * Frame of the key frame
  6612. */
  6613. frame: number;
  6614. /**
  6615. * Value at the specifies key frame
  6616. */
  6617. value: any;
  6618. /**
  6619. * The input tangent for the cubic hermite spline
  6620. */
  6621. inTangent?: any;
  6622. /**
  6623. * The output tangent for the cubic hermite spline
  6624. */
  6625. outTangent?: any;
  6626. /**
  6627. * The animation interpolation type
  6628. */
  6629. interpolation?: AnimationKeyInterpolation;
  6630. }
  6631. /**
  6632. * Enum for the animation key frame interpolation type
  6633. */
  6634. export enum AnimationKeyInterpolation {
  6635. /**
  6636. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6637. */
  6638. STEP = 1
  6639. }
  6640. }
  6641. declare module BABYLON {
  6642. /**
  6643. * Represents the range of an animation
  6644. */
  6645. export class AnimationRange {
  6646. /**The name of the animation range**/
  6647. name: string;
  6648. /**The starting frame of the animation */
  6649. from: number;
  6650. /**The ending frame of the animation*/
  6651. to: number;
  6652. /**
  6653. * Initializes the range of an animation
  6654. * @param name The name of the animation range
  6655. * @param from The starting frame of the animation
  6656. * @param to The ending frame of the animation
  6657. */
  6658. constructor(
  6659. /**The name of the animation range**/
  6660. name: string,
  6661. /**The starting frame of the animation */
  6662. from: number,
  6663. /**The ending frame of the animation*/
  6664. to: number);
  6665. /**
  6666. * Makes a copy of the animation range
  6667. * @returns A copy of the animation range
  6668. */
  6669. clone(): AnimationRange;
  6670. }
  6671. }
  6672. declare module BABYLON {
  6673. /**
  6674. * Composed of a frame, and an action function
  6675. */
  6676. export class AnimationEvent {
  6677. /** The frame for which the event is triggered **/
  6678. frame: number;
  6679. /** The event to perform when triggered **/
  6680. action: (currentFrame: number) => void;
  6681. /** Specifies if the event should be triggered only once**/
  6682. onlyOnce?: boolean | undefined;
  6683. /**
  6684. * Specifies if the animation event is done
  6685. */
  6686. isDone: boolean;
  6687. /**
  6688. * Initializes the animation event
  6689. * @param frame The frame for which the event is triggered
  6690. * @param action The event to perform when triggered
  6691. * @param onlyOnce Specifies if the event should be triggered only once
  6692. */
  6693. constructor(
  6694. /** The frame for which the event is triggered **/
  6695. frame: number,
  6696. /** The event to perform when triggered **/
  6697. action: (currentFrame: number) => void,
  6698. /** Specifies if the event should be triggered only once**/
  6699. onlyOnce?: boolean | undefined);
  6700. /** @hidden */
  6701. _clone(): AnimationEvent;
  6702. }
  6703. }
  6704. declare module BABYLON {
  6705. /**
  6706. * Interface used to define a behavior
  6707. */
  6708. export interface Behavior<T> {
  6709. /** gets or sets behavior's name */
  6710. name: string;
  6711. /**
  6712. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6713. */
  6714. init(): void;
  6715. /**
  6716. * Called when the behavior is attached to a target
  6717. * @param target defines the target where the behavior is attached to
  6718. */
  6719. attach(target: T): void;
  6720. /**
  6721. * Called when the behavior is detached from its target
  6722. */
  6723. detach(): void;
  6724. }
  6725. /**
  6726. * Interface implemented by classes supporting behaviors
  6727. */
  6728. export interface IBehaviorAware<T> {
  6729. /**
  6730. * Attach a behavior
  6731. * @param behavior defines the behavior to attach
  6732. * @returns the current host
  6733. */
  6734. addBehavior(behavior: Behavior<T>): T;
  6735. /**
  6736. * Remove a behavior from the current object
  6737. * @param behavior defines the behavior to detach
  6738. * @returns the current host
  6739. */
  6740. removeBehavior(behavior: Behavior<T>): T;
  6741. /**
  6742. * Gets a behavior using its name to search
  6743. * @param name defines the name to search
  6744. * @returns the behavior or null if not found
  6745. */
  6746. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6747. }
  6748. }
  6749. declare module BABYLON {
  6750. /**
  6751. * Defines a runtime animation
  6752. */
  6753. export class RuntimeAnimation {
  6754. private _events;
  6755. /**
  6756. * The current frame of the runtime animation
  6757. */
  6758. private _currentFrame;
  6759. /**
  6760. * The animation used by the runtime animation
  6761. */
  6762. private _animation;
  6763. /**
  6764. * The target of the runtime animation
  6765. */
  6766. private _target;
  6767. /**
  6768. * The initiating animatable
  6769. */
  6770. private _host;
  6771. /**
  6772. * The original value of the runtime animation
  6773. */
  6774. private _originalValue;
  6775. /**
  6776. * The original blend value of the runtime animation
  6777. */
  6778. private _originalBlendValue;
  6779. /**
  6780. * The offsets cache of the runtime animation
  6781. */
  6782. private _offsetsCache;
  6783. /**
  6784. * The high limits cache of the runtime animation
  6785. */
  6786. private _highLimitsCache;
  6787. /**
  6788. * Specifies if the runtime animation has been stopped
  6789. */
  6790. private _stopped;
  6791. /**
  6792. * The blending factor of the runtime animation
  6793. */
  6794. private _blendingFactor;
  6795. /**
  6796. * The BabylonJS scene
  6797. */
  6798. private _scene;
  6799. /**
  6800. * The current value of the runtime animation
  6801. */
  6802. private _currentValue;
  6803. /** @hidden */
  6804. _workValue: any;
  6805. /**
  6806. * The active target of the runtime animation
  6807. */
  6808. private _activeTarget;
  6809. /**
  6810. * The target path of the runtime animation
  6811. */
  6812. private _targetPath;
  6813. /**
  6814. * The weight of the runtime animation
  6815. */
  6816. private _weight;
  6817. /**
  6818. * The ratio offset of the runtime animation
  6819. */
  6820. private _ratioOffset;
  6821. /**
  6822. * The previous delay of the runtime animation
  6823. */
  6824. private _previousDelay;
  6825. /**
  6826. * The previous ratio of the runtime animation
  6827. */
  6828. private _previousRatio;
  6829. /**
  6830. * Gets the current frame of the runtime animation
  6831. */
  6832. readonly currentFrame: number;
  6833. /**
  6834. * Gets the weight of the runtime animation
  6835. */
  6836. readonly weight: number;
  6837. /**
  6838. * Gets the current value of the runtime animation
  6839. */
  6840. readonly currentValue: any;
  6841. /**
  6842. * Gets the target path of the runtime animation
  6843. */
  6844. readonly targetPath: string;
  6845. /**
  6846. * Gets the actual target of the runtime animation
  6847. */
  6848. readonly target: any;
  6849. /**
  6850. * Create a new RuntimeAnimation object
  6851. * @param target defines the target of the animation
  6852. * @param animation defines the source animation object
  6853. * @param scene defines the hosting scene
  6854. * @param host defines the initiating Animatable
  6855. */
  6856. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  6857. /**
  6858. * Gets the animation from the runtime animation
  6859. */
  6860. readonly animation: Animation;
  6861. /**
  6862. * Resets the runtime animation to the beginning
  6863. * @param restoreOriginal defines whether to restore the target property to the original value
  6864. */
  6865. reset(restoreOriginal?: boolean): void;
  6866. /**
  6867. * Specifies if the runtime animation is stopped
  6868. * @returns Boolean specifying if the runtime animation is stopped
  6869. */
  6870. isStopped(): boolean;
  6871. /**
  6872. * Disposes of the runtime animation
  6873. */
  6874. dispose(): void;
  6875. /**
  6876. * Interpolates the animation from the current frame
  6877. * @param currentFrame The frame to interpolate the animation to
  6878. * @param repeatCount The number of times that the animation should loop
  6879. * @param loopMode The type of looping mode to use
  6880. * @param offsetValue Animation offset value
  6881. * @param highLimitValue The high limit value
  6882. * @returns The interpolated value
  6883. */
  6884. private _interpolate;
  6885. /**
  6886. * Apply the interpolated value to the target
  6887. * @param currentValue defines the value computed by the animation
  6888. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  6889. */
  6890. setValue(currentValue: any, weight?: number): void;
  6891. private _setValue;
  6892. /**
  6893. * Gets the loop pmode of the runtime animation
  6894. * @returns Loop Mode
  6895. */
  6896. private _getCorrectLoopMode;
  6897. /**
  6898. * Move the current animation to a given frame
  6899. * @param frame defines the frame to move to
  6900. */
  6901. goToFrame(frame: number): void;
  6902. /**
  6903. * @hidden Internal use only
  6904. */
  6905. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  6906. /**
  6907. * Execute the current animation
  6908. * @param delay defines the delay to add to the current frame
  6909. * @param from defines the lower bound of the animation range
  6910. * @param to defines the upper bound of the animation range
  6911. * @param loop defines if the current animation must loop
  6912. * @param speedRatio defines the current speed ratio
  6913. * @param weight defines the weight of the animation (default is -1 so no weight)
  6914. * @param onLoop optional callback called when animation loops
  6915. * @returns a boolean indicating if the animation is running
  6916. */
  6917. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  6918. }
  6919. }
  6920. declare module BABYLON {
  6921. /**
  6922. * @hidden
  6923. */
  6924. export class IntersectionInfo {
  6925. bu: Nullable<number>;
  6926. bv: Nullable<number>;
  6927. distance: number;
  6928. faceId: number;
  6929. subMeshId: number;
  6930. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6931. }
  6932. }
  6933. declare module BABYLON {
  6934. /**
  6935. * Class used to store bounding sphere information
  6936. */
  6937. export class BoundingSphere {
  6938. /**
  6939. * Gets the center of the bounding sphere in local space
  6940. */
  6941. readonly center: Vector3;
  6942. /**
  6943. * Radius of the bounding sphere in local space
  6944. */
  6945. radius: number;
  6946. /**
  6947. * Gets the center of the bounding sphere in world space
  6948. */
  6949. readonly centerWorld: Vector3;
  6950. /**
  6951. * Radius of the bounding sphere in world space
  6952. */
  6953. radiusWorld: number;
  6954. /**
  6955. * Gets the minimum vector in local space
  6956. */
  6957. readonly minimum: Vector3;
  6958. /**
  6959. * Gets the maximum vector in local space
  6960. */
  6961. readonly maximum: Vector3;
  6962. private _worldMatrix;
  6963. private static readonly TmpVector3;
  6964. /**
  6965. * Creates a new bounding sphere
  6966. * @param min defines the minimum vector (in local space)
  6967. * @param max defines the maximum vector (in local space)
  6968. * @param worldMatrix defines the new world matrix
  6969. */
  6970. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6971. /**
  6972. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6973. * @param min defines the new minimum vector (in local space)
  6974. * @param max defines the new maximum vector (in local space)
  6975. * @param worldMatrix defines the new world matrix
  6976. */
  6977. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6978. /**
  6979. * Scale the current bounding sphere by applying a scale factor
  6980. * @param factor defines the scale factor to apply
  6981. * @returns the current bounding box
  6982. */
  6983. scale(factor: number): BoundingSphere;
  6984. /**
  6985. * Gets the world matrix of the bounding box
  6986. * @returns a matrix
  6987. */
  6988. getWorldMatrix(): DeepImmutable<Matrix>;
  6989. /** @hidden */
  6990. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6991. /**
  6992. * Tests if the bounding sphere is intersecting the frustum planes
  6993. * @param frustumPlanes defines the frustum planes to test
  6994. * @returns true if there is an intersection
  6995. */
  6996. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6997. /**
  6998. * Tests if the bounding sphere center is in between the frustum planes.
  6999. * Used for optimistic fast inclusion.
  7000. * @param frustumPlanes defines the frustum planes to test
  7001. * @returns true if the sphere center is in between the frustum planes
  7002. */
  7003. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7004. /**
  7005. * Tests if a point is inside the bounding sphere
  7006. * @param point defines the point to test
  7007. * @returns true if the point is inside the bounding sphere
  7008. */
  7009. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7010. /**
  7011. * Checks if two sphere intersct
  7012. * @param sphere0 sphere 0
  7013. * @param sphere1 sphere 1
  7014. * @returns true if the speres intersect
  7015. */
  7016. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7017. }
  7018. }
  7019. declare module BABYLON {
  7020. /**
  7021. * Class used to store bounding box information
  7022. */
  7023. export class BoundingBox implements ICullable {
  7024. /**
  7025. * Gets the 8 vectors representing the bounding box in local space
  7026. */
  7027. readonly vectors: Vector3[];
  7028. /**
  7029. * Gets the center of the bounding box in local space
  7030. */
  7031. readonly center: Vector3;
  7032. /**
  7033. * Gets the center of the bounding box in world space
  7034. */
  7035. readonly centerWorld: Vector3;
  7036. /**
  7037. * Gets the extend size in local space
  7038. */
  7039. readonly extendSize: Vector3;
  7040. /**
  7041. * Gets the extend size in world space
  7042. */
  7043. readonly extendSizeWorld: Vector3;
  7044. /**
  7045. * Gets the OBB (object bounding box) directions
  7046. */
  7047. readonly directions: Vector3[];
  7048. /**
  7049. * Gets the 8 vectors representing the bounding box in world space
  7050. */
  7051. readonly vectorsWorld: Vector3[];
  7052. /**
  7053. * Gets the minimum vector in world space
  7054. */
  7055. readonly minimumWorld: Vector3;
  7056. /**
  7057. * Gets the maximum vector in world space
  7058. */
  7059. readonly maximumWorld: Vector3;
  7060. /**
  7061. * Gets the minimum vector in local space
  7062. */
  7063. readonly minimum: Vector3;
  7064. /**
  7065. * Gets the maximum vector in local space
  7066. */
  7067. readonly maximum: Vector3;
  7068. private _worldMatrix;
  7069. private static readonly TmpVector3;
  7070. /**
  7071. * @hidden
  7072. */
  7073. _tag: number;
  7074. /**
  7075. * Creates a new bounding box
  7076. * @param min defines the minimum vector (in local space)
  7077. * @param max defines the maximum vector (in local space)
  7078. * @param worldMatrix defines the new world matrix
  7079. */
  7080. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7081. /**
  7082. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7083. * @param min defines the new minimum vector (in local space)
  7084. * @param max defines the new maximum vector (in local space)
  7085. * @param worldMatrix defines the new world matrix
  7086. */
  7087. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7088. /**
  7089. * Scale the current bounding box by applying a scale factor
  7090. * @param factor defines the scale factor to apply
  7091. * @returns the current bounding box
  7092. */
  7093. scale(factor: number): BoundingBox;
  7094. /**
  7095. * Gets the world matrix of the bounding box
  7096. * @returns a matrix
  7097. */
  7098. getWorldMatrix(): DeepImmutable<Matrix>;
  7099. /** @hidden */
  7100. _update(world: DeepImmutable<Matrix>): void;
  7101. /**
  7102. * Tests if the bounding box is intersecting the frustum planes
  7103. * @param frustumPlanes defines the frustum planes to test
  7104. * @returns true if there is an intersection
  7105. */
  7106. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7107. /**
  7108. * Tests if the bounding box is entirely inside the frustum planes
  7109. * @param frustumPlanes defines the frustum planes to test
  7110. * @returns true if there is an inclusion
  7111. */
  7112. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7113. /**
  7114. * Tests if a point is inside the bounding box
  7115. * @param point defines the point to test
  7116. * @returns true if the point is inside the bounding box
  7117. */
  7118. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7119. /**
  7120. * Tests if the bounding box intersects with a bounding sphere
  7121. * @param sphere defines the sphere to test
  7122. * @returns true if there is an intersection
  7123. */
  7124. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7125. /**
  7126. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7127. * @param min defines the min vector to use
  7128. * @param max defines the max vector to use
  7129. * @returns true if there is an intersection
  7130. */
  7131. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7132. /**
  7133. * Tests if two bounding boxes are intersections
  7134. * @param box0 defines the first box to test
  7135. * @param box1 defines the second box to test
  7136. * @returns true if there is an intersection
  7137. */
  7138. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7139. /**
  7140. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7141. * @param minPoint defines the minimum vector of the bounding box
  7142. * @param maxPoint defines the maximum vector of the bounding box
  7143. * @param sphereCenter defines the sphere center
  7144. * @param sphereRadius defines the sphere radius
  7145. * @returns true if there is an intersection
  7146. */
  7147. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7148. /**
  7149. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7150. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7151. * @param frustumPlanes defines the frustum planes to test
  7152. * @return true if there is an inclusion
  7153. */
  7154. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7155. /**
  7156. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7157. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7158. * @param frustumPlanes defines the frustum planes to test
  7159. * @return true if there is an intersection
  7160. */
  7161. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7162. }
  7163. }
  7164. declare module BABYLON {
  7165. /** @hidden */
  7166. export class Collider {
  7167. /** Define if a collision was found */
  7168. collisionFound: boolean;
  7169. /**
  7170. * Define last intersection point in local space
  7171. */
  7172. intersectionPoint: Vector3;
  7173. /**
  7174. * Define last collided mesh
  7175. */
  7176. collidedMesh: Nullable<AbstractMesh>;
  7177. private _collisionPoint;
  7178. private _planeIntersectionPoint;
  7179. private _tempVector;
  7180. private _tempVector2;
  7181. private _tempVector3;
  7182. private _tempVector4;
  7183. private _edge;
  7184. private _baseToVertex;
  7185. private _destinationPoint;
  7186. private _slidePlaneNormal;
  7187. private _displacementVector;
  7188. /** @hidden */
  7189. _radius: Vector3;
  7190. /** @hidden */
  7191. _retry: number;
  7192. private _velocity;
  7193. private _basePoint;
  7194. private _epsilon;
  7195. /** @hidden */
  7196. _velocityWorldLength: number;
  7197. /** @hidden */
  7198. _basePointWorld: Vector3;
  7199. private _velocityWorld;
  7200. private _normalizedVelocity;
  7201. /** @hidden */
  7202. _initialVelocity: Vector3;
  7203. /** @hidden */
  7204. _initialPosition: Vector3;
  7205. private _nearestDistance;
  7206. private _collisionMask;
  7207. collisionMask: number;
  7208. /**
  7209. * Gets the plane normal used to compute the sliding response (in local space)
  7210. */
  7211. readonly slidePlaneNormal: Vector3;
  7212. /** @hidden */
  7213. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7214. /** @hidden */
  7215. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7216. /** @hidden */
  7217. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7218. /** @hidden */
  7219. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7220. /** @hidden */
  7221. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7222. /** @hidden */
  7223. _getResponse(pos: Vector3, vel: Vector3): void;
  7224. }
  7225. }
  7226. declare module BABYLON {
  7227. /**
  7228. * Interface for cullable objects
  7229. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7230. */
  7231. export interface ICullable {
  7232. /**
  7233. * Checks if the object or part of the object is in the frustum
  7234. * @param frustumPlanes Camera near/planes
  7235. * @returns true if the object is in frustum otherwise false
  7236. */
  7237. isInFrustum(frustumPlanes: Plane[]): boolean;
  7238. /**
  7239. * Checks if a cullable object (mesh...) is in the camera frustum
  7240. * Unlike isInFrustum this cheks the full bounding box
  7241. * @param frustumPlanes Camera near/planes
  7242. * @returns true if the object is in frustum otherwise false
  7243. */
  7244. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7245. }
  7246. /**
  7247. * Info for a bounding data of a mesh
  7248. */
  7249. export class BoundingInfo implements ICullable {
  7250. /**
  7251. * Bounding box for the mesh
  7252. */
  7253. readonly boundingBox: BoundingBox;
  7254. /**
  7255. * Bounding sphere for the mesh
  7256. */
  7257. readonly boundingSphere: BoundingSphere;
  7258. private _isLocked;
  7259. private static readonly TmpVector3;
  7260. /**
  7261. * Constructs bounding info
  7262. * @param minimum min vector of the bounding box/sphere
  7263. * @param maximum max vector of the bounding box/sphere
  7264. * @param worldMatrix defines the new world matrix
  7265. */
  7266. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7267. /**
  7268. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7269. * @param min defines the new minimum vector (in local space)
  7270. * @param max defines the new maximum vector (in local space)
  7271. * @param worldMatrix defines the new world matrix
  7272. */
  7273. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7274. /**
  7275. * min vector of the bounding box/sphere
  7276. */
  7277. readonly minimum: Vector3;
  7278. /**
  7279. * max vector of the bounding box/sphere
  7280. */
  7281. readonly maximum: Vector3;
  7282. /**
  7283. * If the info is locked and won't be updated to avoid perf overhead
  7284. */
  7285. isLocked: boolean;
  7286. /**
  7287. * Updates the bounding sphere and box
  7288. * @param world world matrix to be used to update
  7289. */
  7290. update(world: DeepImmutable<Matrix>): void;
  7291. /**
  7292. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7293. * @param center New center of the bounding info
  7294. * @param extend New extend of the bounding info
  7295. * @returns the current bounding info
  7296. */
  7297. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7298. /**
  7299. * Scale the current bounding info by applying a scale factor
  7300. * @param factor defines the scale factor to apply
  7301. * @returns the current bounding info
  7302. */
  7303. scale(factor: number): BoundingInfo;
  7304. /**
  7305. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7306. * @param frustumPlanes defines the frustum to test
  7307. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7308. * @returns true if the bounding info is in the frustum planes
  7309. */
  7310. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7311. /**
  7312. * Gets the world distance between the min and max points of the bounding box
  7313. */
  7314. readonly diagonalLength: number;
  7315. /**
  7316. * Checks if a cullable object (mesh...) is in the camera frustum
  7317. * Unlike isInFrustum this cheks the full bounding box
  7318. * @param frustumPlanes Camera near/planes
  7319. * @returns true if the object is in frustum otherwise false
  7320. */
  7321. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7322. /** @hidden */
  7323. _checkCollision(collider: Collider): boolean;
  7324. /**
  7325. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7326. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7327. * @param point the point to check intersection with
  7328. * @returns if the point intersects
  7329. */
  7330. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7331. /**
  7332. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7333. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7334. * @param boundingInfo the bounding info to check intersection with
  7335. * @param precise if the intersection should be done using OBB
  7336. * @returns if the bounding info intersects
  7337. */
  7338. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7339. }
  7340. }
  7341. declare module BABYLON {
  7342. /**
  7343. * Defines an array and its length.
  7344. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7345. */
  7346. export interface ISmartArrayLike<T> {
  7347. /**
  7348. * The data of the array.
  7349. */
  7350. data: Array<T>;
  7351. /**
  7352. * The active length of the array.
  7353. */
  7354. length: number;
  7355. }
  7356. /**
  7357. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7358. */
  7359. export class SmartArray<T> implements ISmartArrayLike<T> {
  7360. /**
  7361. * The full set of data from the array.
  7362. */
  7363. data: Array<T>;
  7364. /**
  7365. * The active length of the array.
  7366. */
  7367. length: number;
  7368. protected _id: number;
  7369. /**
  7370. * Instantiates a Smart Array.
  7371. * @param capacity defines the default capacity of the array.
  7372. */
  7373. constructor(capacity: number);
  7374. /**
  7375. * Pushes a value at the end of the active data.
  7376. * @param value defines the object to push in the array.
  7377. */
  7378. push(value: T): void;
  7379. /**
  7380. * Iterates over the active data and apply the lambda to them.
  7381. * @param func defines the action to apply on each value.
  7382. */
  7383. forEach(func: (content: T) => void): void;
  7384. /**
  7385. * Sorts the full sets of data.
  7386. * @param compareFn defines the comparison function to apply.
  7387. */
  7388. sort(compareFn: (a: T, b: T) => number): void;
  7389. /**
  7390. * Resets the active data to an empty array.
  7391. */
  7392. reset(): void;
  7393. /**
  7394. * Releases all the data from the array as well as the array.
  7395. */
  7396. dispose(): void;
  7397. /**
  7398. * Concats the active data with a given array.
  7399. * @param array defines the data to concatenate with.
  7400. */
  7401. concat(array: any): void;
  7402. /**
  7403. * Returns the position of a value in the active data.
  7404. * @param value defines the value to find the index for
  7405. * @returns the index if found in the active data otherwise -1
  7406. */
  7407. indexOf(value: T): number;
  7408. /**
  7409. * Returns whether an element is part of the active data.
  7410. * @param value defines the value to look for
  7411. * @returns true if found in the active data otherwise false
  7412. */
  7413. contains(value: T): boolean;
  7414. private static _GlobalId;
  7415. }
  7416. /**
  7417. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7418. * The data in this array can only be present once
  7419. */
  7420. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7421. private _duplicateId;
  7422. /**
  7423. * Pushes a value at the end of the active data.
  7424. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7425. * @param value defines the object to push in the array.
  7426. */
  7427. push(value: T): void;
  7428. /**
  7429. * Pushes a value at the end of the active data.
  7430. * If the data is already present, it won t be added again
  7431. * @param value defines the object to push in the array.
  7432. * @returns true if added false if it was already present
  7433. */
  7434. pushNoDuplicate(value: T): boolean;
  7435. /**
  7436. * Resets the active data to an empty array.
  7437. */
  7438. reset(): void;
  7439. /**
  7440. * Concats the active data with a given array.
  7441. * This ensures no dupplicate will be present in the result.
  7442. * @param array defines the data to concatenate with.
  7443. */
  7444. concatWithNoDuplicate(array: any): void;
  7445. }
  7446. }
  7447. declare module BABYLON {
  7448. /**
  7449. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7450. * separate meshes. This can be use to improve performances.
  7451. * @see http://doc.babylonjs.com/how_to/multi_materials
  7452. */
  7453. export class MultiMaterial extends Material {
  7454. private _subMaterials;
  7455. /**
  7456. * Gets or Sets the list of Materials used within the multi material.
  7457. * They need to be ordered according to the submeshes order in the associated mesh
  7458. */
  7459. subMaterials: Nullable<Material>[];
  7460. /**
  7461. * Function used to align with Node.getChildren()
  7462. * @returns the list of Materials used within the multi material
  7463. */
  7464. getChildren(): Nullable<Material>[];
  7465. /**
  7466. * Instantiates a new Multi Material
  7467. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7468. * separate meshes. This can be use to improve performances.
  7469. * @see http://doc.babylonjs.com/how_to/multi_materials
  7470. * @param name Define the name in the scene
  7471. * @param scene Define the scene the material belongs to
  7472. */
  7473. constructor(name: string, scene: Scene);
  7474. private _hookArray;
  7475. /**
  7476. * Get one of the submaterial by its index in the submaterials array
  7477. * @param index The index to look the sub material at
  7478. * @returns The Material if the index has been defined
  7479. */
  7480. getSubMaterial(index: number): Nullable<Material>;
  7481. /**
  7482. * Get the list of active textures for the whole sub materials list.
  7483. * @returns All the textures that will be used during the rendering
  7484. */
  7485. getActiveTextures(): BaseTexture[];
  7486. /**
  7487. * Gets the current class name of the material e.g. "MultiMaterial"
  7488. * Mainly use in serialization.
  7489. * @returns the class name
  7490. */
  7491. getClassName(): string;
  7492. /**
  7493. * Checks if the material is ready to render the requested sub mesh
  7494. * @param mesh Define the mesh the submesh belongs to
  7495. * @param subMesh Define the sub mesh to look readyness for
  7496. * @param useInstances Define whether or not the material is used with instances
  7497. * @returns true if ready, otherwise false
  7498. */
  7499. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7500. /**
  7501. * Clones the current material and its related sub materials
  7502. * @param name Define the name of the newly cloned material
  7503. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7504. * @returns the cloned material
  7505. */
  7506. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7507. /**
  7508. * Serializes the materials into a JSON representation.
  7509. * @returns the JSON representation
  7510. */
  7511. serialize(): any;
  7512. /**
  7513. * Dispose the material and release its associated resources
  7514. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  7515. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  7516. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  7517. */
  7518. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7519. /**
  7520. * Creates a MultiMaterial from parsed MultiMaterial data.
  7521. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7522. * @param scene defines the hosting scene
  7523. * @returns a new MultiMaterial
  7524. */
  7525. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7526. }
  7527. }
  7528. declare module BABYLON {
  7529. /**
  7530. * Class used to represent data loading progression
  7531. */
  7532. export class SceneLoaderFlags {
  7533. private static _ForceFullSceneLoadingForIncremental;
  7534. private static _ShowLoadingScreen;
  7535. private static _CleanBoneMatrixWeights;
  7536. private static _loggingLevel;
  7537. /**
  7538. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7539. */
  7540. static ForceFullSceneLoadingForIncremental: boolean;
  7541. /**
  7542. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7543. */
  7544. static ShowLoadingScreen: boolean;
  7545. /**
  7546. * Defines the current logging level (while loading the scene)
  7547. * @ignorenaming
  7548. */
  7549. static loggingLevel: number;
  7550. /**
  7551. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7552. */
  7553. static CleanBoneMatrixWeights: boolean;
  7554. }
  7555. }
  7556. declare module BABYLON {
  7557. /**
  7558. * Class used to override all child animations of a given target
  7559. */
  7560. export class AnimationPropertiesOverride {
  7561. /**
  7562. * Gets or sets a value indicating if animation blending must be used
  7563. */
  7564. enableBlending: boolean;
  7565. /**
  7566. * Gets or sets the blending speed to use when enableBlending is true
  7567. */
  7568. blendingSpeed: number;
  7569. /**
  7570. * Gets or sets the default loop mode to use
  7571. */
  7572. loopMode: number;
  7573. }
  7574. }
  7575. declare module BABYLON {
  7576. /**
  7577. * Defines a target to use with MorphTargetManager
  7578. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  7579. */
  7580. export class MorphTarget implements IAnimatable {
  7581. /** defines the name of the target */
  7582. name: string;
  7583. /**
  7584. * Gets or sets the list of animations
  7585. */
  7586. animations: Animation[];
  7587. private _scene;
  7588. private _positions;
  7589. private _normals;
  7590. private _tangents;
  7591. private _influence;
  7592. /**
  7593. * Observable raised when the influence changes
  7594. */
  7595. onInfluenceChanged: Observable<boolean>;
  7596. /** @hidden */
  7597. _onDataLayoutChanged: Observable<void>;
  7598. /**
  7599. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  7600. */
  7601. influence: number;
  7602. /**
  7603. * Gets or sets the id of the morph Target
  7604. */
  7605. id: string;
  7606. private _animationPropertiesOverride;
  7607. /**
  7608. * Gets or sets the animation properties override
  7609. */
  7610. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  7611. /**
  7612. * Creates a new MorphTarget
  7613. * @param name defines the name of the target
  7614. * @param influence defines the influence to use
  7615. * @param scene defines the scene the morphtarget belongs to
  7616. */
  7617. constructor(
  7618. /** defines the name of the target */
  7619. name: string, influence?: number, scene?: Nullable<Scene>);
  7620. /**
  7621. * Gets a boolean defining if the target contains position data
  7622. */
  7623. readonly hasPositions: boolean;
  7624. /**
  7625. * Gets a boolean defining if the target contains normal data
  7626. */
  7627. readonly hasNormals: boolean;
  7628. /**
  7629. * Gets a boolean defining if the target contains tangent data
  7630. */
  7631. readonly hasTangents: boolean;
  7632. /**
  7633. * Affects position data to this target
  7634. * @param data defines the position data to use
  7635. */
  7636. setPositions(data: Nullable<FloatArray>): void;
  7637. /**
  7638. * Gets the position data stored in this target
  7639. * @returns a FloatArray containing the position data (or null if not present)
  7640. */
  7641. getPositions(): Nullable<FloatArray>;
  7642. /**
  7643. * Affects normal data to this target
  7644. * @param data defines the normal data to use
  7645. */
  7646. setNormals(data: Nullable<FloatArray>): void;
  7647. /**
  7648. * Gets the normal data stored in this target
  7649. * @returns a FloatArray containing the normal data (or null if not present)
  7650. */
  7651. getNormals(): Nullable<FloatArray>;
  7652. /**
  7653. * Affects tangent data to this target
  7654. * @param data defines the tangent data to use
  7655. */
  7656. setTangents(data: Nullable<FloatArray>): void;
  7657. /**
  7658. * Gets the tangent data stored in this target
  7659. * @returns a FloatArray containing the tangent data (or null if not present)
  7660. */
  7661. getTangents(): Nullable<FloatArray>;
  7662. /**
  7663. * Serializes the current target into a Serialization object
  7664. * @returns the serialized object
  7665. */
  7666. serialize(): any;
  7667. /**
  7668. * Returns the string "MorphTarget"
  7669. * @returns "MorphTarget"
  7670. */
  7671. getClassName(): string;
  7672. /**
  7673. * Creates a new target from serialized data
  7674. * @param serializationObject defines the serialized data to use
  7675. * @returns a new MorphTarget
  7676. */
  7677. static Parse(serializationObject: any): MorphTarget;
  7678. /**
  7679. * Creates a MorphTarget from mesh data
  7680. * @param mesh defines the source mesh
  7681. * @param name defines the name to use for the new target
  7682. * @param influence defines the influence to attach to the target
  7683. * @returns a new MorphTarget
  7684. */
  7685. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  7686. }
  7687. }
  7688. declare module BABYLON {
  7689. /**
  7690. * This class is used to deform meshes using morphing between different targets
  7691. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  7692. */
  7693. export class MorphTargetManager {
  7694. private _targets;
  7695. private _targetInfluenceChangedObservers;
  7696. private _targetDataLayoutChangedObservers;
  7697. private _activeTargets;
  7698. private _scene;
  7699. private _influences;
  7700. private _supportsNormals;
  7701. private _supportsTangents;
  7702. private _vertexCount;
  7703. private _uniqueId;
  7704. private _tempInfluences;
  7705. /**
  7706. * Creates a new MorphTargetManager
  7707. * @param scene defines the current scene
  7708. */
  7709. constructor(scene?: Nullable<Scene>);
  7710. /**
  7711. * Gets the unique ID of this manager
  7712. */
  7713. readonly uniqueId: number;
  7714. /**
  7715. * Gets the number of vertices handled by this manager
  7716. */
  7717. readonly vertexCount: number;
  7718. /**
  7719. * Gets a boolean indicating if this manager supports morphing of normals
  7720. */
  7721. readonly supportsNormals: boolean;
  7722. /**
  7723. * Gets a boolean indicating if this manager supports morphing of tangents
  7724. */
  7725. readonly supportsTangents: boolean;
  7726. /**
  7727. * Gets the number of targets stored in this manager
  7728. */
  7729. readonly numTargets: number;
  7730. /**
  7731. * Gets the number of influencers (ie. the number of targets with influences > 0)
  7732. */
  7733. readonly numInfluencers: number;
  7734. /**
  7735. * Gets the list of influences (one per target)
  7736. */
  7737. readonly influences: Float32Array;
  7738. /**
  7739. * Gets the active target at specified index. An active target is a target with an influence > 0
  7740. * @param index defines the index to check
  7741. * @returns the requested target
  7742. */
  7743. getActiveTarget(index: number): MorphTarget;
  7744. /**
  7745. * Gets the target at specified index
  7746. * @param index defines the index to check
  7747. * @returns the requested target
  7748. */
  7749. getTarget(index: number): MorphTarget;
  7750. /**
  7751. * Add a new target to this manager
  7752. * @param target defines the target to add
  7753. */
  7754. addTarget(target: MorphTarget): void;
  7755. /**
  7756. * Removes a target from the manager
  7757. * @param target defines the target to remove
  7758. */
  7759. removeTarget(target: MorphTarget): void;
  7760. /**
  7761. * Serializes the current manager into a Serialization object
  7762. * @returns the serialized object
  7763. */
  7764. serialize(): any;
  7765. private _syncActiveTargets;
  7766. /**
  7767. * Syncrhonize the targets with all the meshes using this morph target manager
  7768. */
  7769. synchronize(): void;
  7770. /**
  7771. * Creates a new MorphTargetManager from serialized data
  7772. * @param serializationObject defines the serialized data
  7773. * @param scene defines the hosting scene
  7774. * @returns the new MorphTargetManager
  7775. */
  7776. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  7777. }
  7778. }
  7779. declare module BABYLON {
  7780. /**
  7781. * Creates an instance based on a source mesh.
  7782. */
  7783. export class InstancedMesh extends AbstractMesh {
  7784. private _sourceMesh;
  7785. private _currentLOD;
  7786. /** @hidden */
  7787. _indexInSourceMeshInstanceArray: number;
  7788. constructor(name: string, source: Mesh);
  7789. /**
  7790. * Returns the string "InstancedMesh".
  7791. */
  7792. getClassName(): string;
  7793. /**
  7794. * If the source mesh receives shadows
  7795. */
  7796. readonly receiveShadows: boolean;
  7797. /**
  7798. * The material of the source mesh
  7799. */
  7800. readonly material: Nullable<Material>;
  7801. /**
  7802. * Visibility of the source mesh
  7803. */
  7804. readonly visibility: number;
  7805. /**
  7806. * Skeleton of the source mesh
  7807. */
  7808. readonly skeleton: Nullable<Skeleton>;
  7809. /**
  7810. * Rendering ground id of the source mesh
  7811. */
  7812. renderingGroupId: number;
  7813. /**
  7814. * Returns the total number of vertices (integer).
  7815. */
  7816. getTotalVertices(): number;
  7817. /**
  7818. * Returns a positive integer : the total number of indices in this mesh geometry.
  7819. * @returns the numner of indices or zero if the mesh has no geometry.
  7820. */
  7821. getTotalIndices(): number;
  7822. /**
  7823. * The source mesh of the instance
  7824. */
  7825. readonly sourceMesh: Mesh;
  7826. /**
  7827. * Is this node ready to be used/rendered
  7828. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  7829. * @return {boolean} is it ready
  7830. */
  7831. isReady(completeCheck?: boolean): boolean;
  7832. /**
  7833. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  7834. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  7835. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  7836. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  7837. */
  7838. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  7839. /**
  7840. * Sets the vertex data of the mesh geometry for the requested `kind`.
  7841. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  7842. * The `data` are either a numeric array either a Float32Array.
  7843. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  7844. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  7845. * Note that a new underlying VertexBuffer object is created each call.
  7846. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  7847. *
  7848. * Possible `kind` values :
  7849. * - VertexBuffer.PositionKind
  7850. * - VertexBuffer.UVKind
  7851. * - VertexBuffer.UV2Kind
  7852. * - VertexBuffer.UV3Kind
  7853. * - VertexBuffer.UV4Kind
  7854. * - VertexBuffer.UV5Kind
  7855. * - VertexBuffer.UV6Kind
  7856. * - VertexBuffer.ColorKind
  7857. * - VertexBuffer.MatricesIndicesKind
  7858. * - VertexBuffer.MatricesIndicesExtraKind
  7859. * - VertexBuffer.MatricesWeightsKind
  7860. * - VertexBuffer.MatricesWeightsExtraKind
  7861. *
  7862. * Returns the Mesh.
  7863. */
  7864. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  7865. /**
  7866. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  7867. * If the mesh has no geometry, it is simply returned as it is.
  7868. * The `data` are either a numeric array either a Float32Array.
  7869. * No new underlying VertexBuffer object is created.
  7870. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  7871. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  7872. *
  7873. * Possible `kind` values :
  7874. * - VertexBuffer.PositionKind
  7875. * - VertexBuffer.UVKind
  7876. * - VertexBuffer.UV2Kind
  7877. * - VertexBuffer.UV3Kind
  7878. * - VertexBuffer.UV4Kind
  7879. * - VertexBuffer.UV5Kind
  7880. * - VertexBuffer.UV6Kind
  7881. * - VertexBuffer.ColorKind
  7882. * - VertexBuffer.MatricesIndicesKind
  7883. * - VertexBuffer.MatricesIndicesExtraKind
  7884. * - VertexBuffer.MatricesWeightsKind
  7885. * - VertexBuffer.MatricesWeightsExtraKind
  7886. *
  7887. * Returns the Mesh.
  7888. */
  7889. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  7890. /**
  7891. * Sets the mesh indices.
  7892. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  7893. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  7894. * This method creates a new index buffer each call.
  7895. * Returns the Mesh.
  7896. */
  7897. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  7898. /**
  7899. * Boolean : True if the mesh owns the requested kind of data.
  7900. */
  7901. isVerticesDataPresent(kind: string): boolean;
  7902. /**
  7903. * Returns an array of indices (IndicesArray).
  7904. */
  7905. getIndices(): Nullable<IndicesArray>;
  7906. readonly _positions: Nullable<Vector3[]>;
  7907. /**
  7908. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  7909. * This means the mesh underlying bounding box and sphere are recomputed.
  7910. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  7911. * @returns the current mesh
  7912. */
  7913. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  7914. /** @hidden */
  7915. _preActivate(): InstancedMesh;
  7916. /** @hidden */
  7917. _activate(renderId: number): InstancedMesh;
  7918. /**
  7919. * Returns the current associated LOD AbstractMesh.
  7920. */
  7921. getLOD(camera: Camera): AbstractMesh;
  7922. /** @hidden */
  7923. _syncSubMeshes(): InstancedMesh;
  7924. /** @hidden */
  7925. _generatePointsArray(): boolean;
  7926. /**
  7927. * Creates a new InstancedMesh from the current mesh.
  7928. * - name (string) : the cloned mesh name
  7929. * - newParent (optional Node) : the optional Node to parent the clone to.
  7930. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  7931. *
  7932. * Returns the clone.
  7933. */
  7934. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  7935. /**
  7936. * Disposes the InstancedMesh.
  7937. * Returns nothing.
  7938. */
  7939. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7940. }
  7941. }
  7942. declare module BABYLON {
  7943. /**
  7944. * Class for creating a cube texture
  7945. */
  7946. export class CubeTexture extends BaseTexture {
  7947. private _delayedOnLoad;
  7948. /**
  7949. * The url of the texture
  7950. */
  7951. url: string;
  7952. /**
  7953. * Gets or sets the center of the bounding box associated with the cube texture.
  7954. * It must define where the camera used to render the texture was set
  7955. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7956. */
  7957. boundingBoxPosition: Vector3;
  7958. private _boundingBoxSize;
  7959. /**
  7960. * Gets or sets the size of the bounding box associated with the cube texture
  7961. * When defined, the cubemap will switch to local mode
  7962. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7963. * @example https://www.babylonjs-playground.com/#RNASML
  7964. */
  7965. /**
  7966. * Returns the bounding box size
  7967. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7968. */
  7969. boundingBoxSize: Vector3;
  7970. protected _rotationY: number;
  7971. /**
  7972. * Sets texture matrix rotation angle around Y axis in radians.
  7973. */
  7974. /**
  7975. * Gets texture matrix rotation angle around Y axis radians.
  7976. */
  7977. rotationY: number;
  7978. /**
  7979. * Are mip maps generated for this texture or not.
  7980. */
  7981. readonly noMipmap: boolean;
  7982. private _noMipmap;
  7983. private _files;
  7984. private _extensions;
  7985. private _textureMatrix;
  7986. private _format;
  7987. private _createPolynomials;
  7988. /** @hidden */
  7989. _prefiltered: boolean;
  7990. /**
  7991. * Creates a cube texture from an array of image urls
  7992. * @param files defines an array of image urls
  7993. * @param scene defines the hosting scene
  7994. * @param noMipmap specifies if mip maps are not used
  7995. * @returns a cube texture
  7996. */
  7997. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7998. /**
  7999. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8000. * @param url defines the url of the prefiltered texture
  8001. * @param scene defines the scene the texture is attached to
  8002. * @param forcedExtension defines the extension of the file if different from the url
  8003. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8004. * @return the prefiltered texture
  8005. */
  8006. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8007. /**
  8008. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8009. * as prefiltered data.
  8010. * @param rootUrl defines the url of the texture or the root name of the six images
  8011. * @param scene defines the scene the texture is attached to
  8012. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8013. * @param noMipmap defines if mipmaps should be created or not
  8014. * @param files defines the six files to load for the different faces
  8015. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8016. * @param onError defines a callback triggered in case of error during load
  8017. * @param format defines the internal format to use for the texture once loaded
  8018. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8019. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8020. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8021. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8022. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8023. * @return the cube texture
  8024. */
  8025. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  8026. /**
  8027. * Get the current class name of the texture useful for serialization or dynamic coding.
  8028. * @returns "CubeTexture"
  8029. */
  8030. getClassName(): string;
  8031. /**
  8032. * Update the url (and optional buffer) of this texture if url was null during construction.
  8033. * @param url the url of the texture
  8034. * @param forcedExtension defines the extension to use
  8035. * @param onLoad callback called when the texture is loaded (defaults to null)
  8036. */
  8037. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8038. /**
  8039. * Delays loading of the cube texture
  8040. * @param forcedExtension defines the extension to use
  8041. */
  8042. delayLoad(forcedExtension?: string): void;
  8043. /**
  8044. * Returns the reflection texture matrix
  8045. * @returns the reflection texture matrix
  8046. */
  8047. getReflectionTextureMatrix(): Matrix;
  8048. /**
  8049. * Sets the reflection texture matrix
  8050. * @param value Reflection texture matrix
  8051. */
  8052. setReflectionTextureMatrix(value: Matrix): void;
  8053. /**
  8054. * Parses text to create a cube texture
  8055. * @param parsedTexture define the serialized text to read from
  8056. * @param scene defines the hosting scene
  8057. * @param rootUrl defines the root url of the cube texture
  8058. * @returns a cube texture
  8059. */
  8060. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8061. /**
  8062. * Makes a clone, or deep copy, of the cube texture
  8063. * @returns a new cube texture
  8064. */
  8065. clone(): CubeTexture;
  8066. }
  8067. }
  8068. declare module BABYLON {
  8069. /** @hidden */
  8070. export var postprocessVertexShader: {
  8071. name: string;
  8072. shader: string;
  8073. };
  8074. }
  8075. declare module BABYLON {
  8076. /**
  8077. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8078. * This is the base of the follow, arc rotate cameras and Free camera
  8079. * @see http://doc.babylonjs.com/features/cameras
  8080. */
  8081. export class TargetCamera extends Camera {
  8082. private static _RigCamTransformMatrix;
  8083. private static _TargetTransformMatrix;
  8084. private static _TargetFocalPoint;
  8085. /**
  8086. * Define the current direction the camera is moving to
  8087. */
  8088. cameraDirection: Vector3;
  8089. /**
  8090. * Define the current rotation the camera is rotating to
  8091. */
  8092. cameraRotation: Vector2;
  8093. /**
  8094. * When set, the up vector of the camera will be updated by the rotation of the camera
  8095. */
  8096. updateUpVectorFromRotation: boolean;
  8097. private _tmpQuaternion;
  8098. /**
  8099. * Define the current rotation of the camera
  8100. */
  8101. rotation: Vector3;
  8102. /**
  8103. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8104. */
  8105. rotationQuaternion: Quaternion;
  8106. /**
  8107. * Define the current speed of the camera
  8108. */
  8109. speed: number;
  8110. /**
  8111. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8112. * around all axis.
  8113. */
  8114. noRotationConstraint: boolean;
  8115. /**
  8116. * Define the current target of the camera as an object or a position.
  8117. */
  8118. lockedTarget: any;
  8119. /** @hidden */
  8120. _currentTarget: Vector3;
  8121. /** @hidden */
  8122. _initialFocalDistance: number;
  8123. /** @hidden */
  8124. _viewMatrix: Matrix;
  8125. /** @hidden */
  8126. _camMatrix: Matrix;
  8127. /** @hidden */
  8128. _cameraTransformMatrix: Matrix;
  8129. /** @hidden */
  8130. _cameraRotationMatrix: Matrix;
  8131. /** @hidden */
  8132. _referencePoint: Vector3;
  8133. /** @hidden */
  8134. _transformedReferencePoint: Vector3;
  8135. protected _globalCurrentTarget: Vector3;
  8136. protected _globalCurrentUpVector: Vector3;
  8137. /** @hidden */
  8138. _reset: () => void;
  8139. private _defaultUp;
  8140. /**
  8141. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8142. * This is the base of the follow, arc rotate cameras and Free camera
  8143. * @see http://doc.babylonjs.com/features/cameras
  8144. * @param name Defines the name of the camera in the scene
  8145. * @param position Defines the start position of the camera in the scene
  8146. * @param scene Defines the scene the camera belongs to
  8147. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8148. */
  8149. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8150. /**
  8151. * Gets the position in front of the camera at a given distance.
  8152. * @param distance The distance from the camera we want the position to be
  8153. * @returns the position
  8154. */
  8155. getFrontPosition(distance: number): Vector3;
  8156. /** @hidden */
  8157. _getLockedTargetPosition(): Nullable<Vector3>;
  8158. private _storedPosition;
  8159. private _storedRotation;
  8160. private _storedRotationQuaternion;
  8161. /**
  8162. * Store current camera state of the camera (fov, position, rotation, etc..)
  8163. * @returns the camera
  8164. */
  8165. storeState(): Camera;
  8166. /**
  8167. * Restored camera state. You must call storeState() first
  8168. * @returns whether it was successful or not
  8169. * @hidden
  8170. */
  8171. _restoreStateValues(): boolean;
  8172. /** @hidden */
  8173. _initCache(): void;
  8174. /** @hidden */
  8175. _updateCache(ignoreParentClass?: boolean): void;
  8176. /** @hidden */
  8177. _isSynchronizedViewMatrix(): boolean;
  8178. /** @hidden */
  8179. _computeLocalCameraSpeed(): number;
  8180. /** @hidden */
  8181. setTarget(target: Vector3): void;
  8182. /**
  8183. * Return the current target position of the camera. This value is expressed in local space.
  8184. * @returns the target position
  8185. */
  8186. getTarget(): Vector3;
  8187. /** @hidden */
  8188. _decideIfNeedsToMove(): boolean;
  8189. /** @hidden */
  8190. _updatePosition(): void;
  8191. /** @hidden */
  8192. _checkInputs(): void;
  8193. protected _updateCameraRotationMatrix(): void;
  8194. /**
  8195. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8196. * @returns the current camera
  8197. */
  8198. private _rotateUpVectorWithCameraRotationMatrix;
  8199. private _cachedRotationZ;
  8200. private _cachedQuaternionRotationZ;
  8201. /** @hidden */
  8202. _getViewMatrix(): Matrix;
  8203. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8204. /**
  8205. * @hidden
  8206. */
  8207. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8208. /**
  8209. * @hidden
  8210. */
  8211. _updateRigCameras(): void;
  8212. private _getRigCamPositionAndTarget;
  8213. /**
  8214. * Gets the current object class name.
  8215. * @return the class name
  8216. */
  8217. getClassName(): string;
  8218. }
  8219. }
  8220. declare module BABYLON {
  8221. /**
  8222. * @ignore
  8223. * This is a list of all the different input types that are available in the application.
  8224. * Fo instance: ArcRotateCameraGamepadInput...
  8225. */
  8226. export var CameraInputTypes: {};
  8227. /**
  8228. * This is the contract to implement in order to create a new input class.
  8229. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8230. */
  8231. export interface ICameraInput<TCamera extends Camera> {
  8232. /**
  8233. * Defines the camera the input is attached to.
  8234. */
  8235. camera: Nullable<TCamera>;
  8236. /**
  8237. * Gets the class name of the current intput.
  8238. * @returns the class name
  8239. */
  8240. getClassName(): string;
  8241. /**
  8242. * Get the friendly name associated with the input class.
  8243. * @returns the input friendly name
  8244. */
  8245. getSimpleName(): string;
  8246. /**
  8247. * Attach the input controls to a specific dom element to get the input from.
  8248. * @param element Defines the element the controls should be listened from
  8249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8250. */
  8251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8252. /**
  8253. * Detach the current controls from the specified dom element.
  8254. * @param element Defines the element to stop listening the inputs from
  8255. */
  8256. detachControl(element: Nullable<HTMLElement>): void;
  8257. /**
  8258. * Update the current camera state depending on the inputs that have been used this frame.
  8259. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8260. */
  8261. checkInputs?: () => void;
  8262. }
  8263. /**
  8264. * Represents a map of input types to input instance or input index to input instance.
  8265. */
  8266. export interface CameraInputsMap<TCamera extends Camera> {
  8267. /**
  8268. * Accessor to the input by input type.
  8269. */
  8270. [name: string]: ICameraInput<TCamera>;
  8271. /**
  8272. * Accessor to the input by input index.
  8273. */
  8274. [idx: number]: ICameraInput<TCamera>;
  8275. }
  8276. /**
  8277. * This represents the input manager used within a camera.
  8278. * It helps dealing with all the different kind of input attached to a camera.
  8279. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8280. */
  8281. export class CameraInputsManager<TCamera extends Camera> {
  8282. /**
  8283. * Defines the list of inputs attahed to the camera.
  8284. */
  8285. attached: CameraInputsMap<TCamera>;
  8286. /**
  8287. * Defines the dom element the camera is collecting inputs from.
  8288. * This is null if the controls have not been attached.
  8289. */
  8290. attachedElement: Nullable<HTMLElement>;
  8291. /**
  8292. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8293. */
  8294. noPreventDefault: boolean;
  8295. /**
  8296. * Defined the camera the input manager belongs to.
  8297. */
  8298. camera: TCamera;
  8299. /**
  8300. * Update the current camera state depending on the inputs that have been used this frame.
  8301. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8302. */
  8303. checkInputs: () => void;
  8304. /**
  8305. * Instantiate a new Camera Input Manager.
  8306. * @param camera Defines the camera the input manager blongs to
  8307. */
  8308. constructor(camera: TCamera);
  8309. /**
  8310. * Add an input method to a camera
  8311. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8312. * @param input camera input method
  8313. */
  8314. add(input: ICameraInput<TCamera>): void;
  8315. /**
  8316. * Remove a specific input method from a camera
  8317. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8318. * @param inputToRemove camera input method
  8319. */
  8320. remove(inputToRemove: ICameraInput<TCamera>): void;
  8321. /**
  8322. * Remove a specific input type from a camera
  8323. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8324. * @param inputType the type of the input to remove
  8325. */
  8326. removeByType(inputType: string): void;
  8327. private _addCheckInputs;
  8328. /**
  8329. * Attach the input controls to the currently attached dom element to listen the events from.
  8330. * @param input Defines the input to attach
  8331. */
  8332. attachInput(input: ICameraInput<TCamera>): void;
  8333. /**
  8334. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8335. * @param element Defines the dom element to collect the events from
  8336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8337. */
  8338. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8339. /**
  8340. * Detach the current manager inputs controls from a specific dom element.
  8341. * @param element Defines the dom element to collect the events from
  8342. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8343. */
  8344. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8345. /**
  8346. * Rebuild the dynamic inputCheck function from the current list of
  8347. * defined inputs in the manager.
  8348. */
  8349. rebuildInputCheck(): void;
  8350. /**
  8351. * Remove all attached input methods from a camera
  8352. */
  8353. clear(): void;
  8354. /**
  8355. * Serialize the current input manager attached to a camera.
  8356. * This ensures than once parsed,
  8357. * the input associated to the camera will be identical to the current ones
  8358. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8359. */
  8360. serialize(serializedCamera: any): void;
  8361. /**
  8362. * Parses an input manager serialized JSON to restore the previous list of inputs
  8363. * and states associated to a camera.
  8364. * @param parsedCamera Defines the JSON to parse
  8365. */
  8366. parse(parsedCamera: any): void;
  8367. }
  8368. }
  8369. declare module BABYLON {
  8370. /**
  8371. * Gather the list of keyboard event types as constants.
  8372. */
  8373. export class KeyboardEventTypes {
  8374. /**
  8375. * The keydown event is fired when a key becomes active (pressed).
  8376. */
  8377. static readonly KEYDOWN: number;
  8378. /**
  8379. * The keyup event is fired when a key has been released.
  8380. */
  8381. static readonly KEYUP: number;
  8382. }
  8383. /**
  8384. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8385. */
  8386. export class KeyboardInfo {
  8387. /**
  8388. * Defines the type of event (KeyboardEventTypes)
  8389. */
  8390. type: number;
  8391. /**
  8392. * Defines the related dom event
  8393. */
  8394. event: KeyboardEvent;
  8395. /**
  8396. * Instantiates a new keyboard info.
  8397. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8398. * @param type Defines the type of event (KeyboardEventTypes)
  8399. * @param event Defines the related dom event
  8400. */
  8401. constructor(
  8402. /**
  8403. * Defines the type of event (KeyboardEventTypes)
  8404. */
  8405. type: number,
  8406. /**
  8407. * Defines the related dom event
  8408. */
  8409. event: KeyboardEvent);
  8410. }
  8411. /**
  8412. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8413. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8414. */
  8415. export class KeyboardInfoPre extends KeyboardInfo {
  8416. /**
  8417. * Defines the type of event (KeyboardEventTypes)
  8418. */
  8419. type: number;
  8420. /**
  8421. * Defines the related dom event
  8422. */
  8423. event: KeyboardEvent;
  8424. /**
  8425. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8426. */
  8427. skipOnPointerObservable: boolean;
  8428. /**
  8429. * Instantiates a new keyboard pre info.
  8430. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8431. * @param type Defines the type of event (KeyboardEventTypes)
  8432. * @param event Defines the related dom event
  8433. */
  8434. constructor(
  8435. /**
  8436. * Defines the type of event (KeyboardEventTypes)
  8437. */
  8438. type: number,
  8439. /**
  8440. * Defines the related dom event
  8441. */
  8442. event: KeyboardEvent);
  8443. }
  8444. }
  8445. declare module BABYLON {
  8446. /**
  8447. * Manage the keyboard inputs to control the movement of a free camera.
  8448. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8449. */
  8450. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8451. /**
  8452. * Defines the camera the input is attached to.
  8453. */
  8454. camera: FreeCamera;
  8455. /**
  8456. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8457. */
  8458. keysUp: number[];
  8459. /**
  8460. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8461. */
  8462. keysDown: number[];
  8463. /**
  8464. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8465. */
  8466. keysLeft: number[];
  8467. /**
  8468. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8469. */
  8470. keysRight: number[];
  8471. private _keys;
  8472. private _onCanvasBlurObserver;
  8473. private _onKeyboardObserver;
  8474. private _engine;
  8475. private _scene;
  8476. /**
  8477. * Attach the input controls to a specific dom element to get the input from.
  8478. * @param element Defines the element the controls should be listened from
  8479. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8480. */
  8481. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8482. /**
  8483. * Detach the current controls from the specified dom element.
  8484. * @param element Defines the element to stop listening the inputs from
  8485. */
  8486. detachControl(element: Nullable<HTMLElement>): void;
  8487. /**
  8488. * Update the current camera state depending on the inputs that have been used this frame.
  8489. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8490. */
  8491. checkInputs(): void;
  8492. /**
  8493. * Gets the class name of the current intput.
  8494. * @returns the class name
  8495. */
  8496. getClassName(): string;
  8497. /** @hidden */
  8498. _onLostFocus(): void;
  8499. /**
  8500. * Get the friendly name associated with the input class.
  8501. * @returns the input friendly name
  8502. */
  8503. getSimpleName(): string;
  8504. }
  8505. }
  8506. declare module BABYLON {
  8507. /**
  8508. * Interface used to define ActionEvent
  8509. */
  8510. export interface IActionEvent {
  8511. /** The mesh or sprite that triggered the action */
  8512. source: any;
  8513. /** The X mouse cursor position at the time of the event */
  8514. pointerX: number;
  8515. /** The Y mouse cursor position at the time of the event */
  8516. pointerY: number;
  8517. /** The mesh that is currently pointed at (can be null) */
  8518. meshUnderPointer: Nullable<AbstractMesh>;
  8519. /** the original (browser) event that triggered the ActionEvent */
  8520. sourceEvent?: any;
  8521. /** additional data for the event */
  8522. additionalData?: any;
  8523. }
  8524. /**
  8525. * ActionEvent is the event being sent when an action is triggered.
  8526. */
  8527. export class ActionEvent implements IActionEvent {
  8528. /** The mesh or sprite that triggered the action */
  8529. source: any;
  8530. /** The X mouse cursor position at the time of the event */
  8531. pointerX: number;
  8532. /** The Y mouse cursor position at the time of the event */
  8533. pointerY: number;
  8534. /** The mesh that is currently pointed at (can be null) */
  8535. meshUnderPointer: Nullable<AbstractMesh>;
  8536. /** the original (browser) event that triggered the ActionEvent */
  8537. sourceEvent?: any;
  8538. /** additional data for the event */
  8539. additionalData?: any;
  8540. /**
  8541. * Creates a new ActionEvent
  8542. * @param source The mesh or sprite that triggered the action
  8543. * @param pointerX The X mouse cursor position at the time of the event
  8544. * @param pointerY The Y mouse cursor position at the time of the event
  8545. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  8546. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  8547. * @param additionalData additional data for the event
  8548. */
  8549. constructor(
  8550. /** The mesh or sprite that triggered the action */
  8551. source: any,
  8552. /** The X mouse cursor position at the time of the event */
  8553. pointerX: number,
  8554. /** The Y mouse cursor position at the time of the event */
  8555. pointerY: number,
  8556. /** The mesh that is currently pointed at (can be null) */
  8557. meshUnderPointer: Nullable<AbstractMesh>,
  8558. /** the original (browser) event that triggered the ActionEvent */
  8559. sourceEvent?: any,
  8560. /** additional data for the event */
  8561. additionalData?: any);
  8562. /**
  8563. * Helper function to auto-create an ActionEvent from a source mesh.
  8564. * @param source The source mesh that triggered the event
  8565. * @param evt The original (browser) event
  8566. * @param additionalData additional data for the event
  8567. * @returns the new ActionEvent
  8568. */
  8569. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  8570. /**
  8571. * Helper function to auto-create an ActionEvent from a source sprite
  8572. * @param source The source sprite that triggered the event
  8573. * @param scene Scene associated with the sprite
  8574. * @param evt The original (browser) event
  8575. * @param additionalData additional data for the event
  8576. * @returns the new ActionEvent
  8577. */
  8578. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  8579. /**
  8580. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  8581. * @param scene the scene where the event occurred
  8582. * @param evt The original (browser) event
  8583. * @returns the new ActionEvent
  8584. */
  8585. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  8586. /**
  8587. * Helper function to auto-create an ActionEvent from a primitive
  8588. * @param prim defines the target primitive
  8589. * @param pointerPos defines the pointer position
  8590. * @param evt The original (browser) event
  8591. * @param additionalData additional data for the event
  8592. * @returns the new ActionEvent
  8593. */
  8594. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  8595. }
  8596. }
  8597. declare module BABYLON {
  8598. /**
  8599. * Interface describing all the common properties and methods a shadow light needs to implement.
  8600. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8601. * as well as binding the different shadow properties to the effects.
  8602. */
  8603. export interface IShadowLight extends Light {
  8604. /**
  8605. * The light id in the scene (used in scene.findLighById for instance)
  8606. */
  8607. id: string;
  8608. /**
  8609. * The position the shdow will be casted from.
  8610. */
  8611. position: Vector3;
  8612. /**
  8613. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8614. */
  8615. direction: Vector3;
  8616. /**
  8617. * The transformed position. Position of the light in world space taking parenting in account.
  8618. */
  8619. transformedPosition: Vector3;
  8620. /**
  8621. * The transformed direction. Direction of the light in world space taking parenting in account.
  8622. */
  8623. transformedDirection: Vector3;
  8624. /**
  8625. * The friendly name of the light in the scene.
  8626. */
  8627. name: string;
  8628. /**
  8629. * Defines the shadow projection clipping minimum z value.
  8630. */
  8631. shadowMinZ: number;
  8632. /**
  8633. * Defines the shadow projection clipping maximum z value.
  8634. */
  8635. shadowMaxZ: number;
  8636. /**
  8637. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8638. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8639. */
  8640. computeTransformedInformation(): boolean;
  8641. /**
  8642. * Gets the scene the light belongs to.
  8643. * @returns The scene
  8644. */
  8645. getScene(): Scene;
  8646. /**
  8647. * Callback defining a custom Projection Matrix Builder.
  8648. * This can be used to override the default projection matrix computation.
  8649. */
  8650. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8651. /**
  8652. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8653. * @param matrix The materix to updated with the projection information
  8654. * @param viewMatrix The transform matrix of the light
  8655. * @param renderList The list of mesh to render in the map
  8656. * @returns The current light
  8657. */
  8658. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8659. /**
  8660. * Gets the current depth scale used in ESM.
  8661. * @returns The scale
  8662. */
  8663. getDepthScale(): number;
  8664. /**
  8665. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8666. * @returns true if a cube texture needs to be use
  8667. */
  8668. needCube(): boolean;
  8669. /**
  8670. * Detects if the projection matrix requires to be recomputed this frame.
  8671. * @returns true if it requires to be recomputed otherwise, false.
  8672. */
  8673. needProjectionMatrixCompute(): boolean;
  8674. /**
  8675. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8676. */
  8677. forceProjectionMatrixCompute(): void;
  8678. /**
  8679. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8680. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8681. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8682. */
  8683. getShadowDirection(faceIndex?: number): Vector3;
  8684. /**
  8685. * Gets the minZ used for shadow according to both the scene and the light.
  8686. * @param activeCamera The camera we are returning the min for
  8687. * @returns the depth min z
  8688. */
  8689. getDepthMinZ(activeCamera: Camera): number;
  8690. /**
  8691. * Gets the maxZ used for shadow according to both the scene and the light.
  8692. * @param activeCamera The camera we are returning the max for
  8693. * @returns the depth max z
  8694. */
  8695. getDepthMaxZ(activeCamera: Camera): number;
  8696. }
  8697. /**
  8698. * Base implementation IShadowLight
  8699. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8700. */
  8701. export abstract class ShadowLight extends Light implements IShadowLight {
  8702. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8703. protected _position: Vector3;
  8704. protected _setPosition(value: Vector3): void;
  8705. /**
  8706. * Sets the position the shadow will be casted from. Also use as the light position for both
  8707. * point and spot lights.
  8708. */
  8709. /**
  8710. * Sets the position the shadow will be casted from. Also use as the light position for both
  8711. * point and spot lights.
  8712. */
  8713. position: Vector3;
  8714. protected _direction: Vector3;
  8715. protected _setDirection(value: Vector3): void;
  8716. /**
  8717. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8718. * Also use as the light direction on spot and directional lights.
  8719. */
  8720. /**
  8721. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8722. * Also use as the light direction on spot and directional lights.
  8723. */
  8724. direction: Vector3;
  8725. private _shadowMinZ;
  8726. /**
  8727. * Gets the shadow projection clipping minimum z value.
  8728. */
  8729. /**
  8730. * Sets the shadow projection clipping minimum z value.
  8731. */
  8732. shadowMinZ: number;
  8733. private _shadowMaxZ;
  8734. /**
  8735. * Sets the shadow projection clipping maximum z value.
  8736. */
  8737. /**
  8738. * Gets the shadow projection clipping maximum z value.
  8739. */
  8740. shadowMaxZ: number;
  8741. /**
  8742. * Callback defining a custom Projection Matrix Builder.
  8743. * This can be used to override the default projection matrix computation.
  8744. */
  8745. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8746. /**
  8747. * The transformed position. Position of the light in world space taking parenting in account.
  8748. */
  8749. transformedPosition: Vector3;
  8750. /**
  8751. * The transformed direction. Direction of the light in world space taking parenting in account.
  8752. */
  8753. transformedDirection: Vector3;
  8754. private _needProjectionMatrixCompute;
  8755. /**
  8756. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8757. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8758. */
  8759. computeTransformedInformation(): boolean;
  8760. /**
  8761. * Return the depth scale used for the shadow map.
  8762. * @returns the depth scale.
  8763. */
  8764. getDepthScale(): number;
  8765. /**
  8766. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8767. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8768. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8769. */
  8770. getShadowDirection(faceIndex?: number): Vector3;
  8771. /**
  8772. * Returns the ShadowLight absolute position in the World.
  8773. * @returns the position vector in world space
  8774. */
  8775. getAbsolutePosition(): Vector3;
  8776. /**
  8777. * Sets the ShadowLight direction toward the passed target.
  8778. * @param target The point tot target in local space
  8779. * @returns the updated ShadowLight direction
  8780. */
  8781. setDirectionToTarget(target: Vector3): Vector3;
  8782. /**
  8783. * Returns the light rotation in euler definition.
  8784. * @returns the x y z rotation in local space.
  8785. */
  8786. getRotation(): Vector3;
  8787. /**
  8788. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8789. * @returns true if a cube texture needs to be use
  8790. */
  8791. needCube(): boolean;
  8792. /**
  8793. * Detects if the projection matrix requires to be recomputed this frame.
  8794. * @returns true if it requires to be recomputed otherwise, false.
  8795. */
  8796. needProjectionMatrixCompute(): boolean;
  8797. /**
  8798. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8799. */
  8800. forceProjectionMatrixCompute(): void;
  8801. /** @hidden */
  8802. _initCache(): void;
  8803. /** @hidden */
  8804. _isSynchronized(): boolean;
  8805. /**
  8806. * Computes the world matrix of the node
  8807. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8808. * @returns the world matrix
  8809. */
  8810. computeWorldMatrix(force?: boolean): Matrix;
  8811. /**
  8812. * Gets the minZ used for shadow according to both the scene and the light.
  8813. * @param activeCamera The camera we are returning the min for
  8814. * @returns the depth min z
  8815. */
  8816. getDepthMinZ(activeCamera: Camera): number;
  8817. /**
  8818. * Gets the maxZ used for shadow according to both the scene and the light.
  8819. * @param activeCamera The camera we are returning the max for
  8820. * @returns the depth max z
  8821. */
  8822. getDepthMaxZ(activeCamera: Camera): number;
  8823. /**
  8824. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8825. * @param matrix The materix to updated with the projection information
  8826. * @param viewMatrix The transform matrix of the light
  8827. * @param renderList The list of mesh to render in the map
  8828. * @returns The current light
  8829. */
  8830. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8831. }
  8832. }
  8833. declare module BABYLON {
  8834. /**
  8835. * "Static Class" containing the most commonly used helper while dealing with material for
  8836. * rendering purpose.
  8837. *
  8838. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8839. *
  8840. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8841. */
  8842. export class MaterialHelper {
  8843. /**
  8844. * Bind the current view position to an effect.
  8845. * @param effect The effect to be bound
  8846. * @param scene The scene the eyes position is used from
  8847. */
  8848. static BindEyePosition(effect: Effect, scene: Scene): void;
  8849. /**
  8850. * Helps preparing the defines values about the UVs in used in the effect.
  8851. * UVs are shared as much as we can accross channels in the shaders.
  8852. * @param texture The texture we are preparing the UVs for
  8853. * @param defines The defines to update
  8854. * @param key The channel key "diffuse", "specular"... used in the shader
  8855. */
  8856. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8857. /**
  8858. * Binds a texture matrix value to its corrsponding uniform
  8859. * @param texture The texture to bind the matrix for
  8860. * @param uniformBuffer The uniform buffer receivin the data
  8861. * @param key The channel key "diffuse", "specular"... used in the shader
  8862. */
  8863. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8864. /**
  8865. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8866. * @param mesh defines the current mesh
  8867. * @param scene defines the current scene
  8868. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8869. * @param pointsCloud defines if point cloud rendering has to be turned on
  8870. * @param fogEnabled defines if fog has to be turned on
  8871. * @param alphaTest defines if alpha testing has to be turned on
  8872. * @param defines defines the current list of defines
  8873. */
  8874. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8875. /**
  8876. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8877. * @param scene defines the current scene
  8878. * @param engine defines the current engine
  8879. * @param defines specifies the list of active defines
  8880. * @param useInstances defines if instances have to be turned on
  8881. * @param useClipPlane defines if clip plane have to be turned on
  8882. */
  8883. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8884. /**
  8885. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8886. * @param mesh The mesh containing the geometry data we will draw
  8887. * @param defines The defines to update
  8888. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8889. * @param useBones Precise whether bones should be used or not (override mesh info)
  8890. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8891. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8892. * @returns false if defines are considered not dirty and have not been checked
  8893. */
  8894. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8895. /**
  8896. * Prepares the defines related to the light information passed in parameter
  8897. * @param scene The scene we are intending to draw
  8898. * @param mesh The mesh the effect is compiling for
  8899. * @param defines The defines to update
  8900. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8901. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8902. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8903. * @returns true if normals will be required for the rest of the effect
  8904. */
  8905. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8906. /**
  8907. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  8908. * that won t be acctive due to defines being turned off.
  8909. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8910. * @param samplersList The samplers list
  8911. * @param defines The defines helping in the list generation
  8912. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8913. */
  8914. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8915. /**
  8916. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8917. * @param defines The defines to update while falling back
  8918. * @param fallbacks The authorized effect fallbacks
  8919. * @param maxSimultaneousLights The maximum number of lights allowed
  8920. * @param rank the current rank of the Effect
  8921. * @returns The newly affected rank
  8922. */
  8923. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8924. /**
  8925. * Prepares the list of attributes required for morph targets according to the effect defines.
  8926. * @param attribs The current list of supported attribs
  8927. * @param mesh The mesh to prepare the morph targets attributes for
  8928. * @param defines The current Defines of the effect
  8929. */
  8930. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8931. /**
  8932. * Prepares the list of attributes required for bones according to the effect defines.
  8933. * @param attribs The current list of supported attribs
  8934. * @param mesh The mesh to prepare the bones attributes for
  8935. * @param defines The current Defines of the effect
  8936. * @param fallbacks The current efffect fallback strategy
  8937. */
  8938. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8939. /**
  8940. * Prepares the list of attributes required for instances according to the effect defines.
  8941. * @param attribs The current list of supported attribs
  8942. * @param defines The current Defines of the effect
  8943. */
  8944. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  8945. /**
  8946. * Binds the light shadow information to the effect for the given mesh.
  8947. * @param light The light containing the generator
  8948. * @param scene The scene the lights belongs to
  8949. * @param mesh The mesh we are binding the information to render
  8950. * @param lightIndex The light index in the effect used to render the mesh
  8951. * @param effect The effect we are binding the data to
  8952. */
  8953. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8954. /**
  8955. * Binds the light information to the effect.
  8956. * @param light The light containing the generator
  8957. * @param effect The effect we are binding the data to
  8958. * @param lightIndex The light index in the effect used to render
  8959. */
  8960. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8961. /**
  8962. * Binds the lights information from the scene to the effect for the given mesh.
  8963. * @param scene The scene the lights belongs to
  8964. * @param mesh The mesh we are binding the information to render
  8965. * @param effect The effect we are binding the data to
  8966. * @param defines The generated defines for the effect
  8967. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8968. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8969. */
  8970. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  8971. private static _tempFogColor;
  8972. /**
  8973. * Binds the fog information from the scene to the effect for the given mesh.
  8974. * @param scene The scene the lights belongs to
  8975. * @param mesh The mesh we are binding the information to render
  8976. * @param effect The effect we are binding the data to
  8977. * @param linearSpace Defines if the fog effect is applied in linear space
  8978. */
  8979. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8980. /**
  8981. * Binds the bones information from the mesh to the effect.
  8982. * @param mesh The mesh we are binding the information to render
  8983. * @param effect The effect we are binding the data to
  8984. */
  8985. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8986. /**
  8987. * Binds the morph targets information from the mesh to the effect.
  8988. * @param abstractMesh The mesh we are binding the information to render
  8989. * @param effect The effect we are binding the data to
  8990. */
  8991. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8992. /**
  8993. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8994. * @param defines The generated defines used in the effect
  8995. * @param effect The effect we are binding the data to
  8996. * @param scene The scene we are willing to render with logarithmic scale for
  8997. */
  8998. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8999. /**
  9000. * Binds the clip plane information from the scene to the effect.
  9001. * @param scene The scene the clip plane information are extracted from
  9002. * @param effect The effect we are binding the data to
  9003. */
  9004. static BindClipPlane(effect: Effect, scene: Scene): void;
  9005. }
  9006. }
  9007. declare module BABYLON {
  9008. /** @hidden */
  9009. export var kernelBlurVaryingDeclaration: {
  9010. name: string;
  9011. shader: string;
  9012. };
  9013. }
  9014. declare module BABYLON {
  9015. /** @hidden */
  9016. export var kernelBlurFragment: {
  9017. name: string;
  9018. shader: string;
  9019. };
  9020. }
  9021. declare module BABYLON {
  9022. /** @hidden */
  9023. export var kernelBlurFragment2: {
  9024. name: string;
  9025. shader: string;
  9026. };
  9027. }
  9028. declare module BABYLON {
  9029. /** @hidden */
  9030. export var kernelBlurPixelShader: {
  9031. name: string;
  9032. shader: string;
  9033. };
  9034. }
  9035. declare module BABYLON {
  9036. /** @hidden */
  9037. export var kernelBlurVertex: {
  9038. name: string;
  9039. shader: string;
  9040. };
  9041. }
  9042. declare module BABYLON {
  9043. /** @hidden */
  9044. export var kernelBlurVertexShader: {
  9045. name: string;
  9046. shader: string;
  9047. };
  9048. }
  9049. declare module BABYLON {
  9050. /**
  9051. * The Blur Post Process which blurs an image based on a kernel and direction.
  9052. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9053. */
  9054. export class BlurPostProcess extends PostProcess {
  9055. /** The direction in which to blur the image. */
  9056. direction: Vector2;
  9057. private blockCompilation;
  9058. protected _kernel: number;
  9059. protected _idealKernel: number;
  9060. protected _packedFloat: boolean;
  9061. private _staticDefines;
  9062. /**
  9063. * Sets the length in pixels of the blur sample region
  9064. */
  9065. /**
  9066. * Gets the length in pixels of the blur sample region
  9067. */
  9068. kernel: number;
  9069. /**
  9070. * Sets wether or not the blur needs to unpack/repack floats
  9071. */
  9072. /**
  9073. * Gets wether or not the blur is unpacking/repacking floats
  9074. */
  9075. packedFloat: boolean;
  9076. /**
  9077. * Creates a new instance BlurPostProcess
  9078. * @param name The name of the effect.
  9079. * @param direction The direction in which to blur the image.
  9080. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  9081. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9082. * @param camera The camera to apply the render pass to.
  9083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9084. * @param engine The engine which the post process will be applied. (default: current engine)
  9085. * @param reusable If the post process can be reused on the same frame. (default: false)
  9086. * @param textureType Type of textures used when performing the post process. (default: 0)
  9087. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  9088. */
  9089. constructor(name: string,
  9090. /** The direction in which to blur the image. */
  9091. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9092. /**
  9093. * Updates the effect with the current post process compile time values and recompiles the shader.
  9094. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9095. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9096. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9097. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  9098. * @param onCompiled Called when the shader has been compiled.
  9099. * @param onError Called if there is an error when compiling a shader.
  9100. */
  9101. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9102. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9103. /**
  9104. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9105. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9106. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9107. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9108. * The gaps between physical kernels are compensated for in the weighting of the samples
  9109. * @param idealKernel Ideal blur kernel.
  9110. * @return Nearest best kernel.
  9111. */
  9112. protected _nearestBestKernel(idealKernel: number): number;
  9113. /**
  9114. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9115. * @param x The point on the Gaussian distribution to sample.
  9116. * @return the value of the Gaussian function at x.
  9117. */
  9118. protected _gaussianWeight(x: number): number;
  9119. /**
  9120. * Generates a string that can be used as a floating point number in GLSL.
  9121. * @param x Value to print.
  9122. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9123. * @return GLSL float string.
  9124. */
  9125. protected _glslFloat(x: number, decimalFigures?: number): string;
  9126. }
  9127. }
  9128. declare module BABYLON {
  9129. /** @hidden */
  9130. export var shadowMapPixelShader: {
  9131. name: string;
  9132. shader: string;
  9133. };
  9134. }
  9135. declare module BABYLON {
  9136. /** @hidden */
  9137. export var bonesDeclaration: {
  9138. name: string;
  9139. shader: string;
  9140. };
  9141. }
  9142. declare module BABYLON {
  9143. /** @hidden */
  9144. export var morphTargetsVertexGlobalDeclaration: {
  9145. name: string;
  9146. shader: string;
  9147. };
  9148. }
  9149. declare module BABYLON {
  9150. /** @hidden */
  9151. export var morphTargetsVertexDeclaration: {
  9152. name: string;
  9153. shader: string;
  9154. };
  9155. }
  9156. declare module BABYLON {
  9157. /** @hidden */
  9158. export var instancesDeclaration: {
  9159. name: string;
  9160. shader: string;
  9161. };
  9162. }
  9163. declare module BABYLON {
  9164. /** @hidden */
  9165. export var helperFunctions: {
  9166. name: string;
  9167. shader: string;
  9168. };
  9169. }
  9170. declare module BABYLON {
  9171. /** @hidden */
  9172. export var morphTargetsVertex: {
  9173. name: string;
  9174. shader: string;
  9175. };
  9176. }
  9177. declare module BABYLON {
  9178. /** @hidden */
  9179. export var instancesVertex: {
  9180. name: string;
  9181. shader: string;
  9182. };
  9183. }
  9184. declare module BABYLON {
  9185. /** @hidden */
  9186. export var bonesVertex: {
  9187. name: string;
  9188. shader: string;
  9189. };
  9190. }
  9191. declare module BABYLON {
  9192. /** @hidden */
  9193. export var shadowMapVertexShader: {
  9194. name: string;
  9195. shader: string;
  9196. };
  9197. }
  9198. declare module BABYLON {
  9199. /** @hidden */
  9200. export var depthBoxBlurPixelShader: {
  9201. name: string;
  9202. shader: string;
  9203. };
  9204. }
  9205. declare module BABYLON {
  9206. /**
  9207. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9208. */
  9209. export interface ICustomShaderOptions {
  9210. /**
  9211. * Gets or sets the custom shader name to use
  9212. */
  9213. shaderName: string;
  9214. /**
  9215. * The list of attribute names used in the shader
  9216. */
  9217. attributes?: string[];
  9218. /**
  9219. * The list of unifrom names used in the shader
  9220. */
  9221. uniforms?: string[];
  9222. /**
  9223. * The list of sampler names used in the shader
  9224. */
  9225. samplers?: string[];
  9226. /**
  9227. * The list of defines used in the shader
  9228. */
  9229. defines?: string[];
  9230. }
  9231. /**
  9232. * Interface to implement to create a shadow generator compatible with BJS.
  9233. */
  9234. export interface IShadowGenerator {
  9235. /**
  9236. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9237. * @returns The render target texture if present otherwise, null
  9238. */
  9239. getShadowMap(): Nullable<RenderTargetTexture>;
  9240. /**
  9241. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9242. * @returns The render target texture if the shadow map is present otherwise, null
  9243. */
  9244. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9245. /**
  9246. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9247. * @param subMesh The submesh we want to render in the shadow map
  9248. * @param useInstances Defines wether will draw in the map using instances
  9249. * @returns true if ready otherwise, false
  9250. */
  9251. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9252. /**
  9253. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9254. * @param defines Defines of the material we want to update
  9255. * @param lightIndex Index of the light in the enabled light list of the material
  9256. */
  9257. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9258. /**
  9259. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9260. * defined in the generator but impacting the effect).
  9261. * It implies the unifroms available on the materials are the standard BJS ones.
  9262. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9263. * @param effect The effect we are binfing the information for
  9264. */
  9265. bindShadowLight(lightIndex: string, effect: Effect): void;
  9266. /**
  9267. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9268. * (eq to shadow prjection matrix * light transform matrix)
  9269. * @returns The transform matrix used to create the shadow map
  9270. */
  9271. getTransformMatrix(): Matrix;
  9272. /**
  9273. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9274. * Cube and 2D textures for instance.
  9275. */
  9276. recreateShadowMap(): void;
  9277. /**
  9278. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9279. * @param onCompiled Callback triggered at the and of the effects compilation
  9280. * @param options Sets of optional options forcing the compilation with different modes
  9281. */
  9282. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9283. useInstances: boolean;
  9284. }>): void;
  9285. /**
  9286. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9287. * @param options Sets of optional options forcing the compilation with different modes
  9288. * @returns A promise that resolves when the compilation completes
  9289. */
  9290. forceCompilationAsync(options?: Partial<{
  9291. useInstances: boolean;
  9292. }>): Promise<void>;
  9293. /**
  9294. * Serializes the shadow generator setup to a json object.
  9295. * @returns The serialized JSON object
  9296. */
  9297. serialize(): any;
  9298. /**
  9299. * Disposes the Shadow map and related Textures and effects.
  9300. */
  9301. dispose(): void;
  9302. }
  9303. /**
  9304. * Default implementation IShadowGenerator.
  9305. * This is the main object responsible of generating shadows in the framework.
  9306. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9307. */
  9308. export class ShadowGenerator implements IShadowGenerator {
  9309. /**
  9310. * Shadow generator mode None: no filtering applied.
  9311. */
  9312. static readonly FILTER_NONE: number;
  9313. /**
  9314. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9315. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9316. */
  9317. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9318. /**
  9319. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9320. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9321. */
  9322. static readonly FILTER_POISSONSAMPLING: number;
  9323. /**
  9324. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9325. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9326. */
  9327. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9328. /**
  9329. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9330. * edge artifacts on steep falloff.
  9331. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9332. */
  9333. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9334. /**
  9335. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9336. * edge artifacts on steep falloff.
  9337. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9338. */
  9339. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9340. /**
  9341. * Shadow generator mode PCF: Percentage Closer Filtering
  9342. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9343. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9344. */
  9345. static readonly FILTER_PCF: number;
  9346. /**
  9347. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9348. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9349. * Contact Hardening
  9350. */
  9351. static readonly FILTER_PCSS: number;
  9352. /**
  9353. * Reserved for PCF and PCSS
  9354. * Highest Quality.
  9355. *
  9356. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9357. *
  9358. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9359. */
  9360. static readonly QUALITY_HIGH: number;
  9361. /**
  9362. * Reserved for PCF and PCSS
  9363. * Good tradeoff for quality/perf cross devices
  9364. *
  9365. * Execute PCF on a 3*3 kernel.
  9366. *
  9367. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9368. */
  9369. static readonly QUALITY_MEDIUM: number;
  9370. /**
  9371. * Reserved for PCF and PCSS
  9372. * The lowest quality but the fastest.
  9373. *
  9374. * Execute PCF on a 1*1 kernel.
  9375. *
  9376. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9377. */
  9378. static readonly QUALITY_LOW: number;
  9379. /** Gets or sets the custom shader name to use */
  9380. customShaderOptions: ICustomShaderOptions;
  9381. /**
  9382. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9383. */
  9384. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9385. private _bias;
  9386. /**
  9387. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9388. */
  9389. /**
  9390. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9391. */
  9392. bias: number;
  9393. private _normalBias;
  9394. /**
  9395. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9396. */
  9397. /**
  9398. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9399. */
  9400. normalBias: number;
  9401. private _blurBoxOffset;
  9402. /**
  9403. * Gets the blur box offset: offset applied during the blur pass.
  9404. * Only useful if useKernelBlur = false
  9405. */
  9406. /**
  9407. * Sets the blur box offset: offset applied during the blur pass.
  9408. * Only useful if useKernelBlur = false
  9409. */
  9410. blurBoxOffset: number;
  9411. private _blurScale;
  9412. /**
  9413. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9414. * 2 means half of the size.
  9415. */
  9416. /**
  9417. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9418. * 2 means half of the size.
  9419. */
  9420. blurScale: number;
  9421. private _blurKernel;
  9422. /**
  9423. * Gets the blur kernel: kernel size of the blur pass.
  9424. * Only useful if useKernelBlur = true
  9425. */
  9426. /**
  9427. * Sets the blur kernel: kernel size of the blur pass.
  9428. * Only useful if useKernelBlur = true
  9429. */
  9430. blurKernel: number;
  9431. private _useKernelBlur;
  9432. /**
  9433. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9434. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9435. */
  9436. /**
  9437. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9438. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9439. */
  9440. useKernelBlur: boolean;
  9441. private _depthScale;
  9442. /**
  9443. * Gets the depth scale used in ESM mode.
  9444. */
  9445. /**
  9446. * Sets the depth scale used in ESM mode.
  9447. * This can override the scale stored on the light.
  9448. */
  9449. depthScale: number;
  9450. private _filter;
  9451. /**
  9452. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9453. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9454. */
  9455. /**
  9456. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9457. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9458. */
  9459. filter: number;
  9460. /**
  9461. * Gets if the current filter is set to Poisson Sampling.
  9462. */
  9463. /**
  9464. * Sets the current filter to Poisson Sampling.
  9465. */
  9466. usePoissonSampling: boolean;
  9467. /**
  9468. * Gets if the current filter is set to ESM.
  9469. */
  9470. /**
  9471. * Sets the current filter is to ESM.
  9472. */
  9473. useExponentialShadowMap: boolean;
  9474. /**
  9475. * Gets if the current filter is set to filtered ESM.
  9476. */
  9477. /**
  9478. * Gets if the current filter is set to filtered ESM.
  9479. */
  9480. useBlurExponentialShadowMap: boolean;
  9481. /**
  9482. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9483. * exponential to prevent steep falloff artifacts).
  9484. */
  9485. /**
  9486. * Sets the current filter to "close ESM" (using the inverse of the
  9487. * exponential to prevent steep falloff artifacts).
  9488. */
  9489. useCloseExponentialShadowMap: boolean;
  9490. /**
  9491. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9492. * exponential to prevent steep falloff artifacts).
  9493. */
  9494. /**
  9495. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9496. * exponential to prevent steep falloff artifacts).
  9497. */
  9498. useBlurCloseExponentialShadowMap: boolean;
  9499. /**
  9500. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9501. */
  9502. /**
  9503. * Sets the current filter to "PCF" (percentage closer filtering).
  9504. */
  9505. usePercentageCloserFiltering: boolean;
  9506. private _filteringQuality;
  9507. /**
  9508. * Gets the PCF or PCSS Quality.
  9509. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9510. */
  9511. /**
  9512. * Sets the PCF or PCSS Quality.
  9513. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9514. */
  9515. filteringQuality: number;
  9516. /**
  9517. * Gets if the current filter is set to "PCSS" (contact hardening).
  9518. */
  9519. /**
  9520. * Sets the current filter to "PCSS" (contact hardening).
  9521. */
  9522. useContactHardeningShadow: boolean;
  9523. private _contactHardeningLightSizeUVRatio;
  9524. /**
  9525. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9526. * Using a ratio helps keeping shape stability independently of the map size.
  9527. *
  9528. * It does not account for the light projection as it was having too much
  9529. * instability during the light setup or during light position changes.
  9530. *
  9531. * Only valid if useContactHardeningShadow is true.
  9532. */
  9533. /**
  9534. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9535. * Using a ratio helps keeping shape stability independently of the map size.
  9536. *
  9537. * It does not account for the light projection as it was having too much
  9538. * instability during the light setup or during light position changes.
  9539. *
  9540. * Only valid if useContactHardeningShadow is true.
  9541. */
  9542. contactHardeningLightSizeUVRatio: number;
  9543. private _darkness;
  9544. /**
  9545. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9546. * 0 means strongest and 1 would means no shadow.
  9547. * @returns the darkness.
  9548. */
  9549. getDarkness(): number;
  9550. /**
  9551. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9552. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9553. * @returns the shadow generator allowing fluent coding.
  9554. */
  9555. setDarkness(darkness: number): ShadowGenerator;
  9556. private _transparencyShadow;
  9557. /**
  9558. * Sets the ability to have transparent shadow (boolean).
  9559. * @param transparent True if transparent else False
  9560. * @returns the shadow generator allowing fluent coding
  9561. */
  9562. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9563. private _shadowMap;
  9564. private _shadowMap2;
  9565. /**
  9566. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9567. * @returns The render target texture if present otherwise, null
  9568. */
  9569. getShadowMap(): Nullable<RenderTargetTexture>;
  9570. /**
  9571. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9572. * @returns The render target texture if the shadow map is present otherwise, null
  9573. */
  9574. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9575. /**
  9576. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9577. * @param mesh Mesh to add
  9578. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9579. * @returns the Shadow Generator itself
  9580. */
  9581. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9582. /**
  9583. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9584. * @param mesh Mesh to remove
  9585. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9586. * @returns the Shadow Generator itself
  9587. */
  9588. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9589. /**
  9590. * Controls the extent to which the shadows fade out at the edge of the frustum
  9591. * Used only by directionals and spots
  9592. */
  9593. frustumEdgeFalloff: number;
  9594. private _light;
  9595. /**
  9596. * Returns the associated light object.
  9597. * @returns the light generating the shadow
  9598. */
  9599. getLight(): IShadowLight;
  9600. /**
  9601. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9602. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9603. * It might on the other hand introduce peter panning.
  9604. */
  9605. forceBackFacesOnly: boolean;
  9606. private _scene;
  9607. private _lightDirection;
  9608. private _effect;
  9609. private _viewMatrix;
  9610. private _projectionMatrix;
  9611. private _transformMatrix;
  9612. private _cachedPosition;
  9613. private _cachedDirection;
  9614. private _cachedDefines;
  9615. private _currentRenderID;
  9616. private _boxBlurPostprocess;
  9617. private _kernelBlurXPostprocess;
  9618. private _kernelBlurYPostprocess;
  9619. private _blurPostProcesses;
  9620. private _mapSize;
  9621. private _currentFaceIndex;
  9622. private _currentFaceIndexCache;
  9623. private _textureType;
  9624. private _defaultTextureMatrix;
  9625. /** @hidden */
  9626. static _SceneComponentInitialization: (scene: Scene) => void;
  9627. /**
  9628. * Creates a ShadowGenerator object.
  9629. * A ShadowGenerator is the required tool to use the shadows.
  9630. * Each light casting shadows needs to use its own ShadowGenerator.
  9631. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9632. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9633. * @param light The light object generating the shadows.
  9634. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9635. */
  9636. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9637. private _initializeGenerator;
  9638. private _initializeShadowMap;
  9639. private _initializeBlurRTTAndPostProcesses;
  9640. private _renderForShadowMap;
  9641. private _renderSubMeshForShadowMap;
  9642. private _applyFilterValues;
  9643. /**
  9644. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9645. * @param onCompiled Callback triggered at the and of the effects compilation
  9646. * @param options Sets of optional options forcing the compilation with different modes
  9647. */
  9648. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9649. useInstances: boolean;
  9650. }>): void;
  9651. /**
  9652. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9653. * @param options Sets of optional options forcing the compilation with different modes
  9654. * @returns A promise that resolves when the compilation completes
  9655. */
  9656. forceCompilationAsync(options?: Partial<{
  9657. useInstances: boolean;
  9658. }>): Promise<void>;
  9659. /**
  9660. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9661. * @param subMesh The submesh we want to render in the shadow map
  9662. * @param useInstances Defines wether will draw in the map using instances
  9663. * @returns true if ready otherwise, false
  9664. */
  9665. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9666. /**
  9667. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9668. * @param defines Defines of the material we want to update
  9669. * @param lightIndex Index of the light in the enabled light list of the material
  9670. */
  9671. prepareDefines(defines: any, lightIndex: number): void;
  9672. /**
  9673. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9674. * defined in the generator but impacting the effect).
  9675. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9676. * @param effect The effect we are binfing the information for
  9677. */
  9678. bindShadowLight(lightIndex: string, effect: Effect): void;
  9679. /**
  9680. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9681. * (eq to shadow prjection matrix * light transform matrix)
  9682. * @returns The transform matrix used to create the shadow map
  9683. */
  9684. getTransformMatrix(): Matrix;
  9685. /**
  9686. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9687. * Cube and 2D textures for instance.
  9688. */
  9689. recreateShadowMap(): void;
  9690. private _disposeBlurPostProcesses;
  9691. private _disposeRTTandPostProcesses;
  9692. /**
  9693. * Disposes the ShadowGenerator.
  9694. * Returns nothing.
  9695. */
  9696. dispose(): void;
  9697. /**
  9698. * Serializes the shadow generator setup to a json object.
  9699. * @returns The serialized JSON object
  9700. */
  9701. serialize(): any;
  9702. /**
  9703. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9704. * @param parsedShadowGenerator The JSON object to parse
  9705. * @param scene The scene to create the shadow map for
  9706. * @returns The parsed shadow generator
  9707. */
  9708. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9709. }
  9710. }
  9711. declare module BABYLON {
  9712. /**
  9713. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9714. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9715. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9716. */
  9717. export abstract class Light extends Node {
  9718. /**
  9719. * Falloff Default: light is falling off following the material specification:
  9720. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9721. */
  9722. static readonly FALLOFF_DEFAULT: number;
  9723. /**
  9724. * Falloff Physical: light is falling off following the inverse squared distance law.
  9725. */
  9726. static readonly FALLOFF_PHYSICAL: number;
  9727. /**
  9728. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9729. * to enhance interoperability with other engines.
  9730. */
  9731. static readonly FALLOFF_GLTF: number;
  9732. /**
  9733. * Falloff Standard: light is falling off like in the standard material
  9734. * to enhance interoperability with other materials.
  9735. */
  9736. static readonly FALLOFF_STANDARD: number;
  9737. /**
  9738. * If every light affecting the material is in this lightmapMode,
  9739. * material.lightmapTexture adds or multiplies
  9740. * (depends on material.useLightmapAsShadowmap)
  9741. * after every other light calculations.
  9742. */
  9743. static readonly LIGHTMAP_DEFAULT: number;
  9744. /**
  9745. * material.lightmapTexture as only diffuse lighting from this light
  9746. * adds only specular lighting from this light
  9747. * adds dynamic shadows
  9748. */
  9749. static readonly LIGHTMAP_SPECULAR: number;
  9750. /**
  9751. * material.lightmapTexture as only lighting
  9752. * no light calculation from this light
  9753. * only adds dynamic shadows from this light
  9754. */
  9755. static readonly LIGHTMAP_SHADOWSONLY: number;
  9756. /**
  9757. * Each light type uses the default quantity according to its type:
  9758. * point/spot lights use luminous intensity
  9759. * directional lights use illuminance
  9760. */
  9761. static readonly INTENSITYMODE_AUTOMATIC: number;
  9762. /**
  9763. * lumen (lm)
  9764. */
  9765. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9766. /**
  9767. * candela (lm/sr)
  9768. */
  9769. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9770. /**
  9771. * lux (lm/m^2)
  9772. */
  9773. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9774. /**
  9775. * nit (cd/m^2)
  9776. */
  9777. static readonly INTENSITYMODE_LUMINANCE: number;
  9778. /**
  9779. * Light type const id of the point light.
  9780. */
  9781. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9782. /**
  9783. * Light type const id of the directional light.
  9784. */
  9785. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9786. /**
  9787. * Light type const id of the spot light.
  9788. */
  9789. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9790. /**
  9791. * Light type const id of the hemispheric light.
  9792. */
  9793. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9794. /**
  9795. * Diffuse gives the basic color to an object.
  9796. */
  9797. diffuse: Color3;
  9798. /**
  9799. * Specular produces a highlight color on an object.
  9800. * Note: This is note affecting PBR materials.
  9801. */
  9802. specular: Color3;
  9803. /**
  9804. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9805. * falling off base on range or angle.
  9806. * This can be set to any values in Light.FALLOFF_x.
  9807. *
  9808. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9809. * other types of materials.
  9810. */
  9811. falloffType: number;
  9812. /**
  9813. * Strength of the light.
  9814. * Note: By default it is define in the framework own unit.
  9815. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9816. */
  9817. intensity: number;
  9818. private _range;
  9819. protected _inverseSquaredRange: number;
  9820. /**
  9821. * Defines how far from the source the light is impacting in scene units.
  9822. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9823. */
  9824. /**
  9825. * Defines how far from the source the light is impacting in scene units.
  9826. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9827. */
  9828. range: number;
  9829. /**
  9830. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9831. * of light.
  9832. */
  9833. private _photometricScale;
  9834. private _intensityMode;
  9835. /**
  9836. * Gets the photometric scale used to interpret the intensity.
  9837. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9838. */
  9839. /**
  9840. * Sets the photometric scale used to interpret the intensity.
  9841. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9842. */
  9843. intensityMode: number;
  9844. private _radius;
  9845. /**
  9846. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9847. */
  9848. /**
  9849. * sets the light radius used by PBR Materials to simulate soft area lights.
  9850. */
  9851. radius: number;
  9852. private _renderPriority;
  9853. /**
  9854. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9855. * exceeding the number allowed of the materials.
  9856. */
  9857. renderPriority: number;
  9858. private _shadowEnabled;
  9859. /**
  9860. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9861. * the current shadow generator.
  9862. */
  9863. /**
  9864. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9865. * the current shadow generator.
  9866. */
  9867. shadowEnabled: boolean;
  9868. private _includedOnlyMeshes;
  9869. /**
  9870. * Gets the only meshes impacted by this light.
  9871. */
  9872. /**
  9873. * Sets the only meshes impacted by this light.
  9874. */
  9875. includedOnlyMeshes: AbstractMesh[];
  9876. private _excludedMeshes;
  9877. /**
  9878. * Gets the meshes not impacted by this light.
  9879. */
  9880. /**
  9881. * Sets the meshes not impacted by this light.
  9882. */
  9883. excludedMeshes: AbstractMesh[];
  9884. private _excludeWithLayerMask;
  9885. /**
  9886. * Gets the layer id use to find what meshes are not impacted by the light.
  9887. * Inactive if 0
  9888. */
  9889. /**
  9890. * Sets the layer id use to find what meshes are not impacted by the light.
  9891. * Inactive if 0
  9892. */
  9893. excludeWithLayerMask: number;
  9894. private _includeOnlyWithLayerMask;
  9895. /**
  9896. * Gets the layer id use to find what meshes are impacted by the light.
  9897. * Inactive if 0
  9898. */
  9899. /**
  9900. * Sets the layer id use to find what meshes are impacted by the light.
  9901. * Inactive if 0
  9902. */
  9903. includeOnlyWithLayerMask: number;
  9904. private _lightmapMode;
  9905. /**
  9906. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9907. */
  9908. /**
  9909. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9910. */
  9911. lightmapMode: number;
  9912. /**
  9913. * Shadow generator associted to the light.
  9914. * @hidden Internal use only.
  9915. */
  9916. _shadowGenerator: Nullable<IShadowGenerator>;
  9917. /**
  9918. * @hidden Internal use only.
  9919. */
  9920. _excludedMeshesIds: string[];
  9921. /**
  9922. * @hidden Internal use only.
  9923. */
  9924. _includedOnlyMeshesIds: string[];
  9925. /**
  9926. * The current light unifom buffer.
  9927. * @hidden Internal use only.
  9928. */
  9929. _uniformBuffer: UniformBuffer;
  9930. /**
  9931. * Creates a Light object in the scene.
  9932. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9933. * @param name The firendly name of the light
  9934. * @param scene The scene the light belongs too
  9935. */
  9936. constructor(name: string, scene: Scene);
  9937. protected abstract _buildUniformLayout(): void;
  9938. /**
  9939. * Sets the passed Effect "effect" with the Light information.
  9940. * @param effect The effect to update
  9941. * @param lightIndex The index of the light in the effect to update
  9942. * @returns The light
  9943. */
  9944. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9945. /**
  9946. * Returns the string "Light".
  9947. * @returns the class name
  9948. */
  9949. getClassName(): string;
  9950. /** @hidden */
  9951. readonly _isLight: boolean;
  9952. /**
  9953. * Converts the light information to a readable string for debug purpose.
  9954. * @param fullDetails Supports for multiple levels of logging within scene loading
  9955. * @returns the human readable light info
  9956. */
  9957. toString(fullDetails?: boolean): string;
  9958. /** @hidden */
  9959. protected _syncParentEnabledState(): void;
  9960. /**
  9961. * Set the enabled state of this node.
  9962. * @param value - the new enabled state
  9963. */
  9964. setEnabled(value: boolean): void;
  9965. /**
  9966. * Returns the Light associated shadow generator if any.
  9967. * @return the associated shadow generator.
  9968. */
  9969. getShadowGenerator(): Nullable<IShadowGenerator>;
  9970. /**
  9971. * Returns a Vector3, the absolute light position in the World.
  9972. * @returns the world space position of the light
  9973. */
  9974. getAbsolutePosition(): Vector3;
  9975. /**
  9976. * Specifies if the light will affect the passed mesh.
  9977. * @param mesh The mesh to test against the light
  9978. * @return true the mesh is affected otherwise, false.
  9979. */
  9980. canAffectMesh(mesh: AbstractMesh): boolean;
  9981. /**
  9982. * Sort function to order lights for rendering.
  9983. * @param a First Light object to compare to second.
  9984. * @param b Second Light object to compare first.
  9985. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9986. */
  9987. static CompareLightsPriority(a: Light, b: Light): number;
  9988. /**
  9989. * Releases resources associated with this node.
  9990. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9991. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9992. */
  9993. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9994. /**
  9995. * Returns the light type ID (integer).
  9996. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9997. */
  9998. getTypeID(): number;
  9999. /**
  10000. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10001. * @returns the scaled intensity in intensity mode unit
  10002. */
  10003. getScaledIntensity(): number;
  10004. /**
  10005. * Returns a new Light object, named "name", from the current one.
  10006. * @param name The name of the cloned light
  10007. * @returns the new created light
  10008. */
  10009. clone(name: string): Nullable<Light>;
  10010. /**
  10011. * Serializes the current light into a Serialization object.
  10012. * @returns the serialized object.
  10013. */
  10014. serialize(): any;
  10015. /**
  10016. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10017. * This new light is named "name" and added to the passed scene.
  10018. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10019. * @param name The friendly name of the light
  10020. * @param scene The scene the new light will belong to
  10021. * @returns the constructor function
  10022. */
  10023. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10024. /**
  10025. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10026. * @param parsedLight The JSON representation of the light
  10027. * @param scene The scene to create the parsed light in
  10028. * @returns the created light after parsing
  10029. */
  10030. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10031. private _hookArrayForExcluded;
  10032. private _hookArrayForIncludedOnly;
  10033. private _resyncMeshes;
  10034. /**
  10035. * Forces the meshes to update their light related information in their rendering used effects
  10036. * @hidden Internal Use Only
  10037. */
  10038. _markMeshesAsLightDirty(): void;
  10039. /**
  10040. * Recomputes the cached photometric scale if needed.
  10041. */
  10042. private _computePhotometricScale;
  10043. /**
  10044. * Returns the Photometric Scale according to the light type and intensity mode.
  10045. */
  10046. private _getPhotometricScale;
  10047. /**
  10048. * Reorder the light in the scene according to their defined priority.
  10049. * @hidden Internal Use Only
  10050. */
  10051. _reorderLightsInScene(): void;
  10052. /**
  10053. * Prepares the list of defines specific to the light type.
  10054. * @param defines the list of defines
  10055. * @param lightIndex defines the index of the light for the effect
  10056. */
  10057. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10058. }
  10059. }
  10060. declare module BABYLON {
  10061. /**
  10062. * Interface used to define Action
  10063. */
  10064. export interface IAction {
  10065. /**
  10066. * Trigger for the action
  10067. */
  10068. trigger: number;
  10069. /** the trigger, with or without parameters, for the action */
  10070. triggerOptions: any;
  10071. /**
  10072. * Gets the trigger parameters
  10073. * @returns the trigger parameters
  10074. */
  10075. getTriggerParameter(): any;
  10076. /**
  10077. * Internal only - executes current action event
  10078. * @hidden
  10079. */
  10080. _executeCurrent(evt?: ActionEvent): void;
  10081. /**
  10082. * Serialize placeholder for child classes
  10083. * @param parent of child
  10084. * @returns the serialized object
  10085. */
  10086. serialize(parent: any): any;
  10087. }
  10088. /**
  10089. * The action to be carried out following a trigger
  10090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10091. */
  10092. export class Action implements IAction {
  10093. /** the trigger, with or without parameters, for the action */
  10094. triggerOptions: any;
  10095. /**
  10096. * Trigger for the action
  10097. */
  10098. trigger: number;
  10099. /**
  10100. * Internal only - manager for action
  10101. * @hidden
  10102. */
  10103. _actionManager: ActionManager;
  10104. private _nextActiveAction;
  10105. private _child;
  10106. private _condition?;
  10107. private _triggerParameter;
  10108. /**
  10109. * An event triggered prior to action being executed.
  10110. */
  10111. onBeforeExecuteObservable: Observable<Action>;
  10112. /**
  10113. * Creates a new Action
  10114. * @param triggerOptions the trigger, with or without parameters, for the action
  10115. * @param condition an optional determinant of action
  10116. */
  10117. constructor(
  10118. /** the trigger, with or without parameters, for the action */
  10119. triggerOptions: any, condition?: Condition);
  10120. /**
  10121. * Internal only
  10122. * @hidden
  10123. */
  10124. _prepare(): void;
  10125. /**
  10126. * Gets the trigger parameters
  10127. * @returns the trigger parameters
  10128. */
  10129. getTriggerParameter(): any;
  10130. /**
  10131. * Internal only - executes current action event
  10132. * @hidden
  10133. */
  10134. _executeCurrent(evt?: ActionEvent): void;
  10135. /**
  10136. * Execute placeholder for child classes
  10137. * @param evt optional action event
  10138. */
  10139. execute(evt?: ActionEvent): void;
  10140. /**
  10141. * Skips to next active action
  10142. */
  10143. skipToNextActiveAction(): void;
  10144. /**
  10145. * Adds action to chain of actions, may be a DoNothingAction
  10146. * @param action defines the next action to execute
  10147. * @returns The action passed in
  10148. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10149. */
  10150. then(action: Action): Action;
  10151. /**
  10152. * Internal only
  10153. * @hidden
  10154. */
  10155. _getProperty(propertyPath: string): string;
  10156. /**
  10157. * Internal only
  10158. * @hidden
  10159. */
  10160. _getEffectiveTarget(target: any, propertyPath: string): any;
  10161. /**
  10162. * Serialize placeholder for child classes
  10163. * @param parent of child
  10164. * @returns the serialized object
  10165. */
  10166. serialize(parent: any): any;
  10167. /**
  10168. * Internal only called by serialize
  10169. * @hidden
  10170. */
  10171. protected _serialize(serializedAction: any, parent?: any): any;
  10172. /**
  10173. * Internal only
  10174. * @hidden
  10175. */
  10176. static _SerializeValueAsString: (value: any) => string;
  10177. /**
  10178. * Internal only
  10179. * @hidden
  10180. */
  10181. static _GetTargetProperty: (target: Scene | Node) => {
  10182. name: string;
  10183. targetType: string;
  10184. value: string;
  10185. };
  10186. }
  10187. }
  10188. declare module BABYLON {
  10189. /**
  10190. * A Condition applied to an Action
  10191. */
  10192. export class Condition {
  10193. /**
  10194. * Internal only - manager for action
  10195. * @hidden
  10196. */
  10197. _actionManager: ActionManager;
  10198. /**
  10199. * Internal only
  10200. * @hidden
  10201. */
  10202. _evaluationId: number;
  10203. /**
  10204. * Internal only
  10205. * @hidden
  10206. */
  10207. _currentResult: boolean;
  10208. /**
  10209. * Creates a new Condition
  10210. * @param actionManager the manager of the action the condition is applied to
  10211. */
  10212. constructor(actionManager: ActionManager);
  10213. /**
  10214. * Check if the current condition is valid
  10215. * @returns a boolean
  10216. */
  10217. isValid(): boolean;
  10218. /**
  10219. * Internal only
  10220. * @hidden
  10221. */
  10222. _getProperty(propertyPath: string): string;
  10223. /**
  10224. * Internal only
  10225. * @hidden
  10226. */
  10227. _getEffectiveTarget(target: any, propertyPath: string): any;
  10228. /**
  10229. * Serialize placeholder for child classes
  10230. * @returns the serialized object
  10231. */
  10232. serialize(): any;
  10233. /**
  10234. * Internal only
  10235. * @hidden
  10236. */
  10237. protected _serialize(serializedCondition: any): any;
  10238. }
  10239. /**
  10240. * Defines specific conditional operators as extensions of Condition
  10241. */
  10242. export class ValueCondition extends Condition {
  10243. /** path to specify the property of the target the conditional operator uses */
  10244. propertyPath: string;
  10245. /** the value compared by the conditional operator against the current value of the property */
  10246. value: any;
  10247. /** the conditional operator, default ValueCondition.IsEqual */
  10248. operator: number;
  10249. /**
  10250. * Internal only
  10251. * @hidden
  10252. */
  10253. private static _IsEqual;
  10254. /**
  10255. * Internal only
  10256. * @hidden
  10257. */
  10258. private static _IsDifferent;
  10259. /**
  10260. * Internal only
  10261. * @hidden
  10262. */
  10263. private static _IsGreater;
  10264. /**
  10265. * Internal only
  10266. * @hidden
  10267. */
  10268. private static _IsLesser;
  10269. /**
  10270. * returns the number for IsEqual
  10271. */
  10272. static readonly IsEqual: number;
  10273. /**
  10274. * Returns the number for IsDifferent
  10275. */
  10276. static readonly IsDifferent: number;
  10277. /**
  10278. * Returns the number for IsGreater
  10279. */
  10280. static readonly IsGreater: number;
  10281. /**
  10282. * Returns the number for IsLesser
  10283. */
  10284. static readonly IsLesser: number;
  10285. /**
  10286. * Internal only The action manager for the condition
  10287. * @hidden
  10288. */
  10289. _actionManager: ActionManager;
  10290. /**
  10291. * Internal only
  10292. * @hidden
  10293. */
  10294. private _target;
  10295. /**
  10296. * Internal only
  10297. * @hidden
  10298. */
  10299. private _effectiveTarget;
  10300. /**
  10301. * Internal only
  10302. * @hidden
  10303. */
  10304. private _property;
  10305. /**
  10306. * Creates a new ValueCondition
  10307. * @param actionManager manager for the action the condition applies to
  10308. * @param target for the action
  10309. * @param propertyPath path to specify the property of the target the conditional operator uses
  10310. * @param value the value compared by the conditional operator against the current value of the property
  10311. * @param operator the conditional operator, default ValueCondition.IsEqual
  10312. */
  10313. constructor(actionManager: ActionManager, target: any,
  10314. /** path to specify the property of the target the conditional operator uses */
  10315. propertyPath: string,
  10316. /** the value compared by the conditional operator against the current value of the property */
  10317. value: any,
  10318. /** the conditional operator, default ValueCondition.IsEqual */
  10319. operator?: number);
  10320. /**
  10321. * Compares the given value with the property value for the specified conditional operator
  10322. * @returns the result of the comparison
  10323. */
  10324. isValid(): boolean;
  10325. /**
  10326. * Serialize the ValueCondition into a JSON compatible object
  10327. * @returns serialization object
  10328. */
  10329. serialize(): any;
  10330. /**
  10331. * Gets the name of the conditional operator for the ValueCondition
  10332. * @param operator the conditional operator
  10333. * @returns the name
  10334. */
  10335. static GetOperatorName(operator: number): string;
  10336. }
  10337. /**
  10338. * Defines a predicate condition as an extension of Condition
  10339. */
  10340. export class PredicateCondition extends Condition {
  10341. /** defines the predicate function used to validate the condition */
  10342. predicate: () => boolean;
  10343. /**
  10344. * Internal only - manager for action
  10345. * @hidden
  10346. */
  10347. _actionManager: ActionManager;
  10348. /**
  10349. * Creates a new PredicateCondition
  10350. * @param actionManager manager for the action the condition applies to
  10351. * @param predicate defines the predicate function used to validate the condition
  10352. */
  10353. constructor(actionManager: ActionManager,
  10354. /** defines the predicate function used to validate the condition */
  10355. predicate: () => boolean);
  10356. /**
  10357. * @returns the validity of the predicate condition
  10358. */
  10359. isValid(): boolean;
  10360. }
  10361. /**
  10362. * Defines a state condition as an extension of Condition
  10363. */
  10364. export class StateCondition extends Condition {
  10365. /** Value to compare with target state */
  10366. value: string;
  10367. /**
  10368. * Internal only - manager for action
  10369. * @hidden
  10370. */
  10371. _actionManager: ActionManager;
  10372. /**
  10373. * Internal only
  10374. * @hidden
  10375. */
  10376. private _target;
  10377. /**
  10378. * Creates a new StateCondition
  10379. * @param actionManager manager for the action the condition applies to
  10380. * @param target of the condition
  10381. * @param value to compare with target state
  10382. */
  10383. constructor(actionManager: ActionManager, target: any,
  10384. /** Value to compare with target state */
  10385. value: string);
  10386. /**
  10387. * Gets a boolean indicating if the current condition is met
  10388. * @returns the validity of the state
  10389. */
  10390. isValid(): boolean;
  10391. /**
  10392. * Serialize the StateCondition into a JSON compatible object
  10393. * @returns serialization object
  10394. */
  10395. serialize(): any;
  10396. }
  10397. }
  10398. declare module BABYLON {
  10399. /**
  10400. * This defines an action responsible to toggle a boolean once triggered.
  10401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10402. */
  10403. export class SwitchBooleanAction extends Action {
  10404. /**
  10405. * The path to the boolean property in the target object
  10406. */
  10407. propertyPath: string;
  10408. private _target;
  10409. private _effectiveTarget;
  10410. private _property;
  10411. /**
  10412. * Instantiate the action
  10413. * @param triggerOptions defines the trigger options
  10414. * @param target defines the object containing the boolean
  10415. * @param propertyPath defines the path to the boolean property in the target object
  10416. * @param condition defines the trigger related conditions
  10417. */
  10418. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10419. /** @hidden */
  10420. _prepare(): void;
  10421. /**
  10422. * Execute the action toggle the boolean value.
  10423. */
  10424. execute(): void;
  10425. /**
  10426. * Serializes the actions and its related information.
  10427. * @param parent defines the object to serialize in
  10428. * @returns the serialized object
  10429. */
  10430. serialize(parent: any): any;
  10431. }
  10432. /**
  10433. * This defines an action responsible to set a the state field of the target
  10434. * to a desired value once triggered.
  10435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10436. */
  10437. export class SetStateAction extends Action {
  10438. /**
  10439. * The value to store in the state field.
  10440. */
  10441. value: string;
  10442. private _target;
  10443. /**
  10444. * Instantiate the action
  10445. * @param triggerOptions defines the trigger options
  10446. * @param target defines the object containing the state property
  10447. * @param value defines the value to store in the state field
  10448. * @param condition defines the trigger related conditions
  10449. */
  10450. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10451. /**
  10452. * Execute the action and store the value on the target state property.
  10453. */
  10454. execute(): void;
  10455. /**
  10456. * Serializes the actions and its related information.
  10457. * @param parent defines the object to serialize in
  10458. * @returns the serialized object
  10459. */
  10460. serialize(parent: any): any;
  10461. }
  10462. /**
  10463. * This defines an action responsible to set a property of the target
  10464. * to a desired value once triggered.
  10465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10466. */
  10467. export class SetValueAction extends Action {
  10468. /**
  10469. * The path of the property to set in the target.
  10470. */
  10471. propertyPath: string;
  10472. /**
  10473. * The value to set in the property
  10474. */
  10475. value: any;
  10476. private _target;
  10477. private _effectiveTarget;
  10478. private _property;
  10479. /**
  10480. * Instantiate the action
  10481. * @param triggerOptions defines the trigger options
  10482. * @param target defines the object containing the property
  10483. * @param propertyPath defines the path of the property to set in the target
  10484. * @param value defines the value to set in the property
  10485. * @param condition defines the trigger related conditions
  10486. */
  10487. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10488. /** @hidden */
  10489. _prepare(): void;
  10490. /**
  10491. * Execute the action and set the targetted property to the desired value.
  10492. */
  10493. execute(): void;
  10494. /**
  10495. * Serializes the actions and its related information.
  10496. * @param parent defines the object to serialize in
  10497. * @returns the serialized object
  10498. */
  10499. serialize(parent: any): any;
  10500. }
  10501. /**
  10502. * This defines an action responsible to increment the target value
  10503. * to a desired value once triggered.
  10504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10505. */
  10506. export class IncrementValueAction extends Action {
  10507. /**
  10508. * The path of the property to increment in the target.
  10509. */
  10510. propertyPath: string;
  10511. /**
  10512. * The value we should increment the property by.
  10513. */
  10514. value: any;
  10515. private _target;
  10516. private _effectiveTarget;
  10517. private _property;
  10518. /**
  10519. * Instantiate the action
  10520. * @param triggerOptions defines the trigger options
  10521. * @param target defines the object containing the property
  10522. * @param propertyPath defines the path of the property to increment in the target
  10523. * @param value defines the value value we should increment the property by
  10524. * @param condition defines the trigger related conditions
  10525. */
  10526. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10527. /** @hidden */
  10528. _prepare(): void;
  10529. /**
  10530. * Execute the action and increment the target of the value amount.
  10531. */
  10532. execute(): void;
  10533. /**
  10534. * Serializes the actions and its related information.
  10535. * @param parent defines the object to serialize in
  10536. * @returns the serialized object
  10537. */
  10538. serialize(parent: any): any;
  10539. }
  10540. /**
  10541. * This defines an action responsible to start an animation once triggered.
  10542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10543. */
  10544. export class PlayAnimationAction extends Action {
  10545. /**
  10546. * Where the animation should start (animation frame)
  10547. */
  10548. from: number;
  10549. /**
  10550. * Where the animation should stop (animation frame)
  10551. */
  10552. to: number;
  10553. /**
  10554. * Define if the animation should loop or stop after the first play.
  10555. */
  10556. loop?: boolean;
  10557. private _target;
  10558. /**
  10559. * Instantiate the action
  10560. * @param triggerOptions defines the trigger options
  10561. * @param target defines the target animation or animation name
  10562. * @param from defines from where the animation should start (animation frame)
  10563. * @param end defines where the animation should stop (animation frame)
  10564. * @param loop defines if the animation should loop or stop after the first play
  10565. * @param condition defines the trigger related conditions
  10566. */
  10567. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10568. /** @hidden */
  10569. _prepare(): void;
  10570. /**
  10571. * Execute the action and play the animation.
  10572. */
  10573. execute(): void;
  10574. /**
  10575. * Serializes the actions and its related information.
  10576. * @param parent defines the object to serialize in
  10577. * @returns the serialized object
  10578. */
  10579. serialize(parent: any): any;
  10580. }
  10581. /**
  10582. * This defines an action responsible to stop an animation once triggered.
  10583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10584. */
  10585. export class StopAnimationAction extends Action {
  10586. private _target;
  10587. /**
  10588. * Instantiate the action
  10589. * @param triggerOptions defines the trigger options
  10590. * @param target defines the target animation or animation name
  10591. * @param condition defines the trigger related conditions
  10592. */
  10593. constructor(triggerOptions: any, target: any, condition?: Condition);
  10594. /** @hidden */
  10595. _prepare(): void;
  10596. /**
  10597. * Execute the action and stop the animation.
  10598. */
  10599. execute(): void;
  10600. /**
  10601. * Serializes the actions and its related information.
  10602. * @param parent defines the object to serialize in
  10603. * @returns the serialized object
  10604. */
  10605. serialize(parent: any): any;
  10606. }
  10607. /**
  10608. * This defines an action responsible that does nothing once triggered.
  10609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10610. */
  10611. export class DoNothingAction extends Action {
  10612. /**
  10613. * Instantiate the action
  10614. * @param triggerOptions defines the trigger options
  10615. * @param condition defines the trigger related conditions
  10616. */
  10617. constructor(triggerOptions?: any, condition?: Condition);
  10618. /**
  10619. * Execute the action and do nothing.
  10620. */
  10621. execute(): void;
  10622. /**
  10623. * Serializes the actions and its related information.
  10624. * @param parent defines the object to serialize in
  10625. * @returns the serialized object
  10626. */
  10627. serialize(parent: any): any;
  10628. }
  10629. /**
  10630. * This defines an action responsible to trigger several actions once triggered.
  10631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10632. */
  10633. export class CombineAction extends Action {
  10634. /**
  10635. * The list of aggregated animations to run.
  10636. */
  10637. children: Action[];
  10638. /**
  10639. * Instantiate the action
  10640. * @param triggerOptions defines the trigger options
  10641. * @param children defines the list of aggregated animations to run
  10642. * @param condition defines the trigger related conditions
  10643. */
  10644. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10645. /** @hidden */
  10646. _prepare(): void;
  10647. /**
  10648. * Execute the action and executes all the aggregated actions.
  10649. */
  10650. execute(evt: ActionEvent): void;
  10651. /**
  10652. * Serializes the actions and its related information.
  10653. * @param parent defines the object to serialize in
  10654. * @returns the serialized object
  10655. */
  10656. serialize(parent: any): any;
  10657. }
  10658. /**
  10659. * This defines an action responsible to run code (external event) once triggered.
  10660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10661. */
  10662. export class ExecuteCodeAction extends Action {
  10663. /**
  10664. * The callback function to run.
  10665. */
  10666. func: (evt: ActionEvent) => void;
  10667. /**
  10668. * Instantiate the action
  10669. * @param triggerOptions defines the trigger options
  10670. * @param func defines the callback function to run
  10671. * @param condition defines the trigger related conditions
  10672. */
  10673. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10674. /**
  10675. * Execute the action and run the attached code.
  10676. */
  10677. execute(evt: ActionEvent): void;
  10678. }
  10679. /**
  10680. * This defines an action responsible to set the parent property of the target once triggered.
  10681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10682. */
  10683. export class SetParentAction extends Action {
  10684. private _parent;
  10685. private _target;
  10686. /**
  10687. * Instantiate the action
  10688. * @param triggerOptions defines the trigger options
  10689. * @param target defines the target containing the parent property
  10690. * @param parent defines from where the animation should start (animation frame)
  10691. * @param condition defines the trigger related conditions
  10692. */
  10693. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10694. /** @hidden */
  10695. _prepare(): void;
  10696. /**
  10697. * Execute the action and set the parent property.
  10698. */
  10699. execute(): void;
  10700. /**
  10701. * Serializes the actions and its related information.
  10702. * @param parent defines the object to serialize in
  10703. * @returns the serialized object
  10704. */
  10705. serialize(parent: any): any;
  10706. }
  10707. }
  10708. declare module BABYLON {
  10709. /**
  10710. * Abstract class used to decouple action Manager from scene and meshes.
  10711. * Do not instantiate.
  10712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10713. */
  10714. export abstract class AbstractActionManager implements IDisposable {
  10715. /** Gets the list of active triggers */
  10716. static Triggers: {
  10717. [key: string]: number;
  10718. };
  10719. /** Gets the cursor to use when hovering items */
  10720. hoverCursor: string;
  10721. /** Gets the list of actions */
  10722. actions: IAction[];
  10723. /**
  10724. * Releases all associated resources
  10725. */
  10726. abstract dispose(): void;
  10727. /**
  10728. * Does this action manager has pointer triggers
  10729. */
  10730. abstract readonly hasPointerTriggers: boolean;
  10731. /**
  10732. * Does this action manager has pick triggers
  10733. */
  10734. abstract readonly hasPickTriggers: boolean;
  10735. /**
  10736. * Process a specific trigger
  10737. * @param trigger defines the trigger to process
  10738. * @param evt defines the event details to be processed
  10739. */
  10740. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  10741. /**
  10742. * Does this action manager handles actions of any of the given triggers
  10743. * @param triggers defines the triggers to be tested
  10744. * @return a boolean indicating whether one (or more) of the triggers is handled
  10745. */
  10746. abstract hasSpecificTriggers(triggers: number[]): boolean;
  10747. /**
  10748. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10749. * speed.
  10750. * @param triggerA defines the trigger to be tested
  10751. * @param triggerB defines the trigger to be tested
  10752. * @return a boolean indicating whether one (or more) of the triggers is handled
  10753. */
  10754. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10755. /**
  10756. * Does this action manager handles actions of a given trigger
  10757. * @param trigger defines the trigger to be tested
  10758. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10759. * @return whether the trigger is handled
  10760. */
  10761. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10762. /**
  10763. * Serialize this manager to a JSON object
  10764. * @param name defines the property name to store this manager
  10765. * @returns a JSON representation of this manager
  10766. */
  10767. abstract serialize(name: string): any;
  10768. /**
  10769. * Does exist one action manager with at least one trigger
  10770. **/
  10771. static readonly HasTriggers: boolean;
  10772. /**
  10773. * Does exist one action manager with at least one pick trigger
  10774. **/
  10775. static readonly HasPickTriggers: boolean;
  10776. /**
  10777. * Does exist one action manager that handles actions of a given trigger
  10778. * @param trigger defines the trigger to be tested
  10779. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  10780. **/
  10781. static HasSpecificTrigger(trigger: number): boolean;
  10782. }
  10783. }
  10784. declare module BABYLON {
  10785. /**
  10786. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10787. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10789. */
  10790. export class ActionManager extends AbstractActionManager {
  10791. /**
  10792. * Nothing
  10793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10794. */
  10795. static readonly NothingTrigger: number;
  10796. /**
  10797. * On pick
  10798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10799. */
  10800. static readonly OnPickTrigger: number;
  10801. /**
  10802. * On left pick
  10803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10804. */
  10805. static readonly OnLeftPickTrigger: number;
  10806. /**
  10807. * On right pick
  10808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10809. */
  10810. static readonly OnRightPickTrigger: number;
  10811. /**
  10812. * On center pick
  10813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10814. */
  10815. static readonly OnCenterPickTrigger: number;
  10816. /**
  10817. * On pick down
  10818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10819. */
  10820. static readonly OnPickDownTrigger: number;
  10821. /**
  10822. * On double pick
  10823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10824. */
  10825. static readonly OnDoublePickTrigger: number;
  10826. /**
  10827. * On pick up
  10828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10829. */
  10830. static readonly OnPickUpTrigger: number;
  10831. /**
  10832. * On pick out.
  10833. * This trigger will only be raised if you also declared a OnPickDown
  10834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10835. */
  10836. static readonly OnPickOutTrigger: number;
  10837. /**
  10838. * On long press
  10839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10840. */
  10841. static readonly OnLongPressTrigger: number;
  10842. /**
  10843. * On pointer over
  10844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10845. */
  10846. static readonly OnPointerOverTrigger: number;
  10847. /**
  10848. * On pointer out
  10849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10850. */
  10851. static readonly OnPointerOutTrigger: number;
  10852. /**
  10853. * On every frame
  10854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10855. */
  10856. static readonly OnEveryFrameTrigger: number;
  10857. /**
  10858. * On intersection enter
  10859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10860. */
  10861. static readonly OnIntersectionEnterTrigger: number;
  10862. /**
  10863. * On intersection exit
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10865. */
  10866. static readonly OnIntersectionExitTrigger: number;
  10867. /**
  10868. * On key down
  10869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10870. */
  10871. static readonly OnKeyDownTrigger: number;
  10872. /**
  10873. * On key up
  10874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10875. */
  10876. static readonly OnKeyUpTrigger: number;
  10877. private _scene;
  10878. /**
  10879. * Creates a new action manager
  10880. * @param scene defines the hosting scene
  10881. */
  10882. constructor(scene: Scene);
  10883. /**
  10884. * Releases all associated resources
  10885. */
  10886. dispose(): void;
  10887. /**
  10888. * Gets hosting scene
  10889. * @returns the hosting scene
  10890. */
  10891. getScene(): Scene;
  10892. /**
  10893. * Does this action manager handles actions of any of the given triggers
  10894. * @param triggers defines the triggers to be tested
  10895. * @return a boolean indicating whether one (or more) of the triggers is handled
  10896. */
  10897. hasSpecificTriggers(triggers: number[]): boolean;
  10898. /**
  10899. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10900. * speed.
  10901. * @param triggerA defines the trigger to be tested
  10902. * @param triggerB defines the trigger to be tested
  10903. * @return a boolean indicating whether one (or more) of the triggers is handled
  10904. */
  10905. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10906. /**
  10907. * Does this action manager handles actions of a given trigger
  10908. * @param trigger defines the trigger to be tested
  10909. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10910. * @return whether the trigger is handled
  10911. */
  10912. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10913. /**
  10914. * Does this action manager has pointer triggers
  10915. */
  10916. readonly hasPointerTriggers: boolean;
  10917. /**
  10918. * Does this action manager has pick triggers
  10919. */
  10920. readonly hasPickTriggers: boolean;
  10921. /**
  10922. * Registers an action to this action manager
  10923. * @param action defines the action to be registered
  10924. * @return the action amended (prepared) after registration
  10925. */
  10926. registerAction(action: Action): Nullable<Action>;
  10927. /**
  10928. * Unregisters an action to this action manager
  10929. * @param action defines the action to be unregistered
  10930. * @return a boolean indicating whether the action has been unregistered
  10931. */
  10932. unregisterAction(action: Action): Boolean;
  10933. /**
  10934. * Process a specific trigger
  10935. * @param trigger defines the trigger to process
  10936. * @param evt defines the event details to be processed
  10937. */
  10938. processTrigger(trigger: number, evt?: IActionEvent): void;
  10939. /** @hidden */
  10940. _getEffectiveTarget(target: any, propertyPath: string): any;
  10941. /** @hidden */
  10942. _getProperty(propertyPath: string): string;
  10943. /**
  10944. * Serialize this manager to a JSON object
  10945. * @param name defines the property name to store this manager
  10946. * @returns a JSON representation of this manager
  10947. */
  10948. serialize(name: string): any;
  10949. /**
  10950. * Creates a new ActionManager from a JSON data
  10951. * @param parsedActions defines the JSON data to read from
  10952. * @param object defines the hosting mesh
  10953. * @param scene defines the hosting scene
  10954. */
  10955. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10956. /**
  10957. * Get a trigger name by index
  10958. * @param trigger defines the trigger index
  10959. * @returns a trigger name
  10960. */
  10961. static GetTriggerName(trigger: number): string;
  10962. }
  10963. }
  10964. declare module BABYLON {
  10965. /**
  10966. * Class representing a ray with position and direction
  10967. */
  10968. export class Ray {
  10969. /** origin point */
  10970. origin: Vector3;
  10971. /** direction */
  10972. direction: Vector3;
  10973. /** length of the ray */
  10974. length: number;
  10975. private static readonly TmpVector3;
  10976. private _tmpRay;
  10977. /**
  10978. * Creates a new ray
  10979. * @param origin origin point
  10980. * @param direction direction
  10981. * @param length length of the ray
  10982. */
  10983. constructor(
  10984. /** origin point */
  10985. origin: Vector3,
  10986. /** direction */
  10987. direction: Vector3,
  10988. /** length of the ray */
  10989. length?: number);
  10990. /**
  10991. * Checks if the ray intersects a box
  10992. * @param minimum bound of the box
  10993. * @param maximum bound of the box
  10994. * @param intersectionTreshold extra extend to be added to the box in all direction
  10995. * @returns if the box was hit
  10996. */
  10997. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10998. /**
  10999. * Checks if the ray intersects a box
  11000. * @param box the bounding box to check
  11001. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11002. * @returns if the box was hit
  11003. */
  11004. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11005. /**
  11006. * If the ray hits a sphere
  11007. * @param sphere the bounding sphere to check
  11008. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11009. * @returns true if it hits the sphere
  11010. */
  11011. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11012. /**
  11013. * If the ray hits a triange
  11014. * @param vertex0 triangle vertex
  11015. * @param vertex1 triangle vertex
  11016. * @param vertex2 triangle vertex
  11017. * @returns intersection information if hit
  11018. */
  11019. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11020. /**
  11021. * Checks if ray intersects a plane
  11022. * @param plane the plane to check
  11023. * @returns the distance away it was hit
  11024. */
  11025. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11026. /**
  11027. * Checks if ray intersects a mesh
  11028. * @param mesh the mesh to check
  11029. * @param fastCheck if only the bounding box should checked
  11030. * @returns picking info of the intersecton
  11031. */
  11032. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11033. /**
  11034. * Checks if ray intersects a mesh
  11035. * @param meshes the meshes to check
  11036. * @param fastCheck if only the bounding box should checked
  11037. * @param results array to store result in
  11038. * @returns Array of picking infos
  11039. */
  11040. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11041. private _comparePickingInfo;
  11042. private static smallnum;
  11043. private static rayl;
  11044. /**
  11045. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11046. * @param sega the first point of the segment to test the intersection against
  11047. * @param segb the second point of the segment to test the intersection against
  11048. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11049. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11050. */
  11051. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11052. /**
  11053. * Update the ray from viewport position
  11054. * @param x position
  11055. * @param y y position
  11056. * @param viewportWidth viewport width
  11057. * @param viewportHeight viewport height
  11058. * @param world world matrix
  11059. * @param view view matrix
  11060. * @param projection projection matrix
  11061. * @returns this ray updated
  11062. */
  11063. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11064. /**
  11065. * Creates a ray with origin and direction of 0,0,0
  11066. * @returns the new ray
  11067. */
  11068. static Zero(): Ray;
  11069. /**
  11070. * Creates a new ray from screen space and viewport
  11071. * @param x position
  11072. * @param y y position
  11073. * @param viewportWidth viewport width
  11074. * @param viewportHeight viewport height
  11075. * @param world world matrix
  11076. * @param view view matrix
  11077. * @param projection projection matrix
  11078. * @returns new ray
  11079. */
  11080. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11081. /**
  11082. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11083. * transformed to the given world matrix.
  11084. * @param origin The origin point
  11085. * @param end The end point
  11086. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11087. * @returns the new ray
  11088. */
  11089. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11090. /**
  11091. * Transforms a ray by a matrix
  11092. * @param ray ray to transform
  11093. * @param matrix matrix to apply
  11094. * @returns the resulting new ray
  11095. */
  11096. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11097. /**
  11098. * Transforms a ray by a matrix
  11099. * @param ray ray to transform
  11100. * @param matrix matrix to apply
  11101. * @param result ray to store result in
  11102. */
  11103. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11104. /**
  11105. * Unproject a ray from screen space to object space
  11106. * @param sourceX defines the screen space x coordinate to use
  11107. * @param sourceY defines the screen space y coordinate to use
  11108. * @param viewportWidth defines the current width of the viewport
  11109. * @param viewportHeight defines the current height of the viewport
  11110. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11111. * @param view defines the view matrix to use
  11112. * @param projection defines the projection matrix to use
  11113. */
  11114. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11115. }
  11116. interface Scene {
  11117. /** @hidden */
  11118. _tempPickingRay: Nullable<Ray>;
  11119. /** @hidden */
  11120. _cachedRayForTransform: Ray;
  11121. /** @hidden */
  11122. _pickWithRayInverseMatrix: Matrix;
  11123. /** @hidden */
  11124. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11125. /** @hidden */
  11126. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  11127. }
  11128. }
  11129. declare module BABYLON {
  11130. /**
  11131. * Groups all the scene component constants in one place to ease maintenance.
  11132. * @hidden
  11133. */
  11134. export class SceneComponentConstants {
  11135. static readonly NAME_EFFECTLAYER: string;
  11136. static readonly NAME_LAYER: string;
  11137. static readonly NAME_LENSFLARESYSTEM: string;
  11138. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11139. static readonly NAME_PARTICLESYSTEM: string;
  11140. static readonly NAME_GAMEPAD: string;
  11141. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11142. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11143. static readonly NAME_DEPTHRENDERER: string;
  11144. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11145. static readonly NAME_SPRITE: string;
  11146. static readonly NAME_OUTLINERENDERER: string;
  11147. static readonly NAME_PROCEDURALTEXTURE: string;
  11148. static readonly NAME_SHADOWGENERATOR: string;
  11149. static readonly NAME_OCTREE: string;
  11150. static readonly NAME_PHYSICSENGINE: string;
  11151. static readonly NAME_AUDIO: string;
  11152. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11153. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11154. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11155. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11156. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11157. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11158. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11159. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11160. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11161. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11162. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11163. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11164. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11165. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11166. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11167. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11168. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11169. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11170. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11171. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11172. static readonly STEP_AFTERRENDER_AUDIO: number;
  11173. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11174. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11175. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11176. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11177. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11178. static readonly STEP_POINTERMOVE_SPRITE: number;
  11179. static readonly STEP_POINTERDOWN_SPRITE: number;
  11180. static readonly STEP_POINTERUP_SPRITE: number;
  11181. }
  11182. /**
  11183. * This represents a scene component.
  11184. *
  11185. * This is used to decouple the dependency the scene is having on the different workloads like
  11186. * layers, post processes...
  11187. */
  11188. export interface ISceneComponent {
  11189. /**
  11190. * The name of the component. Each component must have a unique name.
  11191. */
  11192. name: string;
  11193. /**
  11194. * The scene the component belongs to.
  11195. */
  11196. scene: Scene;
  11197. /**
  11198. * Register the component to one instance of a scene.
  11199. */
  11200. register(): void;
  11201. /**
  11202. * Rebuilds the elements related to this component in case of
  11203. * context lost for instance.
  11204. */
  11205. rebuild(): void;
  11206. /**
  11207. * Disposes the component and the associated ressources.
  11208. */
  11209. dispose(): void;
  11210. }
  11211. /**
  11212. * This represents a SERIALIZABLE scene component.
  11213. *
  11214. * This extends Scene Component to add Serialization methods on top.
  11215. */
  11216. export interface ISceneSerializableComponent extends ISceneComponent {
  11217. /**
  11218. * Adds all the element from the container to the scene
  11219. * @param container the container holding the elements
  11220. */
  11221. addFromContainer(container: AbstractScene): void;
  11222. /**
  11223. * Removes all the elements in the container from the scene
  11224. * @param container contains the elements to remove
  11225. */
  11226. removeFromContainer(container: AbstractScene): void;
  11227. /**
  11228. * Serializes the component data to the specified json object
  11229. * @param serializationObject The object to serialize to
  11230. */
  11231. serialize(serializationObject: any): void;
  11232. }
  11233. /**
  11234. * Strong typing of a Mesh related stage step action
  11235. */
  11236. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11237. /**
  11238. * Strong typing of a Evaluate Sub Mesh related stage step action
  11239. */
  11240. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11241. /**
  11242. * Strong typing of a Active Mesh related stage step action
  11243. */
  11244. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11245. /**
  11246. * Strong typing of a Camera related stage step action
  11247. */
  11248. export type CameraStageAction = (camera: Camera) => void;
  11249. /**
  11250. * Strong typing of a Render Target related stage step action
  11251. */
  11252. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11253. /**
  11254. * Strong typing of a RenderingGroup related stage step action
  11255. */
  11256. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11257. /**
  11258. * Strong typing of a Mesh Render related stage step action
  11259. */
  11260. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11261. /**
  11262. * Strong typing of a simple stage step action
  11263. */
  11264. export type SimpleStageAction = () => void;
  11265. /**
  11266. * Strong typing of a render target action.
  11267. */
  11268. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11269. /**
  11270. * Strong typing of a pointer move action.
  11271. */
  11272. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11273. /**
  11274. * Strong typing of a pointer up/down action.
  11275. */
  11276. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11277. /**
  11278. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11279. * @hidden
  11280. */
  11281. export class Stage<T extends Function> extends Array<{
  11282. index: number;
  11283. component: ISceneComponent;
  11284. action: T;
  11285. }> {
  11286. /**
  11287. * Hide ctor from the rest of the world.
  11288. * @param items The items to add.
  11289. */
  11290. private constructor();
  11291. /**
  11292. * Creates a new Stage.
  11293. * @returns A new instance of a Stage
  11294. */
  11295. static Create<T extends Function>(): Stage<T>;
  11296. /**
  11297. * Registers a step in an ordered way in the targeted stage.
  11298. * @param index Defines the position to register the step in
  11299. * @param component Defines the component attached to the step
  11300. * @param action Defines the action to launch during the step
  11301. */
  11302. registerStep(index: number, component: ISceneComponent, action: T): void;
  11303. /**
  11304. * Clears all the steps from the stage.
  11305. */
  11306. clear(): void;
  11307. }
  11308. }
  11309. declare module BABYLON {
  11310. interface Scene {
  11311. /** @hidden */
  11312. _pointerOverSprite: Nullable<Sprite>;
  11313. /** @hidden */
  11314. _pickedDownSprite: Nullable<Sprite>;
  11315. /** @hidden */
  11316. _tempSpritePickingRay: Nullable<Ray>;
  11317. /**
  11318. * All of the sprite managers added to this scene
  11319. * @see http://doc.babylonjs.com/babylon101/sprites
  11320. */
  11321. spriteManagers: Array<ISpriteManager>;
  11322. /**
  11323. * An event triggered when sprites rendering is about to start
  11324. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11325. */
  11326. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11327. /**
  11328. * An event triggered when sprites rendering is done
  11329. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11330. */
  11331. onAfterSpritesRenderingObservable: Observable<Scene>;
  11332. /** @hidden */
  11333. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11334. /** Launch a ray to try to pick a sprite in the scene
  11335. * @param x position on screen
  11336. * @param y position on screen
  11337. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11338. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11339. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11340. * @returns a PickingInfo
  11341. */
  11342. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11343. /** Use the given ray to pick a sprite in the scene
  11344. * @param ray The ray (in world space) to use to pick meshes
  11345. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11346. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11347. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11348. * @returns a PickingInfo
  11349. */
  11350. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11351. /**
  11352. * Force the sprite under the pointer
  11353. * @param sprite defines the sprite to use
  11354. */
  11355. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11356. /**
  11357. * Gets the sprite under the pointer
  11358. * @returns a Sprite or null if no sprite is under the pointer
  11359. */
  11360. getPointerOverSprite(): Nullable<Sprite>;
  11361. }
  11362. /**
  11363. * Defines the sprite scene component responsible to manage sprites
  11364. * in a given scene.
  11365. */
  11366. export class SpriteSceneComponent implements ISceneComponent {
  11367. /**
  11368. * The component name helpfull to identify the component in the list of scene components.
  11369. */
  11370. readonly name: string;
  11371. /**
  11372. * The scene the component belongs to.
  11373. */
  11374. scene: Scene;
  11375. /** @hidden */
  11376. private _spritePredicate;
  11377. /**
  11378. * Creates a new instance of the component for the given scene
  11379. * @param scene Defines the scene to register the component in
  11380. */
  11381. constructor(scene: Scene);
  11382. /**
  11383. * Registers the component in a given scene
  11384. */
  11385. register(): void;
  11386. /**
  11387. * Rebuilds the elements related to this component in case of
  11388. * context lost for instance.
  11389. */
  11390. rebuild(): void;
  11391. /**
  11392. * Disposes the component and the associated ressources.
  11393. */
  11394. dispose(): void;
  11395. private _pickSpriteButKeepRay;
  11396. private _pointerMove;
  11397. private _pointerDown;
  11398. private _pointerUp;
  11399. }
  11400. }
  11401. declare module BABYLON {
  11402. /** @hidden */
  11403. export var fogFragmentDeclaration: {
  11404. name: string;
  11405. shader: string;
  11406. };
  11407. }
  11408. declare module BABYLON {
  11409. /** @hidden */
  11410. export var fogFragment: {
  11411. name: string;
  11412. shader: string;
  11413. };
  11414. }
  11415. declare module BABYLON {
  11416. /** @hidden */
  11417. export var spritesPixelShader: {
  11418. name: string;
  11419. shader: string;
  11420. };
  11421. }
  11422. declare module BABYLON {
  11423. /** @hidden */
  11424. export var fogVertexDeclaration: {
  11425. name: string;
  11426. shader: string;
  11427. };
  11428. }
  11429. declare module BABYLON {
  11430. /** @hidden */
  11431. export var spritesVertexShader: {
  11432. name: string;
  11433. shader: string;
  11434. };
  11435. }
  11436. declare module BABYLON {
  11437. /**
  11438. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11439. */
  11440. export interface ISpriteManager extends IDisposable {
  11441. /**
  11442. * Restricts the camera to viewing objects with the same layerMask.
  11443. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11444. */
  11445. layerMask: number;
  11446. /**
  11447. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11448. */
  11449. isPickable: boolean;
  11450. /**
  11451. * Specifies the rendering group id for this mesh (0 by default)
  11452. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11453. */
  11454. renderingGroupId: number;
  11455. /**
  11456. * Defines the list of sprites managed by the manager.
  11457. */
  11458. sprites: Array<Sprite>;
  11459. /**
  11460. * Tests the intersection of a sprite with a specific ray.
  11461. * @param ray The ray we are sending to test the collision
  11462. * @param camera The camera space we are sending rays in
  11463. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11464. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11465. * @returns picking info or null.
  11466. */
  11467. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11468. /**
  11469. * Renders the list of sprites on screen.
  11470. */
  11471. render(): void;
  11472. }
  11473. /**
  11474. * Class used to manage multiple sprites on the same spritesheet
  11475. * @see http://doc.babylonjs.com/babylon101/sprites
  11476. */
  11477. export class SpriteManager implements ISpriteManager {
  11478. /** defines the manager's name */
  11479. name: string;
  11480. /** Gets the list of sprites */
  11481. sprites: Sprite[];
  11482. /** Gets or sets the rendering group id (0 by default) */
  11483. renderingGroupId: number;
  11484. /** Gets or sets camera layer mask */
  11485. layerMask: number;
  11486. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11487. fogEnabled: boolean;
  11488. /** Gets or sets a boolean indicating if the sprites are pickable */
  11489. isPickable: boolean;
  11490. /** Defines the default width of a cell in the spritesheet */
  11491. cellWidth: number;
  11492. /** Defines the default height of a cell in the spritesheet */
  11493. cellHeight: number;
  11494. /**
  11495. * An event triggered when the manager is disposed.
  11496. */
  11497. onDisposeObservable: Observable<SpriteManager>;
  11498. private _onDisposeObserver;
  11499. /**
  11500. * Callback called when the manager is disposed
  11501. */
  11502. onDispose: () => void;
  11503. private _capacity;
  11504. private _spriteTexture;
  11505. private _epsilon;
  11506. private _scene;
  11507. private _vertexData;
  11508. private _buffer;
  11509. private _vertexBuffers;
  11510. private _indexBuffer;
  11511. private _effectBase;
  11512. private _effectFog;
  11513. /**
  11514. * Gets or sets the spritesheet texture
  11515. */
  11516. texture: Texture;
  11517. /**
  11518. * Creates a new sprite manager
  11519. * @param name defines the manager's name
  11520. * @param imgUrl defines the sprite sheet url
  11521. * @param capacity defines the maximum allowed number of sprites
  11522. * @param cellSize defines the size of a sprite cell
  11523. * @param scene defines the hosting scene
  11524. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11525. * @param samplingMode defines the smapling mode to use with spritesheet
  11526. */
  11527. constructor(
  11528. /** defines the manager's name */
  11529. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11530. private _appendSpriteVertex;
  11531. /**
  11532. * Intersects the sprites with a ray
  11533. * @param ray defines the ray to intersect with
  11534. * @param camera defines the current active camera
  11535. * @param predicate defines a predicate used to select candidate sprites
  11536. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11537. * @returns null if no hit or a PickingInfo
  11538. */
  11539. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11540. /**
  11541. * Render all child sprites
  11542. */
  11543. render(): void;
  11544. /**
  11545. * Release associated resources
  11546. */
  11547. dispose(): void;
  11548. }
  11549. }
  11550. declare module BABYLON {
  11551. /**
  11552. * Class used to represent a sprite
  11553. * @see http://doc.babylonjs.com/babylon101/sprites
  11554. */
  11555. export class Sprite {
  11556. /** defines the name */
  11557. name: string;
  11558. /** Gets or sets the current world position */
  11559. position: Vector3;
  11560. /** Gets or sets the main color */
  11561. color: Color4;
  11562. /** Gets or sets the width */
  11563. width: number;
  11564. /** Gets or sets the height */
  11565. height: number;
  11566. /** Gets or sets rotation angle */
  11567. angle: number;
  11568. /** Gets or sets the cell index in the sprite sheet */
  11569. cellIndex: number;
  11570. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11571. invertU: number;
  11572. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11573. invertV: number;
  11574. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11575. disposeWhenFinishedAnimating: boolean;
  11576. /** Gets the list of attached animations */
  11577. animations: Animation[];
  11578. /** Gets or sets a boolean indicating if the sprite can be picked */
  11579. isPickable: boolean;
  11580. /**
  11581. * Gets or sets the associated action manager
  11582. */
  11583. actionManager: Nullable<ActionManager>;
  11584. private _animationStarted;
  11585. private _loopAnimation;
  11586. private _fromIndex;
  11587. private _toIndex;
  11588. private _delay;
  11589. private _direction;
  11590. private _manager;
  11591. private _time;
  11592. private _onAnimationEnd;
  11593. /**
  11594. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11595. */
  11596. isVisible: boolean;
  11597. /**
  11598. * Gets or sets the sprite size
  11599. */
  11600. size: number;
  11601. /**
  11602. * Creates a new Sprite
  11603. * @param name defines the name
  11604. * @param manager defines the manager
  11605. */
  11606. constructor(
  11607. /** defines the name */
  11608. name: string, manager: ISpriteManager);
  11609. /**
  11610. * Starts an animation
  11611. * @param from defines the initial key
  11612. * @param to defines the end key
  11613. * @param loop defines if the animation must loop
  11614. * @param delay defines the start delay (in ms)
  11615. * @param onAnimationEnd defines a callback to call when animation ends
  11616. */
  11617. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11618. /** Stops current animation (if any) */
  11619. stopAnimation(): void;
  11620. /** @hidden */
  11621. _animate(deltaTime: number): void;
  11622. /** Release associated resources */
  11623. dispose(): void;
  11624. }
  11625. }
  11626. declare module BABYLON {
  11627. /**
  11628. * Information about the result of picking within a scene
  11629. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11630. */
  11631. export class PickingInfo {
  11632. /** @hidden */
  11633. _pickingUnavailable: boolean;
  11634. /**
  11635. * If the pick collided with an object
  11636. */
  11637. hit: boolean;
  11638. /**
  11639. * Distance away where the pick collided
  11640. */
  11641. distance: number;
  11642. /**
  11643. * The location of pick collision
  11644. */
  11645. pickedPoint: Nullable<Vector3>;
  11646. /**
  11647. * The mesh corresponding the the pick collision
  11648. */
  11649. pickedMesh: Nullable<AbstractMesh>;
  11650. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11651. bu: number;
  11652. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11653. bv: number;
  11654. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11655. faceId: number;
  11656. /** Id of the the submesh that was picked */
  11657. subMeshId: number;
  11658. /** If a sprite was picked, this will be the sprite the pick collided with */
  11659. pickedSprite: Nullable<Sprite>;
  11660. /**
  11661. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11662. */
  11663. originMesh: Nullable<AbstractMesh>;
  11664. /**
  11665. * The ray that was used to perform the picking.
  11666. */
  11667. ray: Nullable<Ray>;
  11668. /**
  11669. * Gets the normal correspodning to the face the pick collided with
  11670. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11671. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11672. * @returns The normal correspodning to the face the pick collided with
  11673. */
  11674. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11675. /**
  11676. * Gets the texture coordinates of where the pick occured
  11677. * @returns the vector containing the coordnates of the texture
  11678. */
  11679. getTextureCoordinates(): Nullable<Vector2>;
  11680. }
  11681. }
  11682. declare module BABYLON {
  11683. /**
  11684. * Gather the list of pointer event types as constants.
  11685. */
  11686. export class PointerEventTypes {
  11687. /**
  11688. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11689. */
  11690. static readonly POINTERDOWN: number;
  11691. /**
  11692. * The pointerup event is fired when a pointer is no longer active.
  11693. */
  11694. static readonly POINTERUP: number;
  11695. /**
  11696. * The pointermove event is fired when a pointer changes coordinates.
  11697. */
  11698. static readonly POINTERMOVE: number;
  11699. /**
  11700. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11701. */
  11702. static readonly POINTERWHEEL: number;
  11703. /**
  11704. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11705. */
  11706. static readonly POINTERPICK: number;
  11707. /**
  11708. * The pointertap event is fired when a the object has been touched and released without drag.
  11709. */
  11710. static readonly POINTERTAP: number;
  11711. /**
  11712. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11713. */
  11714. static readonly POINTERDOUBLETAP: number;
  11715. }
  11716. /**
  11717. * Base class of pointer info types.
  11718. */
  11719. export class PointerInfoBase {
  11720. /**
  11721. * Defines the type of event (PointerEventTypes)
  11722. */
  11723. type: number;
  11724. /**
  11725. * Defines the related dom event
  11726. */
  11727. event: PointerEvent | MouseWheelEvent;
  11728. /**
  11729. * Instantiates the base class of pointers info.
  11730. * @param type Defines the type of event (PointerEventTypes)
  11731. * @param event Defines the related dom event
  11732. */
  11733. constructor(
  11734. /**
  11735. * Defines the type of event (PointerEventTypes)
  11736. */
  11737. type: number,
  11738. /**
  11739. * Defines the related dom event
  11740. */
  11741. event: PointerEvent | MouseWheelEvent);
  11742. }
  11743. /**
  11744. * This class is used to store pointer related info for the onPrePointerObservable event.
  11745. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11746. */
  11747. export class PointerInfoPre extends PointerInfoBase {
  11748. /**
  11749. * Ray from a pointer if availible (eg. 6dof controller)
  11750. */
  11751. ray: Nullable<Ray>;
  11752. /**
  11753. * Defines the local position of the pointer on the canvas.
  11754. */
  11755. localPosition: Vector2;
  11756. /**
  11757. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11758. */
  11759. skipOnPointerObservable: boolean;
  11760. /**
  11761. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11762. * @param type Defines the type of event (PointerEventTypes)
  11763. * @param event Defines the related dom event
  11764. * @param localX Defines the local x coordinates of the pointer when the event occured
  11765. * @param localY Defines the local y coordinates of the pointer when the event occured
  11766. */
  11767. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11768. }
  11769. /**
  11770. * This type contains all the data related to a pointer event in Babylon.js.
  11771. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  11772. */
  11773. export class PointerInfo extends PointerInfoBase {
  11774. /**
  11775. * Defines the picking info associated to the info (if any)\
  11776. */
  11777. pickInfo: Nullable<PickingInfo>;
  11778. /**
  11779. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11780. * @param type Defines the type of event (PointerEventTypes)
  11781. * @param event Defines the related dom event
  11782. * @param pickInfo Defines the picking info associated to the info (if any)\
  11783. */
  11784. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11785. /**
  11786. * Defines the picking info associated to the info (if any)\
  11787. */
  11788. pickInfo: Nullable<PickingInfo>);
  11789. }
  11790. }
  11791. declare module BABYLON {
  11792. /**
  11793. * Manage the mouse inputs to control the movement of a free camera.
  11794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11795. */
  11796. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11797. /**
  11798. * Define if touch is enabled in the mouse input
  11799. */
  11800. touchEnabled: boolean;
  11801. /**
  11802. * Defines the camera the input is attached to.
  11803. */
  11804. camera: FreeCamera;
  11805. /**
  11806. * Defines the buttons associated with the input to handle camera move.
  11807. */
  11808. buttons: number[];
  11809. /**
  11810. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11811. */
  11812. angularSensibility: number;
  11813. private _pointerInput;
  11814. private _onMouseMove;
  11815. private _observer;
  11816. private previousPosition;
  11817. /**
  11818. * Manage the mouse inputs to control the movement of a free camera.
  11819. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11820. * @param touchEnabled Defines if touch is enabled or not
  11821. */
  11822. constructor(
  11823. /**
  11824. * Define if touch is enabled in the mouse input
  11825. */
  11826. touchEnabled?: boolean);
  11827. /**
  11828. * Attach the input controls to a specific dom element to get the input from.
  11829. * @param element Defines the element the controls should be listened from
  11830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11831. */
  11832. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11833. /**
  11834. * Detach the current controls from the specified dom element.
  11835. * @param element Defines the element to stop listening the inputs from
  11836. */
  11837. detachControl(element: Nullable<HTMLElement>): void;
  11838. /**
  11839. * Gets the class name of the current intput.
  11840. * @returns the class name
  11841. */
  11842. getClassName(): string;
  11843. /**
  11844. * Get the friendly name associated with the input class.
  11845. * @returns the input friendly name
  11846. */
  11847. getSimpleName(): string;
  11848. }
  11849. }
  11850. declare module BABYLON {
  11851. /**
  11852. * Manage the touch inputs to control the movement of a free camera.
  11853. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11854. */
  11855. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11856. /**
  11857. * Defines the camera the input is attached to.
  11858. */
  11859. camera: FreeCamera;
  11860. /**
  11861. * Defines the touch sensibility for rotation.
  11862. * The higher the faster.
  11863. */
  11864. touchAngularSensibility: number;
  11865. /**
  11866. * Defines the touch sensibility for move.
  11867. * The higher the faster.
  11868. */
  11869. touchMoveSensibility: number;
  11870. private _offsetX;
  11871. private _offsetY;
  11872. private _pointerPressed;
  11873. private _pointerInput;
  11874. private _observer;
  11875. private _onLostFocus;
  11876. /**
  11877. * Attach the input controls to a specific dom element to get the input from.
  11878. * @param element Defines the element the controls should be listened from
  11879. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11880. */
  11881. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11882. /**
  11883. * Detach the current controls from the specified dom element.
  11884. * @param element Defines the element to stop listening the inputs from
  11885. */
  11886. detachControl(element: Nullable<HTMLElement>): void;
  11887. /**
  11888. * Update the current camera state depending on the inputs that have been used this frame.
  11889. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11890. */
  11891. checkInputs(): void;
  11892. /**
  11893. * Gets the class name of the current intput.
  11894. * @returns the class name
  11895. */
  11896. getClassName(): string;
  11897. /**
  11898. * Get the friendly name associated with the input class.
  11899. * @returns the input friendly name
  11900. */
  11901. getSimpleName(): string;
  11902. }
  11903. }
  11904. declare module BABYLON {
  11905. /**
  11906. * Default Inputs manager for the FreeCamera.
  11907. * It groups all the default supported inputs for ease of use.
  11908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11909. */
  11910. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11911. /**
  11912. * Instantiates a new FreeCameraInputsManager.
  11913. * @param camera Defines the camera the inputs belong to
  11914. */
  11915. constructor(camera: FreeCamera);
  11916. /**
  11917. * Add keyboard input support to the input manager.
  11918. * @returns the current input manager
  11919. */
  11920. addKeyboard(): FreeCameraInputsManager;
  11921. /**
  11922. * Add mouse input support to the input manager.
  11923. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11924. * @returns the current input manager
  11925. */
  11926. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11927. /**
  11928. * Add touch input support to the input manager.
  11929. * @returns the current input manager
  11930. */
  11931. addTouch(): FreeCameraInputsManager;
  11932. }
  11933. }
  11934. declare module BABYLON {
  11935. /**
  11936. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11937. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11938. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11939. */
  11940. export class FreeCamera extends TargetCamera {
  11941. /**
  11942. * Define the collision ellipsoid of the camera.
  11943. * This is helpful to simulate a camera body like the player body around the camera
  11944. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11945. */
  11946. ellipsoid: Vector3;
  11947. /**
  11948. * Define an offset for the position of the ellipsoid around the camera.
  11949. * This can be helpful to determine the center of the body near the gravity center of the body
  11950. * instead of its head.
  11951. */
  11952. ellipsoidOffset: Vector3;
  11953. /**
  11954. * Enable or disable collisions of the camera with the rest of the scene objects.
  11955. */
  11956. checkCollisions: boolean;
  11957. /**
  11958. * Enable or disable gravity on the camera.
  11959. */
  11960. applyGravity: boolean;
  11961. /**
  11962. * Define the input manager associated to the camera.
  11963. */
  11964. inputs: FreeCameraInputsManager;
  11965. /**
  11966. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11967. * Higher values reduce sensitivity.
  11968. */
  11969. /**
  11970. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11971. * Higher values reduce sensitivity.
  11972. */
  11973. angularSensibility: number;
  11974. /**
  11975. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11976. */
  11977. keysUp: number[];
  11978. /**
  11979. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11980. */
  11981. keysDown: number[];
  11982. /**
  11983. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11984. */
  11985. keysLeft: number[];
  11986. /**
  11987. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11988. */
  11989. keysRight: number[];
  11990. /**
  11991. * Event raised when the camera collide with a mesh in the scene.
  11992. */
  11993. onCollide: (collidedMesh: AbstractMesh) => void;
  11994. private _collider;
  11995. private _needMoveForGravity;
  11996. private _oldPosition;
  11997. private _diffPosition;
  11998. private _newPosition;
  11999. /** @hidden */
  12000. _localDirection: Vector3;
  12001. /** @hidden */
  12002. _transformedDirection: Vector3;
  12003. /**
  12004. * Instantiates a Free Camera.
  12005. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12006. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12007. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12008. * @param name Define the name of the camera in the scene
  12009. * @param position Define the start position of the camera in the scene
  12010. * @param scene Define the scene the camera belongs to
  12011. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12012. */
  12013. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12014. /**
  12015. * Attached controls to the current camera.
  12016. * @param element Defines the element the controls should be listened from
  12017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12018. */
  12019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12020. /**
  12021. * Detach the current controls from the camera.
  12022. * The camera will stop reacting to inputs.
  12023. * @param element Defines the element to stop listening the inputs from
  12024. */
  12025. detachControl(element: HTMLElement): void;
  12026. private _collisionMask;
  12027. /**
  12028. * Define a collision mask to limit the list of object the camera can collide with
  12029. */
  12030. collisionMask: number;
  12031. /** @hidden */
  12032. _collideWithWorld(displacement: Vector3): void;
  12033. private _onCollisionPositionChange;
  12034. /** @hidden */
  12035. _checkInputs(): void;
  12036. /** @hidden */
  12037. _decideIfNeedsToMove(): boolean;
  12038. /** @hidden */
  12039. _updatePosition(): void;
  12040. /**
  12041. * Destroy the camera and release the current resources hold by it.
  12042. */
  12043. dispose(): void;
  12044. /**
  12045. * Gets the current object class name.
  12046. * @return the class name
  12047. */
  12048. getClassName(): string;
  12049. }
  12050. }
  12051. declare module BABYLON {
  12052. /**
  12053. * Represents a gamepad control stick position
  12054. */
  12055. export class StickValues {
  12056. /**
  12057. * The x component of the control stick
  12058. */
  12059. x: number;
  12060. /**
  12061. * The y component of the control stick
  12062. */
  12063. y: number;
  12064. /**
  12065. * Initializes the gamepad x and y control stick values
  12066. * @param x The x component of the gamepad control stick value
  12067. * @param y The y component of the gamepad control stick value
  12068. */
  12069. constructor(
  12070. /**
  12071. * The x component of the control stick
  12072. */
  12073. x: number,
  12074. /**
  12075. * The y component of the control stick
  12076. */
  12077. y: number);
  12078. }
  12079. /**
  12080. * An interface which manages callbacks for gamepad button changes
  12081. */
  12082. export interface GamepadButtonChanges {
  12083. /**
  12084. * Called when a gamepad has been changed
  12085. */
  12086. changed: boolean;
  12087. /**
  12088. * Called when a gamepad press event has been triggered
  12089. */
  12090. pressChanged: boolean;
  12091. /**
  12092. * Called when a touch event has been triggered
  12093. */
  12094. touchChanged: boolean;
  12095. /**
  12096. * Called when a value has changed
  12097. */
  12098. valueChanged: boolean;
  12099. }
  12100. /**
  12101. * Represents a gamepad
  12102. */
  12103. export class Gamepad {
  12104. /**
  12105. * The id of the gamepad
  12106. */
  12107. id: string;
  12108. /**
  12109. * The index of the gamepad
  12110. */
  12111. index: number;
  12112. /**
  12113. * The browser gamepad
  12114. */
  12115. browserGamepad: any;
  12116. /**
  12117. * Specifies what type of gamepad this represents
  12118. */
  12119. type: number;
  12120. private _leftStick;
  12121. private _rightStick;
  12122. /** @hidden */
  12123. _isConnected: boolean;
  12124. private _leftStickAxisX;
  12125. private _leftStickAxisY;
  12126. private _rightStickAxisX;
  12127. private _rightStickAxisY;
  12128. /**
  12129. * Triggered when the left control stick has been changed
  12130. */
  12131. private _onleftstickchanged;
  12132. /**
  12133. * Triggered when the right control stick has been changed
  12134. */
  12135. private _onrightstickchanged;
  12136. /**
  12137. * Represents a gamepad controller
  12138. */
  12139. static GAMEPAD: number;
  12140. /**
  12141. * Represents a generic controller
  12142. */
  12143. static GENERIC: number;
  12144. /**
  12145. * Represents an XBox controller
  12146. */
  12147. static XBOX: number;
  12148. /**
  12149. * Represents a pose-enabled controller
  12150. */
  12151. static POSE_ENABLED: number;
  12152. /**
  12153. * Specifies whether the left control stick should be Y-inverted
  12154. */
  12155. protected _invertLeftStickY: boolean;
  12156. /**
  12157. * Specifies if the gamepad has been connected
  12158. */
  12159. readonly isConnected: boolean;
  12160. /**
  12161. * Initializes the gamepad
  12162. * @param id The id of the gamepad
  12163. * @param index The index of the gamepad
  12164. * @param browserGamepad The browser gamepad
  12165. * @param leftStickX The x component of the left joystick
  12166. * @param leftStickY The y component of the left joystick
  12167. * @param rightStickX The x component of the right joystick
  12168. * @param rightStickY The y component of the right joystick
  12169. */
  12170. constructor(
  12171. /**
  12172. * The id of the gamepad
  12173. */
  12174. id: string,
  12175. /**
  12176. * The index of the gamepad
  12177. */
  12178. index: number,
  12179. /**
  12180. * The browser gamepad
  12181. */
  12182. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12183. /**
  12184. * Callback triggered when the left joystick has changed
  12185. * @param callback
  12186. */
  12187. onleftstickchanged(callback: (values: StickValues) => void): void;
  12188. /**
  12189. * Callback triggered when the right joystick has changed
  12190. * @param callback
  12191. */
  12192. onrightstickchanged(callback: (values: StickValues) => void): void;
  12193. /**
  12194. * Gets the left joystick
  12195. */
  12196. /**
  12197. * Sets the left joystick values
  12198. */
  12199. leftStick: StickValues;
  12200. /**
  12201. * Gets the right joystick
  12202. */
  12203. /**
  12204. * Sets the right joystick value
  12205. */
  12206. rightStick: StickValues;
  12207. /**
  12208. * Updates the gamepad joystick positions
  12209. */
  12210. update(): void;
  12211. /**
  12212. * Disposes the gamepad
  12213. */
  12214. dispose(): void;
  12215. }
  12216. /**
  12217. * Represents a generic gamepad
  12218. */
  12219. export class GenericPad extends Gamepad {
  12220. private _buttons;
  12221. private _onbuttondown;
  12222. private _onbuttonup;
  12223. /**
  12224. * Observable triggered when a button has been pressed
  12225. */
  12226. onButtonDownObservable: Observable<number>;
  12227. /**
  12228. * Observable triggered when a button has been released
  12229. */
  12230. onButtonUpObservable: Observable<number>;
  12231. /**
  12232. * Callback triggered when a button has been pressed
  12233. * @param callback Called when a button has been pressed
  12234. */
  12235. onbuttondown(callback: (buttonPressed: number) => void): void;
  12236. /**
  12237. * Callback triggered when a button has been released
  12238. * @param callback Called when a button has been released
  12239. */
  12240. onbuttonup(callback: (buttonReleased: number) => void): void;
  12241. /**
  12242. * Initializes the generic gamepad
  12243. * @param id The id of the generic gamepad
  12244. * @param index The index of the generic gamepad
  12245. * @param browserGamepad The browser gamepad
  12246. */
  12247. constructor(id: string, index: number, browserGamepad: any);
  12248. private _setButtonValue;
  12249. /**
  12250. * Updates the generic gamepad
  12251. */
  12252. update(): void;
  12253. /**
  12254. * Disposes the generic gamepad
  12255. */
  12256. dispose(): void;
  12257. }
  12258. }
  12259. declare module BABYLON {
  12260. /**
  12261. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  12262. * @see https://doc.babylonjs.com/how_to/transformnode
  12263. */
  12264. export class TransformNode extends Node {
  12265. /**
  12266. * Object will not rotate to face the camera
  12267. */
  12268. static BILLBOARDMODE_NONE: number;
  12269. /**
  12270. * Object will rotate to face the camera but only on the x axis
  12271. */
  12272. static BILLBOARDMODE_X: number;
  12273. /**
  12274. * Object will rotate to face the camera but only on the y axis
  12275. */
  12276. static BILLBOARDMODE_Y: number;
  12277. /**
  12278. * Object will rotate to face the camera but only on the z axis
  12279. */
  12280. static BILLBOARDMODE_Z: number;
  12281. /**
  12282. * Object will rotate to face the camera
  12283. */
  12284. static BILLBOARDMODE_ALL: number;
  12285. private _forward;
  12286. private _forwardInverted;
  12287. private _up;
  12288. private _right;
  12289. private _rightInverted;
  12290. private _position;
  12291. private _rotation;
  12292. private _rotationQuaternion;
  12293. protected _scaling: Vector3;
  12294. protected _isDirty: boolean;
  12295. private _transformToBoneReferal;
  12296. /**
  12297. * Set the billboard mode. Default is 0.
  12298. *
  12299. * | Value | Type | Description |
  12300. * | --- | --- | --- |
  12301. * | 0 | BILLBOARDMODE_NONE | |
  12302. * | 1 | BILLBOARDMODE_X | |
  12303. * | 2 | BILLBOARDMODE_Y | |
  12304. * | 4 | BILLBOARDMODE_Z | |
  12305. * | 7 | BILLBOARDMODE_ALL | |
  12306. *
  12307. */
  12308. billboardMode: number;
  12309. /**
  12310. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  12311. */
  12312. scalingDeterminant: number;
  12313. /**
  12314. * Sets the distance of the object to max, often used by skybox
  12315. */
  12316. infiniteDistance: boolean;
  12317. /**
  12318. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  12319. * By default the system will update normals to compensate
  12320. */
  12321. ignoreNonUniformScaling: boolean;
  12322. /** @hidden */
  12323. _poseMatrix: Matrix;
  12324. /** @hidden */
  12325. _localMatrix: Matrix;
  12326. private _absolutePosition;
  12327. private _pivotMatrix;
  12328. private _pivotMatrixInverse;
  12329. protected _postMultiplyPivotMatrix: boolean;
  12330. protected _isWorldMatrixFrozen: boolean;
  12331. /** @hidden */
  12332. _indexInSceneTransformNodesArray: number;
  12333. /**
  12334. * An event triggered after the world matrix is updated
  12335. */
  12336. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  12337. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  12338. /**
  12339. * Gets a string identifying the name of the class
  12340. * @returns "TransformNode" string
  12341. */
  12342. getClassName(): string;
  12343. /**
  12344. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  12345. */
  12346. position: Vector3;
  12347. /**
  12348. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  12349. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  12350. */
  12351. rotation: Vector3;
  12352. /**
  12353. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  12354. */
  12355. scaling: Vector3;
  12356. /**
  12357. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  12358. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  12359. */
  12360. rotationQuaternion: Nullable<Quaternion>;
  12361. /**
  12362. * The forward direction of that transform in world space.
  12363. */
  12364. readonly forward: Vector3;
  12365. /**
  12366. * The up direction of that transform in world space.
  12367. */
  12368. readonly up: Vector3;
  12369. /**
  12370. * The right direction of that transform in world space.
  12371. */
  12372. readonly right: Vector3;
  12373. /**
  12374. * Copies the parameter passed Matrix into the mesh Pose matrix.
  12375. * @param matrix the matrix to copy the pose from
  12376. * @returns this TransformNode.
  12377. */
  12378. updatePoseMatrix(matrix: Matrix): TransformNode;
  12379. /**
  12380. * Returns the mesh Pose matrix.
  12381. * @returns the pose matrix
  12382. */
  12383. getPoseMatrix(): Matrix;
  12384. /** @hidden */
  12385. _isSynchronized(): boolean;
  12386. /** @hidden */
  12387. _initCache(): void;
  12388. /**
  12389. * Flag the transform node as dirty (Forcing it to update everything)
  12390. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  12391. * @returns this transform node
  12392. */
  12393. markAsDirty(property: string): TransformNode;
  12394. /**
  12395. * Returns the current mesh absolute position.
  12396. * Returns a Vector3.
  12397. */
  12398. readonly absolutePosition: Vector3;
  12399. /**
  12400. * Sets a new matrix to apply before all other transformation
  12401. * @param matrix defines the transform matrix
  12402. * @returns the current TransformNode
  12403. */
  12404. setPreTransformMatrix(matrix: Matrix): TransformNode;
  12405. /**
  12406. * Sets a new pivot matrix to the current node
  12407. * @param matrix defines the new pivot matrix to use
  12408. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  12409. * @returns the current TransformNode
  12410. */
  12411. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  12412. /**
  12413. * Returns the mesh pivot matrix.
  12414. * Default : Identity.
  12415. * @returns the matrix
  12416. */
  12417. getPivotMatrix(): Matrix;
  12418. /**
  12419. * Prevents the World matrix to be computed any longer.
  12420. * @returns the TransformNode.
  12421. */
  12422. freezeWorldMatrix(): TransformNode;
  12423. /**
  12424. * Allows back the World matrix computation.
  12425. * @returns the TransformNode.
  12426. */
  12427. unfreezeWorldMatrix(): this;
  12428. /**
  12429. * True if the World matrix has been frozen.
  12430. */
  12431. readonly isWorldMatrixFrozen: boolean;
  12432. /**
  12433. * Retuns the mesh absolute position in the World.
  12434. * @returns a Vector3.
  12435. */
  12436. getAbsolutePosition(): Vector3;
  12437. /**
  12438. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  12439. * @param absolutePosition the absolute position to set
  12440. * @returns the TransformNode.
  12441. */
  12442. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  12443. /**
  12444. * Sets the mesh position in its local space.
  12445. * @param vector3 the position to set in localspace
  12446. * @returns the TransformNode.
  12447. */
  12448. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  12449. /**
  12450. * Returns the mesh position in the local space from the current World matrix values.
  12451. * @returns a new Vector3.
  12452. */
  12453. getPositionExpressedInLocalSpace(): Vector3;
  12454. /**
  12455. * Translates the mesh along the passed Vector3 in its local space.
  12456. * @param vector3 the distance to translate in localspace
  12457. * @returns the TransformNode.
  12458. */
  12459. locallyTranslate(vector3: Vector3): TransformNode;
  12460. private static _lookAtVectorCache;
  12461. /**
  12462. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  12463. * @param targetPoint the position (must be in same space as current mesh) to look at
  12464. * @param yawCor optional yaw (y-axis) correction in radians
  12465. * @param pitchCor optional pitch (x-axis) correction in radians
  12466. * @param rollCor optional roll (z-axis) correction in radians
  12467. * @param space the choosen space of the target
  12468. * @returns the TransformNode.
  12469. */
  12470. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  12471. /**
  12472. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  12473. * This Vector3 is expressed in the World space.
  12474. * @param localAxis axis to rotate
  12475. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  12476. */
  12477. getDirection(localAxis: Vector3): Vector3;
  12478. /**
  12479. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  12480. * localAxis is expressed in the mesh local space.
  12481. * result is computed in the Wordl space from the mesh World matrix.
  12482. * @param localAxis axis to rotate
  12483. * @param result the resulting transformnode
  12484. * @returns this TransformNode.
  12485. */
  12486. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  12487. /**
  12488. * Sets this transform node rotation to the given local axis.
  12489. * @param localAxis the axis in local space
  12490. * @param yawCor optional yaw (y-axis) correction in radians
  12491. * @param pitchCor optional pitch (x-axis) correction in radians
  12492. * @param rollCor optional roll (z-axis) correction in radians
  12493. * @returns this TransformNode
  12494. */
  12495. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  12496. /**
  12497. * Sets a new pivot point to the current node
  12498. * @param point defines the new pivot point to use
  12499. * @param space defines if the point is in world or local space (local by default)
  12500. * @returns the current TransformNode
  12501. */
  12502. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  12503. /**
  12504. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  12505. * @returns the pivot point
  12506. */
  12507. getPivotPoint(): Vector3;
  12508. /**
  12509. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  12510. * @param result the vector3 to store the result
  12511. * @returns this TransformNode.
  12512. */
  12513. getPivotPointToRef(result: Vector3): TransformNode;
  12514. /**
  12515. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  12516. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  12517. */
  12518. getAbsolutePivotPoint(): Vector3;
  12519. /**
  12520. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  12521. * @param result vector3 to store the result
  12522. * @returns this TransformNode.
  12523. */
  12524. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  12525. /**
  12526. * Defines the passed node as the parent of the current node.
  12527. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  12528. * @param node the node ot set as the parent
  12529. * @returns this TransformNode.
  12530. */
  12531. setParent(node: Nullable<Node>): TransformNode;
  12532. private _nonUniformScaling;
  12533. /**
  12534. * True if the scaling property of this object is non uniform eg. (1,2,1)
  12535. */
  12536. readonly nonUniformScaling: boolean;
  12537. /** @hidden */
  12538. _updateNonUniformScalingState(value: boolean): boolean;
  12539. /**
  12540. * Attach the current TransformNode to another TransformNode associated with a bone
  12541. * @param bone Bone affecting the TransformNode
  12542. * @param affectedTransformNode TransformNode associated with the bone
  12543. * @returns this object
  12544. */
  12545. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  12546. /**
  12547. * Detach the transform node if its associated with a bone
  12548. * @returns this object
  12549. */
  12550. detachFromBone(): TransformNode;
  12551. private static _rotationAxisCache;
  12552. /**
  12553. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  12554. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  12555. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  12556. * The passed axis is also normalized.
  12557. * @param axis the axis to rotate around
  12558. * @param amount the amount to rotate in radians
  12559. * @param space Space to rotate in (Default: local)
  12560. * @returns the TransformNode.
  12561. */
  12562. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  12563. /**
  12564. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  12565. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  12566. * The passed axis is also normalized. .
  12567. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  12568. * @param point the point to rotate around
  12569. * @param axis the axis to rotate around
  12570. * @param amount the amount to rotate in radians
  12571. * @returns the TransformNode
  12572. */
  12573. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  12574. /**
  12575. * Translates the mesh along the axis vector for the passed distance in the given space.
  12576. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  12577. * @param axis the axis to translate in
  12578. * @param distance the distance to translate
  12579. * @param space Space to rotate in (Default: local)
  12580. * @returns the TransformNode.
  12581. */
  12582. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  12583. /**
  12584. * Adds a rotation step to the mesh current rotation.
  12585. * x, y, z are Euler angles expressed in radians.
  12586. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  12587. * This means this rotation is made in the mesh local space only.
  12588. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  12589. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  12590. * ```javascript
  12591. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  12592. * ```
  12593. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  12594. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  12595. * @param x Rotation to add
  12596. * @param y Rotation to add
  12597. * @param z Rotation to add
  12598. * @returns the TransformNode.
  12599. */
  12600. addRotation(x: number, y: number, z: number): TransformNode;
  12601. /**
  12602. * Computes the world matrix of the node
  12603. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12604. * @returns the world matrix
  12605. */
  12606. computeWorldMatrix(force?: boolean): Matrix;
  12607. protected _afterComputeWorldMatrix(): void;
  12608. /**
  12609. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  12610. * @param func callback function to add
  12611. *
  12612. * @returns the TransformNode.
  12613. */
  12614. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  12615. /**
  12616. * Removes a registered callback function.
  12617. * @param func callback function to remove
  12618. * @returns the TransformNode.
  12619. */
  12620. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  12621. /**
  12622. * Gets the position of the current mesh in camera space
  12623. * @param camera defines the camera to use
  12624. * @returns a position
  12625. */
  12626. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  12627. /**
  12628. * Returns the distance from the mesh to the active camera
  12629. * @param camera defines the camera to use
  12630. * @returns the distance
  12631. */
  12632. getDistanceToCamera(camera?: Nullable<Camera>): number;
  12633. /**
  12634. * Clone the current transform node
  12635. * @param name Name of the new clone
  12636. * @param newParent New parent for the clone
  12637. * @param doNotCloneChildren Do not clone children hierarchy
  12638. * @returns the new transform node
  12639. */
  12640. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  12641. /**
  12642. * Serializes the objects information.
  12643. * @param currentSerializationObject defines the object to serialize in
  12644. * @returns the serialized object
  12645. */
  12646. serialize(currentSerializationObject?: any): any;
  12647. /**
  12648. * Returns a new TransformNode object parsed from the source provided.
  12649. * @param parsedTransformNode is the source.
  12650. * @param scene the scne the object belongs to
  12651. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  12652. * @returns a new TransformNode object parsed from the source provided.
  12653. */
  12654. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  12655. /**
  12656. * Get all child-transformNodes of this node
  12657. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  12658. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  12659. * @returns an array of TransformNode
  12660. */
  12661. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  12662. /**
  12663. * Releases resources associated with this transform node.
  12664. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12665. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12666. */
  12667. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12668. }
  12669. }
  12670. declare module BABYLON {
  12671. /**
  12672. * Defines the types of pose enabled controllers that are supported
  12673. */
  12674. export enum PoseEnabledControllerType {
  12675. /**
  12676. * HTC Vive
  12677. */
  12678. VIVE = 0,
  12679. /**
  12680. * Oculus Rift
  12681. */
  12682. OCULUS = 1,
  12683. /**
  12684. * Windows mixed reality
  12685. */
  12686. WINDOWS = 2,
  12687. /**
  12688. * Samsung gear VR
  12689. */
  12690. GEAR_VR = 3,
  12691. /**
  12692. * Google Daydream
  12693. */
  12694. DAYDREAM = 4,
  12695. /**
  12696. * Generic
  12697. */
  12698. GENERIC = 5
  12699. }
  12700. /**
  12701. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12702. */
  12703. export interface MutableGamepadButton {
  12704. /**
  12705. * Value of the button/trigger
  12706. */
  12707. value: number;
  12708. /**
  12709. * If the button/trigger is currently touched
  12710. */
  12711. touched: boolean;
  12712. /**
  12713. * If the button/trigger is currently pressed
  12714. */
  12715. pressed: boolean;
  12716. }
  12717. /**
  12718. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12719. * @hidden
  12720. */
  12721. export interface ExtendedGamepadButton extends GamepadButton {
  12722. /**
  12723. * If the button/trigger is currently pressed
  12724. */
  12725. readonly pressed: boolean;
  12726. /**
  12727. * If the button/trigger is currently touched
  12728. */
  12729. readonly touched: boolean;
  12730. /**
  12731. * Value of the button/trigger
  12732. */
  12733. readonly value: number;
  12734. }
  12735. /** @hidden */
  12736. export interface _GamePadFactory {
  12737. /**
  12738. * Returns wether or not the current gamepad can be created for this type of controller.
  12739. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12740. * @returns true if it can be created, otherwise false
  12741. */
  12742. canCreate(gamepadInfo: any): boolean;
  12743. /**
  12744. * Creates a new instance of the Gamepad.
  12745. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12746. * @returns the new gamepad instance
  12747. */
  12748. create(gamepadInfo: any): Gamepad;
  12749. }
  12750. /**
  12751. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12752. */
  12753. export class PoseEnabledControllerHelper {
  12754. /** @hidden */
  12755. static _ControllerFactories: _GamePadFactory[];
  12756. /** @hidden */
  12757. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12758. /**
  12759. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12760. * @param vrGamepad the gamepad to initialized
  12761. * @returns a vr controller of the type the gamepad identified as
  12762. */
  12763. static InitiateController(vrGamepad: any): Gamepad;
  12764. }
  12765. /**
  12766. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12767. */
  12768. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12769. private _deviceRoomPosition;
  12770. private _deviceRoomRotationQuaternion;
  12771. /**
  12772. * The device position in babylon space
  12773. */
  12774. devicePosition: Vector3;
  12775. /**
  12776. * The device rotation in babylon space
  12777. */
  12778. deviceRotationQuaternion: Quaternion;
  12779. /**
  12780. * The scale factor of the device in babylon space
  12781. */
  12782. deviceScaleFactor: number;
  12783. /**
  12784. * (Likely devicePosition should be used instead) The device position in its room space
  12785. */
  12786. position: Vector3;
  12787. /**
  12788. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12789. */
  12790. rotationQuaternion: Quaternion;
  12791. /**
  12792. * The type of controller (Eg. Windows mixed reality)
  12793. */
  12794. controllerType: PoseEnabledControllerType;
  12795. protected _calculatedPosition: Vector3;
  12796. private _calculatedRotation;
  12797. /**
  12798. * The raw pose from the device
  12799. */
  12800. rawPose: DevicePose;
  12801. private _trackPosition;
  12802. private _maxRotationDistFromHeadset;
  12803. private _draggedRoomRotation;
  12804. /**
  12805. * @hidden
  12806. */
  12807. _disableTrackPosition(fixedPosition: Vector3): void;
  12808. /**
  12809. * Internal, the mesh attached to the controller
  12810. * @hidden
  12811. */
  12812. _mesh: Nullable<AbstractMesh>;
  12813. private _poseControlledCamera;
  12814. private _leftHandSystemQuaternion;
  12815. /**
  12816. * Internal, matrix used to convert room space to babylon space
  12817. * @hidden
  12818. */
  12819. _deviceToWorld: Matrix;
  12820. /**
  12821. * Node to be used when casting a ray from the controller
  12822. * @hidden
  12823. */
  12824. _pointingPoseNode: Nullable<TransformNode>;
  12825. /**
  12826. * Name of the child mesh that can be used to cast a ray from the controller
  12827. */
  12828. static readonly POINTING_POSE: string;
  12829. /**
  12830. * Creates a new PoseEnabledController from a gamepad
  12831. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12832. */
  12833. constructor(browserGamepad: any);
  12834. private _workingMatrix;
  12835. /**
  12836. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12837. */
  12838. update(): void;
  12839. /**
  12840. * Updates only the pose device and mesh without doing any button event checking
  12841. */
  12842. protected _updatePoseAndMesh(): void;
  12843. /**
  12844. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12845. * @param poseData raw pose fromthe device
  12846. */
  12847. updateFromDevice(poseData: DevicePose): void;
  12848. /**
  12849. * @hidden
  12850. */
  12851. _meshAttachedObservable: Observable<AbstractMesh>;
  12852. /**
  12853. * Attaches a mesh to the controller
  12854. * @param mesh the mesh to be attached
  12855. */
  12856. attachToMesh(mesh: AbstractMesh): void;
  12857. /**
  12858. * Attaches the controllers mesh to a camera
  12859. * @param camera the camera the mesh should be attached to
  12860. */
  12861. attachToPoseControlledCamera(camera: TargetCamera): void;
  12862. /**
  12863. * Disposes of the controller
  12864. */
  12865. dispose(): void;
  12866. /**
  12867. * The mesh that is attached to the controller
  12868. */
  12869. readonly mesh: Nullable<AbstractMesh>;
  12870. /**
  12871. * Gets the ray of the controller in the direction the controller is pointing
  12872. * @param length the length the resulting ray should be
  12873. * @returns a ray in the direction the controller is pointing
  12874. */
  12875. getForwardRay(length?: number): Ray;
  12876. }
  12877. }
  12878. declare module BABYLON {
  12879. /**
  12880. * Defines the WebVRController object that represents controllers tracked in 3D space
  12881. */
  12882. export abstract class WebVRController extends PoseEnabledController {
  12883. /**
  12884. * Internal, the default controller model for the controller
  12885. */
  12886. protected _defaultModel: AbstractMesh;
  12887. /**
  12888. * Fired when the trigger state has changed
  12889. */
  12890. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12891. /**
  12892. * Fired when the main button state has changed
  12893. */
  12894. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12895. /**
  12896. * Fired when the secondary button state has changed
  12897. */
  12898. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12899. /**
  12900. * Fired when the pad state has changed
  12901. */
  12902. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12903. /**
  12904. * Fired when controllers stick values have changed
  12905. */
  12906. onPadValuesChangedObservable: Observable<StickValues>;
  12907. /**
  12908. * Array of button availible on the controller
  12909. */
  12910. protected _buttons: Array<MutableGamepadButton>;
  12911. private _onButtonStateChange;
  12912. /**
  12913. * Fired when a controller button's state has changed
  12914. * @param callback the callback containing the button that was modified
  12915. */
  12916. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12917. /**
  12918. * X and Y axis corrisponding to the controllers joystick
  12919. */
  12920. pad: StickValues;
  12921. /**
  12922. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12923. */
  12924. hand: string;
  12925. /**
  12926. * The default controller model for the controller
  12927. */
  12928. readonly defaultModel: AbstractMesh;
  12929. /**
  12930. * Creates a new WebVRController from a gamepad
  12931. * @param vrGamepad the gamepad that the WebVRController should be created from
  12932. */
  12933. constructor(vrGamepad: any);
  12934. /**
  12935. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12936. */
  12937. update(): void;
  12938. /**
  12939. * Function to be called when a button is modified
  12940. */
  12941. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12942. /**
  12943. * Loads a mesh and attaches it to the controller
  12944. * @param scene the scene the mesh should be added to
  12945. * @param meshLoaded callback for when the mesh has been loaded
  12946. */
  12947. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12948. private _setButtonValue;
  12949. private _changes;
  12950. private _checkChanges;
  12951. /**
  12952. * Disposes of th webVRCOntroller
  12953. */
  12954. dispose(): void;
  12955. }
  12956. }
  12957. declare module BABYLON {
  12958. /**
  12959. * The HemisphericLight simulates the ambient environment light,
  12960. * so the passed direction is the light reflection direction, not the incoming direction.
  12961. */
  12962. export class HemisphericLight extends Light {
  12963. /**
  12964. * The groundColor is the light in the opposite direction to the one specified during creation.
  12965. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  12966. */
  12967. groundColor: Color3;
  12968. /**
  12969. * The light reflection direction, not the incoming direction.
  12970. */
  12971. direction: Vector3;
  12972. /**
  12973. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12974. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12975. * The HemisphericLight can't cast shadows.
  12976. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12977. * @param name The friendly name of the light
  12978. * @param direction The direction of the light reflection
  12979. * @param scene The scene the light belongs to
  12980. */
  12981. constructor(name: string, direction: Vector3, scene: Scene);
  12982. protected _buildUniformLayout(): void;
  12983. /**
  12984. * Returns the string "HemisphericLight".
  12985. * @return The class name
  12986. */
  12987. getClassName(): string;
  12988. /**
  12989. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12990. * Returns the updated direction.
  12991. * @param target The target the direction should point to
  12992. * @return The computed direction
  12993. */
  12994. setDirectionToTarget(target: Vector3): Vector3;
  12995. /**
  12996. * Returns the shadow generator associated to the light.
  12997. * @returns Always null for hemispheric lights because it does not support shadows.
  12998. */
  12999. getShadowGenerator(): Nullable<IShadowGenerator>;
  13000. /**
  13001. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13002. * @param effect The effect to update
  13003. * @param lightIndex The index of the light in the effect to update
  13004. * @returns The hemispheric light
  13005. */
  13006. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13007. /**
  13008. * Computes the world matrix of the node
  13009. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13010. * @param useWasUpdatedFlag defines a reserved property
  13011. * @returns the world matrix
  13012. */
  13013. computeWorldMatrix(): Matrix;
  13014. /**
  13015. * Returns the integer 3.
  13016. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13017. */
  13018. getTypeID(): number;
  13019. /**
  13020. * Prepares the list of defines specific to the light type.
  13021. * @param defines the list of defines
  13022. * @param lightIndex defines the index of the light for the effect
  13023. */
  13024. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13025. }
  13026. }
  13027. declare module BABYLON {
  13028. /**
  13029. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13030. * IMPORTANT!! The data is right-hand data.
  13031. * @export
  13032. * @interface DevicePose
  13033. */
  13034. export interface DevicePose {
  13035. /**
  13036. * The position of the device, values in array are [x,y,z].
  13037. */
  13038. readonly position: Nullable<Float32Array>;
  13039. /**
  13040. * The linearVelocity of the device, values in array are [x,y,z].
  13041. */
  13042. readonly linearVelocity: Nullable<Float32Array>;
  13043. /**
  13044. * The linearAcceleration of the device, values in array are [x,y,z].
  13045. */
  13046. readonly linearAcceleration: Nullable<Float32Array>;
  13047. /**
  13048. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13049. */
  13050. readonly orientation: Nullable<Float32Array>;
  13051. /**
  13052. * The angularVelocity of the device, values in array are [x,y,z].
  13053. */
  13054. readonly angularVelocity: Nullable<Float32Array>;
  13055. /**
  13056. * The angularAcceleration of the device, values in array are [x,y,z].
  13057. */
  13058. readonly angularAcceleration: Nullable<Float32Array>;
  13059. }
  13060. /**
  13061. * Interface representing a pose controlled object in Babylon.
  13062. * A pose controlled object has both regular pose values as well as pose values
  13063. * from an external device such as a VR head mounted display
  13064. */
  13065. export interface PoseControlled {
  13066. /**
  13067. * The position of the object in babylon space.
  13068. */
  13069. position: Vector3;
  13070. /**
  13071. * The rotation quaternion of the object in babylon space.
  13072. */
  13073. rotationQuaternion: Quaternion;
  13074. /**
  13075. * The position of the device in babylon space.
  13076. */
  13077. devicePosition?: Vector3;
  13078. /**
  13079. * The rotation quaternion of the device in babylon space.
  13080. */
  13081. deviceRotationQuaternion: Quaternion;
  13082. /**
  13083. * The raw pose coming from the device.
  13084. */
  13085. rawPose: Nullable<DevicePose>;
  13086. /**
  13087. * The scale of the device to be used when translating from device space to babylon space.
  13088. */
  13089. deviceScaleFactor: number;
  13090. /**
  13091. * Updates the poseControlled values based on the input device pose.
  13092. * @param poseData the pose data to update the object with
  13093. */
  13094. updateFromDevice(poseData: DevicePose): void;
  13095. }
  13096. /**
  13097. * Set of options to customize the webVRCamera
  13098. */
  13099. export interface WebVROptions {
  13100. /**
  13101. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13102. */
  13103. trackPosition?: boolean;
  13104. /**
  13105. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13106. */
  13107. positionScale?: number;
  13108. /**
  13109. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13110. */
  13111. displayName?: string;
  13112. /**
  13113. * Should the native controller meshes be initialized. (default: true)
  13114. */
  13115. controllerMeshes?: boolean;
  13116. /**
  13117. * Creating a default HemiLight only on controllers. (default: true)
  13118. */
  13119. defaultLightingOnControllers?: boolean;
  13120. /**
  13121. * If you don't want to use the default VR button of the helper. (default: false)
  13122. */
  13123. useCustomVRButton?: boolean;
  13124. /**
  13125. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13126. */
  13127. customVRButton?: HTMLButtonElement;
  13128. /**
  13129. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13130. */
  13131. rayLength?: number;
  13132. /**
  13133. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13134. */
  13135. defaultHeight?: number;
  13136. }
  13137. /**
  13138. * This represents a WebVR camera.
  13139. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13140. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13141. */
  13142. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13143. private webVROptions;
  13144. /**
  13145. * @hidden
  13146. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13147. */
  13148. _vrDevice: any;
  13149. /**
  13150. * The rawPose of the vrDevice.
  13151. */
  13152. rawPose: Nullable<DevicePose>;
  13153. private _onVREnabled;
  13154. private _specsVersion;
  13155. private _attached;
  13156. private _frameData;
  13157. protected _descendants: Array<Node>;
  13158. private _deviceRoomPosition;
  13159. /** @hidden */
  13160. _deviceRoomRotationQuaternion: Quaternion;
  13161. private _standingMatrix;
  13162. /**
  13163. * Represents device position in babylon space.
  13164. */
  13165. devicePosition: Vector3;
  13166. /**
  13167. * Represents device rotation in babylon space.
  13168. */
  13169. deviceRotationQuaternion: Quaternion;
  13170. /**
  13171. * The scale of the device to be used when translating from device space to babylon space.
  13172. */
  13173. deviceScaleFactor: number;
  13174. private _deviceToWorld;
  13175. private _worldToDevice;
  13176. /**
  13177. * References to the webVR controllers for the vrDevice.
  13178. */
  13179. controllers: Array<WebVRController>;
  13180. /**
  13181. * Emits an event when a controller is attached.
  13182. */
  13183. onControllersAttachedObservable: Observable<WebVRController[]>;
  13184. /**
  13185. * Emits an event when a controller's mesh has been loaded;
  13186. */
  13187. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13188. /**
  13189. * Emits an event when the HMD's pose has been updated.
  13190. */
  13191. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13192. private _poseSet;
  13193. /**
  13194. * If the rig cameras be used as parent instead of this camera.
  13195. */
  13196. rigParenting: boolean;
  13197. private _lightOnControllers;
  13198. private _defaultHeight?;
  13199. /**
  13200. * Instantiates a WebVRFreeCamera.
  13201. * @param name The name of the WebVRFreeCamera
  13202. * @param position The starting anchor position for the camera
  13203. * @param scene The scene the camera belongs to
  13204. * @param webVROptions a set of customizable options for the webVRCamera
  13205. */
  13206. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13207. /**
  13208. * Gets the device distance from the ground in meters.
  13209. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  13210. */
  13211. deviceDistanceToRoomGround(): number;
  13212. /**
  13213. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13214. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13215. */
  13216. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13217. /**
  13218. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13219. * @returns A promise with a boolean set to if the standing matrix is supported.
  13220. */
  13221. useStandingMatrixAsync(): Promise<boolean>;
  13222. /**
  13223. * Disposes the camera
  13224. */
  13225. dispose(): void;
  13226. /**
  13227. * Gets a vrController by name.
  13228. * @param name The name of the controller to retreive
  13229. * @returns the controller matching the name specified or null if not found
  13230. */
  13231. getControllerByName(name: string): Nullable<WebVRController>;
  13232. private _leftController;
  13233. /**
  13234. * The controller corrisponding to the users left hand.
  13235. */
  13236. readonly leftController: Nullable<WebVRController>;
  13237. private _rightController;
  13238. /**
  13239. * The controller corrisponding to the users right hand.
  13240. */
  13241. readonly rightController: Nullable<WebVRController>;
  13242. /**
  13243. * Casts a ray forward from the vrCamera's gaze.
  13244. * @param length Length of the ray (default: 100)
  13245. * @returns the ray corrisponding to the gaze
  13246. */
  13247. getForwardRay(length?: number): Ray;
  13248. /**
  13249. * @hidden
  13250. * Updates the camera based on device's frame data
  13251. */
  13252. _checkInputs(): void;
  13253. /**
  13254. * Updates the poseControlled values based on the input device pose.
  13255. * @param poseData Pose coming from the device
  13256. */
  13257. updateFromDevice(poseData: DevicePose): void;
  13258. private _htmlElementAttached;
  13259. private _detachIfAttached;
  13260. /**
  13261. * WebVR's attach control will start broadcasting frames to the device.
  13262. * Note that in certain browsers (chrome for example) this function must be called
  13263. * within a user-interaction callback. Example:
  13264. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13265. *
  13266. * @param element html element to attach the vrDevice to
  13267. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13268. */
  13269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13270. /**
  13271. * Detaches the camera from the html element and disables VR
  13272. *
  13273. * @param element html element to detach from
  13274. */
  13275. detachControl(element: HTMLElement): void;
  13276. /**
  13277. * @returns the name of this class
  13278. */
  13279. getClassName(): string;
  13280. /**
  13281. * Calls resetPose on the vrDisplay
  13282. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13283. */
  13284. resetToCurrentRotation(): void;
  13285. /**
  13286. * @hidden
  13287. * Updates the rig cameras (left and right eye)
  13288. */
  13289. _updateRigCameras(): void;
  13290. private _workingVector;
  13291. private _oneVector;
  13292. private _workingMatrix;
  13293. private updateCacheCalled;
  13294. private _correctPositionIfNotTrackPosition;
  13295. /**
  13296. * @hidden
  13297. * Updates the cached values of the camera
  13298. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13299. */
  13300. _updateCache(ignoreParentClass?: boolean): void;
  13301. /**
  13302. * @hidden
  13303. * Get current device position in babylon world
  13304. */
  13305. _computeDevicePosition(): void;
  13306. /**
  13307. * Updates the current device position and rotation in the babylon world
  13308. */
  13309. update(): void;
  13310. /**
  13311. * @hidden
  13312. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13313. * @returns an identity matrix
  13314. */
  13315. _getViewMatrix(): Matrix;
  13316. private _tmpMatrix;
  13317. /**
  13318. * This function is called by the two RIG cameras.
  13319. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13320. * @hidden
  13321. */
  13322. _getWebVRViewMatrix(): Matrix;
  13323. /** @hidden */
  13324. _getWebVRProjectionMatrix(): Matrix;
  13325. private _onGamepadConnectedObserver;
  13326. private _onGamepadDisconnectedObserver;
  13327. private _updateCacheWhenTrackingDisabledObserver;
  13328. /**
  13329. * Initializes the controllers and their meshes
  13330. */
  13331. initControllers(): void;
  13332. }
  13333. }
  13334. declare module BABYLON {
  13335. /**
  13336. * Size options for a post process
  13337. */
  13338. export type PostProcessOptions = {
  13339. width: number;
  13340. height: number;
  13341. };
  13342. /**
  13343. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13344. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13345. */
  13346. export class PostProcess {
  13347. /** Name of the PostProcess. */
  13348. name: string;
  13349. /**
  13350. * Width of the texture to apply the post process on
  13351. */
  13352. width: number;
  13353. /**
  13354. * Height of the texture to apply the post process on
  13355. */
  13356. height: number;
  13357. /**
  13358. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13359. * @hidden
  13360. */
  13361. _outputTexture: Nullable<InternalTexture>;
  13362. /**
  13363. * Sampling mode used by the shader
  13364. * See https://doc.babylonjs.com/classes/3.1/texture
  13365. */
  13366. renderTargetSamplingMode: number;
  13367. /**
  13368. * Clear color to use when screen clearing
  13369. */
  13370. clearColor: Color4;
  13371. /**
  13372. * If the buffer needs to be cleared before applying the post process. (default: true)
  13373. * Should be set to false if shader will overwrite all previous pixels.
  13374. */
  13375. autoClear: boolean;
  13376. /**
  13377. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13378. */
  13379. alphaMode: number;
  13380. /**
  13381. * Sets the setAlphaBlendConstants of the babylon engine
  13382. */
  13383. alphaConstants: Color4;
  13384. /**
  13385. * Animations to be used for the post processing
  13386. */
  13387. animations: Animation[];
  13388. /**
  13389. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13390. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13391. */
  13392. enablePixelPerfectMode: boolean;
  13393. /**
  13394. * Force the postprocess to be applied without taking in account viewport
  13395. */
  13396. forceFullscreenViewport: boolean;
  13397. /**
  13398. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13399. *
  13400. * | Value | Type | Description |
  13401. * | ----- | ----------------------------------- | ----------- |
  13402. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13403. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13404. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13405. *
  13406. */
  13407. scaleMode: number;
  13408. /**
  13409. * Force textures to be a power of two (default: false)
  13410. */
  13411. alwaysForcePOT: boolean;
  13412. private _samples;
  13413. /**
  13414. * Number of sample textures (default: 1)
  13415. */
  13416. samples: number;
  13417. /**
  13418. * Modify the scale of the post process to be the same as the viewport (default: false)
  13419. */
  13420. adaptScaleToCurrentViewport: boolean;
  13421. private _camera;
  13422. private _scene;
  13423. private _engine;
  13424. private _options;
  13425. private _reusable;
  13426. private _textureType;
  13427. /**
  13428. * Smart array of input and output textures for the post process.
  13429. * @hidden
  13430. */
  13431. _textures: SmartArray<InternalTexture>;
  13432. /**
  13433. * The index in _textures that corresponds to the output texture.
  13434. * @hidden
  13435. */
  13436. _currentRenderTextureInd: number;
  13437. private _effect;
  13438. private _samplers;
  13439. private _fragmentUrl;
  13440. private _vertexUrl;
  13441. private _parameters;
  13442. private _scaleRatio;
  13443. protected _indexParameters: any;
  13444. private _shareOutputWithPostProcess;
  13445. private _texelSize;
  13446. private _forcedOutputTexture;
  13447. /**
  13448. * Returns the fragment url or shader name used in the post process.
  13449. * @returns the fragment url or name in the shader store.
  13450. */
  13451. getEffectName(): string;
  13452. /**
  13453. * An event triggered when the postprocess is activated.
  13454. */
  13455. onActivateObservable: Observable<Camera>;
  13456. private _onActivateObserver;
  13457. /**
  13458. * A function that is added to the onActivateObservable
  13459. */
  13460. onActivate: Nullable<(camera: Camera) => void>;
  13461. /**
  13462. * An event triggered when the postprocess changes its size.
  13463. */
  13464. onSizeChangedObservable: Observable<PostProcess>;
  13465. private _onSizeChangedObserver;
  13466. /**
  13467. * A function that is added to the onSizeChangedObservable
  13468. */
  13469. onSizeChanged: (postProcess: PostProcess) => void;
  13470. /**
  13471. * An event triggered when the postprocess applies its effect.
  13472. */
  13473. onApplyObservable: Observable<Effect>;
  13474. private _onApplyObserver;
  13475. /**
  13476. * A function that is added to the onApplyObservable
  13477. */
  13478. onApply: (effect: Effect) => void;
  13479. /**
  13480. * An event triggered before rendering the postprocess
  13481. */
  13482. onBeforeRenderObservable: Observable<Effect>;
  13483. private _onBeforeRenderObserver;
  13484. /**
  13485. * A function that is added to the onBeforeRenderObservable
  13486. */
  13487. onBeforeRender: (effect: Effect) => void;
  13488. /**
  13489. * An event triggered after rendering the postprocess
  13490. */
  13491. onAfterRenderObservable: Observable<Effect>;
  13492. private _onAfterRenderObserver;
  13493. /**
  13494. * A function that is added to the onAfterRenderObservable
  13495. */
  13496. onAfterRender: (efect: Effect) => void;
  13497. /**
  13498. * 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
  13499. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13500. */
  13501. inputTexture: InternalTexture;
  13502. /**
  13503. * Gets the camera which post process is applied to.
  13504. * @returns The camera the post process is applied to.
  13505. */
  13506. getCamera(): Camera;
  13507. /**
  13508. * Gets the texel size of the postprocess.
  13509. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13510. */
  13511. readonly texelSize: Vector2;
  13512. /**
  13513. * Creates a new instance PostProcess
  13514. * @param name The name of the PostProcess.
  13515. * @param fragmentUrl The url of the fragment shader to be used.
  13516. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13517. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13518. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13519. * @param camera The camera to apply the render pass to.
  13520. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13521. * @param engine The engine which the post process will be applied. (default: current engine)
  13522. * @param reusable If the post process can be reused on the same frame. (default: false)
  13523. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13524. * @param textureType Type of textures used when performing the post process. (default: 0)
  13525. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13526. * @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
  13527. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13528. */
  13529. constructor(
  13530. /** Name of the PostProcess. */
  13531. 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);
  13532. /**
  13533. * Gets the engine which this post process belongs to.
  13534. * @returns The engine the post process was enabled with.
  13535. */
  13536. getEngine(): Engine;
  13537. /**
  13538. * The effect that is created when initializing the post process.
  13539. * @returns The created effect corrisponding the the postprocess.
  13540. */
  13541. getEffect(): Effect;
  13542. /**
  13543. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13544. * @param postProcess The post process to share the output with.
  13545. * @returns This post process.
  13546. */
  13547. shareOutputWith(postProcess: PostProcess): PostProcess;
  13548. /**
  13549. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13550. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13551. */
  13552. useOwnOutput(): void;
  13553. /**
  13554. * Updates the effect with the current post process compile time values and recompiles the shader.
  13555. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13556. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13557. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13558. * @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
  13559. * @param onCompiled Called when the shader has been compiled.
  13560. * @param onError Called if there is an error when compiling a shader.
  13561. */
  13562. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13563. /**
  13564. * The post process is reusable if it can be used multiple times within one frame.
  13565. * @returns If the post process is reusable
  13566. */
  13567. isReusable(): boolean;
  13568. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13569. markTextureDirty(): void;
  13570. /**
  13571. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13572. * 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.
  13573. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13574. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13575. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13576. * @returns The target texture that was bound to be written to.
  13577. */
  13578. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13579. /**
  13580. * If the post process is supported.
  13581. */
  13582. readonly isSupported: boolean;
  13583. /**
  13584. * The aspect ratio of the output texture.
  13585. */
  13586. readonly aspectRatio: number;
  13587. /**
  13588. * Get a value indicating if the post-process is ready to be used
  13589. * @returns true if the post-process is ready (shader is compiled)
  13590. */
  13591. isReady(): boolean;
  13592. /**
  13593. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13594. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13595. */
  13596. apply(): Nullable<Effect>;
  13597. private _disposeTextures;
  13598. /**
  13599. * Disposes the post process.
  13600. * @param camera The camera to dispose the post process on.
  13601. */
  13602. dispose(camera?: Camera): void;
  13603. }
  13604. }
  13605. declare module BABYLON {
  13606. /**
  13607. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13608. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13609. */
  13610. export class PostProcessManager {
  13611. private _scene;
  13612. private _indexBuffer;
  13613. private _vertexBuffers;
  13614. /**
  13615. * Creates a new instance PostProcess
  13616. * @param scene The scene that the post process is associated with.
  13617. */
  13618. constructor(scene: Scene);
  13619. private _prepareBuffers;
  13620. private _buildIndexBuffer;
  13621. /**
  13622. * Rebuilds the vertex buffers of the manager.
  13623. * @hidden
  13624. */
  13625. _rebuild(): void;
  13626. /**
  13627. * Prepares a frame to be run through a post process.
  13628. * @param sourceTexture The input texture to the post procesess. (default: null)
  13629. * @param postProcesses An array of post processes to be run. (default: null)
  13630. * @returns True if the post processes were able to be run.
  13631. * @hidden
  13632. */
  13633. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13634. /**
  13635. * Manually render a set of post processes to a texture.
  13636. * @param postProcesses An array of post processes to be run.
  13637. * @param targetTexture The target texture to render to.
  13638. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13639. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13640. * @param lodLevel defines which lod of the texture to render to
  13641. */
  13642. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13643. /**
  13644. * Finalize the result of the output of the postprocesses.
  13645. * @param doNotPresent If true the result will not be displayed to the screen.
  13646. * @param targetTexture The target texture to render to.
  13647. * @param faceIndex The index of the face to bind the target texture to.
  13648. * @param postProcesses The array of post processes to render.
  13649. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13650. * @hidden
  13651. */
  13652. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13653. /**
  13654. * Disposes of the post process manager.
  13655. */
  13656. dispose(): void;
  13657. }
  13658. }
  13659. declare module BABYLON {
  13660. /**
  13661. * Raw texture can help creating a texture directly from an array of data.
  13662. * This can be super useful if you either get the data from an uncompressed source or
  13663. * if you wish to create your texture pixel by pixel.
  13664. */
  13665. export class RawTexture extends Texture {
  13666. /**
  13667. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13668. */
  13669. format: number;
  13670. private _engine;
  13671. /**
  13672. * Instantiates a new RawTexture.
  13673. * Raw texture can help creating a texture directly from an array of data.
  13674. * This can be super useful if you either get the data from an uncompressed source or
  13675. * if you wish to create your texture pixel by pixel.
  13676. * @param data define the array of data to use to create the texture
  13677. * @param width define the width of the texture
  13678. * @param height define the height of the texture
  13679. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13680. * @param scene define the scene the texture belongs to
  13681. * @param generateMipMaps define whether mip maps should be generated or not
  13682. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13683. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13684. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13685. */
  13686. constructor(data: ArrayBufferView, width: number, height: number,
  13687. /**
  13688. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13689. */
  13690. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13691. /**
  13692. * Updates the texture underlying data.
  13693. * @param data Define the new data of the texture
  13694. */
  13695. update(data: ArrayBufferView): void;
  13696. /**
  13697. * Creates a luminance texture from some data.
  13698. * @param data Define the texture data
  13699. * @param width Define the width of the texture
  13700. * @param height Define the height of the texture
  13701. * @param scene Define the scene the texture belongs to
  13702. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13703. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13704. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13705. * @returns the luminance texture
  13706. */
  13707. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13708. /**
  13709. * Creates a luminance alpha texture from some data.
  13710. * @param data Define the texture data
  13711. * @param width Define the width of the texture
  13712. * @param height Define the height of the texture
  13713. * @param scene Define the scene the texture belongs to
  13714. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13715. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13716. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13717. * @returns the luminance alpha texture
  13718. */
  13719. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13720. /**
  13721. * Creates an alpha texture from some data.
  13722. * @param data Define the texture data
  13723. * @param width Define the width of the texture
  13724. * @param height Define the height of the texture
  13725. * @param scene Define the scene the texture belongs to
  13726. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13727. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13728. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13729. * @returns the alpha texture
  13730. */
  13731. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13732. /**
  13733. * Creates a RGB texture from some data.
  13734. * @param data Define the texture data
  13735. * @param width Define the width of the texture
  13736. * @param height Define the height of the texture
  13737. * @param scene Define the scene the texture belongs to
  13738. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13739. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13740. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13741. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13742. * @returns the RGB alpha texture
  13743. */
  13744. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13745. /**
  13746. * Creates a RGBA texture from some data.
  13747. * @param data Define the texture data
  13748. * @param width Define the width of the texture
  13749. * @param height Define the height of the texture
  13750. * @param scene Define the scene the texture belongs to
  13751. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13752. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13753. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13754. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13755. * @returns the RGBA texture
  13756. */
  13757. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13758. /**
  13759. * Creates a R texture from some data.
  13760. * @param data Define the texture data
  13761. * @param width Define the width of the texture
  13762. * @param height Define the height of the texture
  13763. * @param scene Define the scene the texture belongs to
  13764. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13765. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13766. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13767. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13768. * @returns the R texture
  13769. */
  13770. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13771. }
  13772. }
  13773. declare module BABYLON {
  13774. interface AbstractScene {
  13775. /**
  13776. * The list of layers (background and foreground) of the scene
  13777. */
  13778. layers: Array<Layer>;
  13779. }
  13780. /**
  13781. * Defines the layer scene component responsible to manage any layers
  13782. * in a given scene.
  13783. */
  13784. export class LayerSceneComponent implements ISceneComponent {
  13785. /**
  13786. * The component name helpfull to identify the component in the list of scene components.
  13787. */
  13788. readonly name: string;
  13789. /**
  13790. * The scene the component belongs to.
  13791. */
  13792. scene: Scene;
  13793. private _engine;
  13794. /**
  13795. * Creates a new instance of the component for the given scene
  13796. * @param scene Defines the scene to register the component in
  13797. */
  13798. constructor(scene: Scene);
  13799. /**
  13800. * Registers the component in a given scene
  13801. */
  13802. register(): void;
  13803. /**
  13804. * Rebuilds the elements related to this component in case of
  13805. * context lost for instance.
  13806. */
  13807. rebuild(): void;
  13808. /**
  13809. * Disposes the component and the associated ressources.
  13810. */
  13811. dispose(): void;
  13812. private _draw;
  13813. private _drawCameraPredicate;
  13814. private _drawCameraBackground;
  13815. private _drawCameraForeground;
  13816. private _drawRenderTargetPredicate;
  13817. private _drawRenderTargetBackground;
  13818. private _drawRenderTargetForeground;
  13819. }
  13820. }
  13821. declare module BABYLON {
  13822. /** @hidden */
  13823. export var layerPixelShader: {
  13824. name: string;
  13825. shader: string;
  13826. };
  13827. }
  13828. declare module BABYLON {
  13829. /** @hidden */
  13830. export var layerVertexShader: {
  13831. name: string;
  13832. shader: string;
  13833. };
  13834. }
  13835. declare module BABYLON {
  13836. /**
  13837. * This represents a full screen 2d layer.
  13838. * This can be useful to display a picture in the background of your scene for instance.
  13839. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13840. */
  13841. export class Layer {
  13842. /**
  13843. * Define the name of the layer.
  13844. */
  13845. name: string;
  13846. /**
  13847. * Define the texture the layer should display.
  13848. */
  13849. texture: Nullable<Texture>;
  13850. /**
  13851. * Is the layer in background or foreground.
  13852. */
  13853. isBackground: boolean;
  13854. /**
  13855. * Define the color of the layer (instead of texture).
  13856. */
  13857. color: Color4;
  13858. /**
  13859. * Define the scale of the layer in order to zoom in out of the texture.
  13860. */
  13861. scale: Vector2;
  13862. /**
  13863. * Define an offset for the layer in order to shift the texture.
  13864. */
  13865. offset: Vector2;
  13866. /**
  13867. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13868. */
  13869. alphaBlendingMode: number;
  13870. /**
  13871. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13872. * Alpha test will not mix with the background color in case of transparency.
  13873. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13874. */
  13875. alphaTest: boolean;
  13876. /**
  13877. * Define a mask to restrict the layer to only some of the scene cameras.
  13878. */
  13879. layerMask: number;
  13880. /**
  13881. * Define the list of render target the layer is visible into.
  13882. */
  13883. renderTargetTextures: RenderTargetTexture[];
  13884. /**
  13885. * Define if the layer is only used in renderTarget or if it also
  13886. * renders in the main frame buffer of the canvas.
  13887. */
  13888. renderOnlyInRenderTargetTextures: boolean;
  13889. private _scene;
  13890. private _vertexBuffers;
  13891. private _indexBuffer;
  13892. private _effect;
  13893. private _alphaTestEffect;
  13894. /**
  13895. * An event triggered when the layer is disposed.
  13896. */
  13897. onDisposeObservable: Observable<Layer>;
  13898. private _onDisposeObserver;
  13899. /**
  13900. * Back compatibility with callback before the onDisposeObservable existed.
  13901. * The set callback will be triggered when the layer has been disposed.
  13902. */
  13903. onDispose: () => void;
  13904. /**
  13905. * An event triggered before rendering the scene
  13906. */
  13907. onBeforeRenderObservable: Observable<Layer>;
  13908. private _onBeforeRenderObserver;
  13909. /**
  13910. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13911. * The set callback will be triggered just before rendering the layer.
  13912. */
  13913. onBeforeRender: () => void;
  13914. /**
  13915. * An event triggered after rendering the scene
  13916. */
  13917. onAfterRenderObservable: Observable<Layer>;
  13918. private _onAfterRenderObserver;
  13919. /**
  13920. * Back compatibility with callback before the onAfterRenderObservable existed.
  13921. * The set callback will be triggered just after rendering the layer.
  13922. */
  13923. onAfterRender: () => void;
  13924. /**
  13925. * Instantiates a new layer.
  13926. * This represents a full screen 2d layer.
  13927. * This can be useful to display a picture in the background of your scene for instance.
  13928. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13929. * @param name Define the name of the layer in the scene
  13930. * @param imgUrl Define the url of the texture to display in the layer
  13931. * @param scene Define the scene the layer belongs to
  13932. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13933. * @param color Defines a color for the layer
  13934. */
  13935. constructor(
  13936. /**
  13937. * Define the name of the layer.
  13938. */
  13939. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13940. private _createIndexBuffer;
  13941. /** @hidden */
  13942. _rebuild(): void;
  13943. /**
  13944. * Renders the layer in the scene.
  13945. */
  13946. render(): void;
  13947. /**
  13948. * Disposes and releases the associated ressources.
  13949. */
  13950. dispose(): void;
  13951. }
  13952. }
  13953. declare module BABYLON {
  13954. interface AbstractScene {
  13955. /**
  13956. * The list of procedural textures added to the scene
  13957. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13958. */
  13959. proceduralTextures: Array<ProceduralTexture>;
  13960. }
  13961. /**
  13962. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13963. * in a given scene.
  13964. */
  13965. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13966. /**
  13967. * The component name helpfull to identify the component in the list of scene components.
  13968. */
  13969. readonly name: string;
  13970. /**
  13971. * The scene the component belongs to.
  13972. */
  13973. scene: Scene;
  13974. /**
  13975. * Creates a new instance of the component for the given scene
  13976. * @param scene Defines the scene to register the component in
  13977. */
  13978. constructor(scene: Scene);
  13979. /**
  13980. * Registers the component in a given scene
  13981. */
  13982. register(): void;
  13983. /**
  13984. * Rebuilds the elements related to this component in case of
  13985. * context lost for instance.
  13986. */
  13987. rebuild(): void;
  13988. /**
  13989. * Disposes the component and the associated ressources.
  13990. */
  13991. dispose(): void;
  13992. private _beforeClear;
  13993. }
  13994. }
  13995. declare module BABYLON {
  13996. /** @hidden */
  13997. export var proceduralVertexShader: {
  13998. name: string;
  13999. shader: string;
  14000. };
  14001. }
  14002. declare module BABYLON {
  14003. /**
  14004. * 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.
  14005. * This is the base class of any Procedural texture and contains most of the shareable code.
  14006. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14007. */
  14008. export class ProceduralTexture extends Texture {
  14009. isCube: boolean;
  14010. /**
  14011. * Define if the texture is enabled or not (disabled texture will not render)
  14012. */
  14013. isEnabled: boolean;
  14014. /**
  14015. * Define if the texture must be cleared before rendering (default is true)
  14016. */
  14017. autoClear: boolean;
  14018. /**
  14019. * Callback called when the texture is generated
  14020. */
  14021. onGenerated: () => void;
  14022. /**
  14023. * Event raised when the texture is generated
  14024. */
  14025. onGeneratedObservable: Observable<ProceduralTexture>;
  14026. /** @hidden */
  14027. _generateMipMaps: boolean;
  14028. /** @hidden **/
  14029. _effect: Effect;
  14030. /** @hidden */
  14031. _textures: {
  14032. [key: string]: Texture;
  14033. };
  14034. private _size;
  14035. private _currentRefreshId;
  14036. private _refreshRate;
  14037. private _vertexBuffers;
  14038. private _indexBuffer;
  14039. private _uniforms;
  14040. private _samplers;
  14041. private _fragment;
  14042. private _floats;
  14043. private _ints;
  14044. private _floatsArrays;
  14045. private _colors3;
  14046. private _colors4;
  14047. private _vectors2;
  14048. private _vectors3;
  14049. private _matrices;
  14050. private _fallbackTexture;
  14051. private _fallbackTextureUsed;
  14052. private _engine;
  14053. private _cachedDefines;
  14054. private _contentUpdateId;
  14055. private _contentData;
  14056. /**
  14057. * Instantiates a new procedural texture.
  14058. * 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.
  14059. * This is the base class of any Procedural texture and contains most of the shareable code.
  14060. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14061. * @param name Define the name of the texture
  14062. * @param size Define the size of the texture to create
  14063. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14064. * @param scene Define the scene the texture belongs to
  14065. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14066. * @param generateMipMaps Define if the texture should creates mip maps or not
  14067. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14068. */
  14069. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14070. /**
  14071. * The effect that is created when initializing the post process.
  14072. * @returns The created effect corrisponding the the postprocess.
  14073. */
  14074. getEffect(): Effect;
  14075. /**
  14076. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14077. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14078. */
  14079. getContent(): Nullable<ArrayBufferView>;
  14080. private _createIndexBuffer;
  14081. /** @hidden */
  14082. _rebuild(): void;
  14083. /**
  14084. * Resets the texture in order to recreate its associated resources.
  14085. * This can be called in case of context loss
  14086. */
  14087. reset(): void;
  14088. protected _getDefines(): string;
  14089. /**
  14090. * Is the texture ready to be used ? (rendered at least once)
  14091. * @returns true if ready, otherwise, false.
  14092. */
  14093. isReady(): boolean;
  14094. /**
  14095. * Resets the refresh counter of the texture and start bak from scratch.
  14096. * Could be useful to regenerate the texture if it is setup to render only once.
  14097. */
  14098. resetRefreshCounter(): void;
  14099. /**
  14100. * Set the fragment shader to use in order to render the texture.
  14101. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14102. */
  14103. setFragment(fragment: any): void;
  14104. /**
  14105. * Define the refresh rate of the texture or the rendering frequency.
  14106. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14107. */
  14108. refreshRate: number;
  14109. /** @hidden */
  14110. _shouldRender(): boolean;
  14111. /**
  14112. * Get the size the texture is rendering at.
  14113. * @returns the size (texture is always squared)
  14114. */
  14115. getRenderSize(): number;
  14116. /**
  14117. * Resize the texture to new value.
  14118. * @param size Define the new size the texture should have
  14119. * @param generateMipMaps Define whether the new texture should create mip maps
  14120. */
  14121. resize(size: number, generateMipMaps: boolean): void;
  14122. private _checkUniform;
  14123. /**
  14124. * Set a texture in the shader program used to render.
  14125. * @param name Define the name of the uniform samplers as defined in the shader
  14126. * @param texture Define the texture to bind to this sampler
  14127. * @return the texture itself allowing "fluent" like uniform updates
  14128. */
  14129. setTexture(name: string, texture: Texture): ProceduralTexture;
  14130. /**
  14131. * Set a float in the shader.
  14132. * @param name Define the name of the uniform as defined in the shader
  14133. * @param value Define the value to give to the uniform
  14134. * @return the texture itself allowing "fluent" like uniform updates
  14135. */
  14136. setFloat(name: string, value: number): ProceduralTexture;
  14137. /**
  14138. * Set a int in the shader.
  14139. * @param name Define the name of the uniform as defined in the shader
  14140. * @param value Define the value to give to the uniform
  14141. * @return the texture itself allowing "fluent" like uniform updates
  14142. */
  14143. setInt(name: string, value: number): ProceduralTexture;
  14144. /**
  14145. * Set an array of floats in the shader.
  14146. * @param name Define the name of the uniform as defined in the shader
  14147. * @param value Define the value to give to the uniform
  14148. * @return the texture itself allowing "fluent" like uniform updates
  14149. */
  14150. setFloats(name: string, value: number[]): ProceduralTexture;
  14151. /**
  14152. * Set a vec3 in the shader from a Color3.
  14153. * @param name Define the name of the uniform as defined in the shader
  14154. * @param value Define the value to give to the uniform
  14155. * @return the texture itself allowing "fluent" like uniform updates
  14156. */
  14157. setColor3(name: string, value: Color3): ProceduralTexture;
  14158. /**
  14159. * Set a vec4 in the shader from a Color4.
  14160. * @param name Define the name of the uniform as defined in the shader
  14161. * @param value Define the value to give to the uniform
  14162. * @return the texture itself allowing "fluent" like uniform updates
  14163. */
  14164. setColor4(name: string, value: Color4): ProceduralTexture;
  14165. /**
  14166. * Set a vec2 in the shader from a Vector2.
  14167. * @param name Define the name of the uniform as defined in the shader
  14168. * @param value Define the value to give to the uniform
  14169. * @return the texture itself allowing "fluent" like uniform updates
  14170. */
  14171. setVector2(name: string, value: Vector2): ProceduralTexture;
  14172. /**
  14173. * Set a vec3 in the shader from a Vector3.
  14174. * @param name Define the name of the uniform as defined in the shader
  14175. * @param value Define the value to give to the uniform
  14176. * @return the texture itself allowing "fluent" like uniform updates
  14177. */
  14178. setVector3(name: string, value: Vector3): ProceduralTexture;
  14179. /**
  14180. * Set a mat4 in the shader from a MAtrix.
  14181. * @param name Define the name of the uniform as defined in the shader
  14182. * @param value Define the value to give to the uniform
  14183. * @return the texture itself allowing "fluent" like uniform updates
  14184. */
  14185. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14186. /**
  14187. * Render the texture to its associated render target.
  14188. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14189. */
  14190. render(useCameraPostProcess?: boolean): void;
  14191. /**
  14192. * Clone the texture.
  14193. * @returns the cloned texture
  14194. */
  14195. clone(): ProceduralTexture;
  14196. /**
  14197. * Dispose the texture and release its asoociated resources.
  14198. */
  14199. dispose(): void;
  14200. }
  14201. }
  14202. declare module BABYLON {
  14203. /**
  14204. * This represents the base class for particle system in Babylon.
  14205. * 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.
  14206. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14207. * @example https://doc.babylonjs.com/babylon101/particles
  14208. */
  14209. export class BaseParticleSystem {
  14210. /**
  14211. * Source color is added to the destination color without alpha affecting the result
  14212. */
  14213. static BLENDMODE_ONEONE: number;
  14214. /**
  14215. * Blend current color and particle color using particle’s alpha
  14216. */
  14217. static BLENDMODE_STANDARD: number;
  14218. /**
  14219. * Add current color and particle color multiplied by particle’s alpha
  14220. */
  14221. static BLENDMODE_ADD: number;
  14222. /**
  14223. * Multiply current color with particle color
  14224. */
  14225. static BLENDMODE_MULTIPLY: number;
  14226. /**
  14227. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14228. */
  14229. static BLENDMODE_MULTIPLYADD: number;
  14230. /**
  14231. * List of animations used by the particle system.
  14232. */
  14233. animations: Animation[];
  14234. /**
  14235. * The id of the Particle system.
  14236. */
  14237. id: string;
  14238. /**
  14239. * The friendly name of the Particle system.
  14240. */
  14241. name: string;
  14242. /**
  14243. * The rendering group used by the Particle system to chose when to render.
  14244. */
  14245. renderingGroupId: number;
  14246. /**
  14247. * The emitter represents the Mesh or position we are attaching the particle system to.
  14248. */
  14249. emitter: Nullable<AbstractMesh | Vector3>;
  14250. /**
  14251. * The maximum number of particles to emit per frame
  14252. */
  14253. emitRate: number;
  14254. /**
  14255. * If you want to launch only a few particles at once, that can be done, as well.
  14256. */
  14257. manualEmitCount: number;
  14258. /**
  14259. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14260. */
  14261. updateSpeed: number;
  14262. /**
  14263. * The amount of time the particle system is running (depends of the overall update speed).
  14264. */
  14265. targetStopDuration: number;
  14266. /**
  14267. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14268. */
  14269. disposeOnStop: boolean;
  14270. /**
  14271. * Minimum power of emitting particles.
  14272. */
  14273. minEmitPower: number;
  14274. /**
  14275. * Maximum power of emitting particles.
  14276. */
  14277. maxEmitPower: number;
  14278. /**
  14279. * Minimum life time of emitting particles.
  14280. */
  14281. minLifeTime: number;
  14282. /**
  14283. * Maximum life time of emitting particles.
  14284. */
  14285. maxLifeTime: number;
  14286. /**
  14287. * Minimum Size of emitting particles.
  14288. */
  14289. minSize: number;
  14290. /**
  14291. * Maximum Size of emitting particles.
  14292. */
  14293. maxSize: number;
  14294. /**
  14295. * Minimum scale of emitting particles on X axis.
  14296. */
  14297. minScaleX: number;
  14298. /**
  14299. * Maximum scale of emitting particles on X axis.
  14300. */
  14301. maxScaleX: number;
  14302. /**
  14303. * Minimum scale of emitting particles on Y axis.
  14304. */
  14305. minScaleY: number;
  14306. /**
  14307. * Maximum scale of emitting particles on Y axis.
  14308. */
  14309. maxScaleY: number;
  14310. /**
  14311. * Gets or sets the minimal initial rotation in radians.
  14312. */
  14313. minInitialRotation: number;
  14314. /**
  14315. * Gets or sets the maximal initial rotation in radians.
  14316. */
  14317. maxInitialRotation: number;
  14318. /**
  14319. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14320. */
  14321. minAngularSpeed: number;
  14322. /**
  14323. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14324. */
  14325. maxAngularSpeed: number;
  14326. /**
  14327. * The texture used to render each particle. (this can be a spritesheet)
  14328. */
  14329. particleTexture: Nullable<Texture>;
  14330. /**
  14331. * The layer mask we are rendering the particles through.
  14332. */
  14333. layerMask: number;
  14334. /**
  14335. * This can help using your own shader to render the particle system.
  14336. * The according effect will be created
  14337. */
  14338. customShader: any;
  14339. /**
  14340. * By default particle system starts as soon as they are created. This prevents the
  14341. * automatic start to happen and let you decide when to start emitting particles.
  14342. */
  14343. preventAutoStart: boolean;
  14344. private _noiseTexture;
  14345. /**
  14346. * Gets or sets a texture used to add random noise to particle positions
  14347. */
  14348. noiseTexture: Nullable<ProceduralTexture>;
  14349. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14350. noiseStrength: Vector3;
  14351. /**
  14352. * Callback triggered when the particle animation is ending.
  14353. */
  14354. onAnimationEnd: Nullable<() => void>;
  14355. /**
  14356. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14357. */
  14358. blendMode: number;
  14359. /**
  14360. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14361. * to override the particles.
  14362. */
  14363. forceDepthWrite: boolean;
  14364. /** 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 */
  14365. preWarmCycles: number;
  14366. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14367. preWarmStepOffset: number;
  14368. /**
  14369. * 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)
  14370. */
  14371. spriteCellChangeSpeed: number;
  14372. /**
  14373. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14374. */
  14375. startSpriteCellID: number;
  14376. /**
  14377. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14378. */
  14379. endSpriteCellID: number;
  14380. /**
  14381. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14382. */
  14383. spriteCellWidth: number;
  14384. /**
  14385. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14386. */
  14387. spriteCellHeight: number;
  14388. /**
  14389. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14390. */
  14391. spriteRandomStartCell: boolean;
  14392. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14393. translationPivot: Vector2;
  14394. /** @hidden */
  14395. protected _isAnimationSheetEnabled: boolean;
  14396. /**
  14397. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14398. */
  14399. beginAnimationOnStart: boolean;
  14400. /**
  14401. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14402. */
  14403. beginAnimationFrom: number;
  14404. /**
  14405. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14406. */
  14407. beginAnimationTo: number;
  14408. /**
  14409. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14410. */
  14411. beginAnimationLoop: boolean;
  14412. /**
  14413. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14414. */
  14415. isAnimationSheetEnabled: boolean;
  14416. /**
  14417. * Get hosting scene
  14418. * @returns the scene
  14419. */
  14420. getScene(): Scene;
  14421. /**
  14422. * You can use gravity if you want to give an orientation to your particles.
  14423. */
  14424. gravity: Vector3;
  14425. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14426. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14427. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14428. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14429. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14430. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14431. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14432. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14433. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14434. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14435. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14436. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14437. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14438. /**
  14439. * Defines the delay in milliseconds before starting the system (0 by default)
  14440. */
  14441. startDelay: number;
  14442. /**
  14443. * Gets the current list of drag gradients.
  14444. * You must use addDragGradient and removeDragGradient to udpate this list
  14445. * @returns the list of drag gradients
  14446. */
  14447. getDragGradients(): Nullable<Array<FactorGradient>>;
  14448. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14449. limitVelocityDamping: number;
  14450. /**
  14451. * Gets the current list of limit velocity gradients.
  14452. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14453. * @returns the list of limit velocity gradients
  14454. */
  14455. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14456. /**
  14457. * Gets the current list of color gradients.
  14458. * You must use addColorGradient and removeColorGradient to udpate this list
  14459. * @returns the list of color gradients
  14460. */
  14461. getColorGradients(): Nullable<Array<ColorGradient>>;
  14462. /**
  14463. * Gets the current list of size gradients.
  14464. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14465. * @returns the list of size gradients
  14466. */
  14467. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14468. /**
  14469. * Gets the current list of color remap gradients.
  14470. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14471. * @returns the list of color remap gradients
  14472. */
  14473. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14474. /**
  14475. * Gets the current list of alpha remap gradients.
  14476. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14477. * @returns the list of alpha remap gradients
  14478. */
  14479. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14480. /**
  14481. * Gets the current list of life time gradients.
  14482. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14483. * @returns the list of life time gradients
  14484. */
  14485. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14486. /**
  14487. * Gets the current list of angular speed gradients.
  14488. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14489. * @returns the list of angular speed gradients
  14490. */
  14491. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14492. /**
  14493. * Gets the current list of velocity gradients.
  14494. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14495. * @returns the list of velocity gradients
  14496. */
  14497. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14498. /**
  14499. * Gets the current list of start size gradients.
  14500. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14501. * @returns the list of start size gradients
  14502. */
  14503. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14504. /**
  14505. * Gets the current list of emit rate gradients.
  14506. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14507. * @returns the list of emit rate gradients
  14508. */
  14509. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14510. /**
  14511. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14512. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14513. */
  14514. direction1: Vector3;
  14515. /**
  14516. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14517. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14518. */
  14519. direction2: Vector3;
  14520. /**
  14521. * 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.
  14522. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14523. */
  14524. minEmitBox: Vector3;
  14525. /**
  14526. * 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.
  14527. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14528. */
  14529. maxEmitBox: Vector3;
  14530. /**
  14531. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14532. */
  14533. color1: Color4;
  14534. /**
  14535. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14536. */
  14537. color2: Color4;
  14538. /**
  14539. * Color the particle will have at the end of its lifetime
  14540. */
  14541. colorDead: Color4;
  14542. /**
  14543. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14544. */
  14545. textureMask: Color4;
  14546. /**
  14547. * The particle emitter type defines the emitter used by the particle system.
  14548. * It can be for example box, sphere, or cone...
  14549. */
  14550. particleEmitterType: IParticleEmitterType;
  14551. /** @hidden */
  14552. _isSubEmitter: boolean;
  14553. /**
  14554. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14555. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14556. */
  14557. billboardMode: number;
  14558. protected _isBillboardBased: boolean;
  14559. /**
  14560. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14561. */
  14562. isBillboardBased: boolean;
  14563. /**
  14564. * The scene the particle system belongs to.
  14565. */
  14566. protected _scene: Scene;
  14567. /**
  14568. * Local cache of defines for image processing.
  14569. */
  14570. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14571. /**
  14572. * Default configuration related to image processing available in the standard Material.
  14573. */
  14574. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14575. /**
  14576. * Gets the image processing configuration used either in this material.
  14577. */
  14578. /**
  14579. * Sets the Default image processing configuration used either in the this material.
  14580. *
  14581. * If sets to null, the scene one is in use.
  14582. */
  14583. imageProcessingConfiguration: ImageProcessingConfiguration;
  14584. /**
  14585. * Attaches a new image processing configuration to the Standard Material.
  14586. * @param configuration
  14587. */
  14588. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14589. /** @hidden */
  14590. protected _reset(): void;
  14591. /** @hidden */
  14592. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14593. /**
  14594. * Instantiates a particle system.
  14595. * 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.
  14596. * @param name The name of the particle system
  14597. */
  14598. constructor(name: string);
  14599. /**
  14600. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14601. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14602. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14603. * @returns the emitter
  14604. */
  14605. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14606. /**
  14607. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14608. * @param radius The radius of the hemisphere to emit from
  14609. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14610. * @returns the emitter
  14611. */
  14612. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14613. /**
  14614. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14615. * @param radius The radius of the sphere to emit from
  14616. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14617. * @returns the emitter
  14618. */
  14619. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14620. /**
  14621. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14622. * @param radius The radius of the sphere to emit from
  14623. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14624. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14625. * @returns the emitter
  14626. */
  14627. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14628. /**
  14629. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14630. * @param radius The radius of the emission cylinder
  14631. * @param height The height of the emission cylinder
  14632. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14633. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14634. * @returns the emitter
  14635. */
  14636. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14637. /**
  14638. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14639. * @param radius The radius of the cylinder to emit from
  14640. * @param height The height of the emission cylinder
  14641. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14642. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14643. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14644. * @returns the emitter
  14645. */
  14646. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14647. /**
  14648. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14649. * @param radius The radius of the cone to emit from
  14650. * @param angle The base angle of the cone
  14651. * @returns the emitter
  14652. */
  14653. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14654. /**
  14655. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14656. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14657. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14658. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14659. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14660. * @returns the emitter
  14661. */
  14662. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14663. }
  14664. }
  14665. declare module BABYLON {
  14666. /**
  14667. * Type of sub emitter
  14668. */
  14669. export enum SubEmitterType {
  14670. /**
  14671. * Attached to the particle over it's lifetime
  14672. */
  14673. ATTACHED = 0,
  14674. /**
  14675. * Created when the particle dies
  14676. */
  14677. END = 1
  14678. }
  14679. /**
  14680. * Sub emitter class used to emit particles from an existing particle
  14681. */
  14682. export class SubEmitter {
  14683. /**
  14684. * the particle system to be used by the sub emitter
  14685. */
  14686. particleSystem: ParticleSystem;
  14687. /**
  14688. * Type of the submitter (Default: END)
  14689. */
  14690. type: SubEmitterType;
  14691. /**
  14692. * 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)
  14693. * Note: This only is supported when using an emitter of type Mesh
  14694. */
  14695. inheritDirection: boolean;
  14696. /**
  14697. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14698. */
  14699. inheritedVelocityAmount: number;
  14700. /**
  14701. * Creates a sub emitter
  14702. * @param particleSystem the particle system to be used by the sub emitter
  14703. */
  14704. constructor(
  14705. /**
  14706. * the particle system to be used by the sub emitter
  14707. */
  14708. particleSystem: ParticleSystem);
  14709. /**
  14710. * Clones the sub emitter
  14711. * @returns the cloned sub emitter
  14712. */
  14713. clone(): SubEmitter;
  14714. /**
  14715. * Serialize current object to a JSON object
  14716. * @returns the serialized object
  14717. */
  14718. serialize(): any;
  14719. /** @hidden */
  14720. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14721. /**
  14722. * Creates a new SubEmitter from a serialized JSON version
  14723. * @param serializationObject defines the JSON object to read from
  14724. * @param scene defines the hosting scene
  14725. * @param rootUrl defines the rootUrl for data loading
  14726. * @returns a new SubEmitter
  14727. */
  14728. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14729. /** Release associated resources */
  14730. dispose(): void;
  14731. }
  14732. }
  14733. declare module BABYLON {
  14734. /** @hidden */
  14735. export var clipPlaneFragmentDeclaration: {
  14736. name: string;
  14737. shader: string;
  14738. };
  14739. }
  14740. declare module BABYLON {
  14741. /** @hidden */
  14742. export var imageProcessingDeclaration: {
  14743. name: string;
  14744. shader: string;
  14745. };
  14746. }
  14747. declare module BABYLON {
  14748. /** @hidden */
  14749. export var imageProcessingFunctions: {
  14750. name: string;
  14751. shader: string;
  14752. };
  14753. }
  14754. declare module BABYLON {
  14755. /** @hidden */
  14756. export var clipPlaneFragment: {
  14757. name: string;
  14758. shader: string;
  14759. };
  14760. }
  14761. declare module BABYLON {
  14762. /** @hidden */
  14763. export var particlesPixelShader: {
  14764. name: string;
  14765. shader: string;
  14766. };
  14767. }
  14768. declare module BABYLON {
  14769. /** @hidden */
  14770. export var clipPlaneVertexDeclaration: {
  14771. name: string;
  14772. shader: string;
  14773. };
  14774. }
  14775. declare module BABYLON {
  14776. /** @hidden */
  14777. export var clipPlaneVertex: {
  14778. name: string;
  14779. shader: string;
  14780. };
  14781. }
  14782. declare module BABYLON {
  14783. /** @hidden */
  14784. export var particlesVertexShader: {
  14785. name: string;
  14786. shader: string;
  14787. };
  14788. }
  14789. declare module BABYLON {
  14790. /**
  14791. * This represents a particle system in Babylon.
  14792. * 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.
  14793. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14794. * @example https://doc.babylonjs.com/babylon101/particles
  14795. */
  14796. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14797. /**
  14798. * Billboard mode will only apply to Y axis
  14799. */
  14800. static readonly BILLBOARDMODE_Y: number;
  14801. /**
  14802. * Billboard mode will apply to all axes
  14803. */
  14804. static readonly BILLBOARDMODE_ALL: number;
  14805. /**
  14806. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14807. */
  14808. static readonly BILLBOARDMODE_STRETCHED: number;
  14809. /**
  14810. * This function can be defined to provide custom update for active particles.
  14811. * This function will be called instead of regular update (age, position, color, etc.).
  14812. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14813. */
  14814. updateFunction: (particles: Particle[]) => void;
  14815. private _emitterWorldMatrix;
  14816. /**
  14817. * This function can be defined to specify initial direction for every new particle.
  14818. * It by default use the emitterType defined function
  14819. */
  14820. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14821. /**
  14822. * This function can be defined to specify initial position for every new particle.
  14823. * It by default use the emitterType defined function
  14824. */
  14825. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14826. /**
  14827. * @hidden
  14828. */
  14829. _inheritedVelocityOffset: Vector3;
  14830. /**
  14831. * An event triggered when the system is disposed
  14832. */
  14833. onDisposeObservable: Observable<ParticleSystem>;
  14834. private _onDisposeObserver;
  14835. /**
  14836. * Sets a callback that will be triggered when the system is disposed
  14837. */
  14838. onDispose: () => void;
  14839. private _particles;
  14840. private _epsilon;
  14841. private _capacity;
  14842. private _stockParticles;
  14843. private _newPartsExcess;
  14844. private _vertexData;
  14845. private _vertexBuffer;
  14846. private _vertexBuffers;
  14847. private _spriteBuffer;
  14848. private _indexBuffer;
  14849. private _effect;
  14850. private _customEffect;
  14851. private _cachedDefines;
  14852. private _scaledColorStep;
  14853. private _colorDiff;
  14854. private _scaledDirection;
  14855. private _scaledGravity;
  14856. private _currentRenderId;
  14857. private _alive;
  14858. private _useInstancing;
  14859. private _started;
  14860. private _stopped;
  14861. private _actualFrame;
  14862. private _scaledUpdateSpeed;
  14863. private _vertexBufferSize;
  14864. /** @hidden */
  14865. _currentEmitRateGradient: Nullable<FactorGradient>;
  14866. /** @hidden */
  14867. _currentEmitRate1: number;
  14868. /** @hidden */
  14869. _currentEmitRate2: number;
  14870. /** @hidden */
  14871. _currentStartSizeGradient: Nullable<FactorGradient>;
  14872. /** @hidden */
  14873. _currentStartSize1: number;
  14874. /** @hidden */
  14875. _currentStartSize2: number;
  14876. private readonly _rawTextureWidth;
  14877. private _rampGradientsTexture;
  14878. private _useRampGradients;
  14879. /** Gets or sets a boolean indicating that ramp gradients must be used
  14880. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14881. */
  14882. useRampGradients: boolean;
  14883. /**
  14884. * 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.
  14885. * 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: [])
  14886. */
  14887. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14888. private _subEmitters;
  14889. /**
  14890. * @hidden
  14891. * If the particle systems emitter should be disposed when the particle system is disposed
  14892. */
  14893. _disposeEmitterOnDispose: boolean;
  14894. /**
  14895. * The current active Sub-systems, this property is used by the root particle system only.
  14896. */
  14897. activeSubSystems: Array<ParticleSystem>;
  14898. private _rootParticleSystem;
  14899. /**
  14900. * Gets the current list of active particles
  14901. */
  14902. readonly particles: Particle[];
  14903. /**
  14904. * Returns the string "ParticleSystem"
  14905. * @returns a string containing the class name
  14906. */
  14907. getClassName(): string;
  14908. /**
  14909. * Instantiates a particle system.
  14910. * 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.
  14911. * @param name The name of the particle system
  14912. * @param capacity The max number of particles alive at the same time
  14913. * @param scene The scene the particle system belongs to
  14914. * @param customEffect a custom effect used to change the way particles are rendered by default
  14915. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14916. * @param epsilon Offset used to render the particles
  14917. */
  14918. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14919. private _addFactorGradient;
  14920. private _removeFactorGradient;
  14921. /**
  14922. * Adds a new life time gradient
  14923. * @param gradient defines the gradient to use (between 0 and 1)
  14924. * @param factor defines the life time factor to affect to the specified gradient
  14925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14926. * @returns the current particle system
  14927. */
  14928. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14929. /**
  14930. * Remove a specific life time gradient
  14931. * @param gradient defines the gradient to remove
  14932. * @returns the current particle system
  14933. */
  14934. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14935. /**
  14936. * Adds a new size gradient
  14937. * @param gradient defines the gradient to use (between 0 and 1)
  14938. * @param factor defines the size factor to affect to the specified gradient
  14939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14940. * @returns the current particle system
  14941. */
  14942. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14943. /**
  14944. * Remove a specific size gradient
  14945. * @param gradient defines the gradient to remove
  14946. * @returns the current particle system
  14947. */
  14948. removeSizeGradient(gradient: number): IParticleSystem;
  14949. /**
  14950. * Adds a new color remap gradient
  14951. * @param gradient defines the gradient to use (between 0 and 1)
  14952. * @param min defines the color remap minimal range
  14953. * @param max defines the color remap maximal range
  14954. * @returns the current particle system
  14955. */
  14956. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14957. /**
  14958. * Remove a specific color remap gradient
  14959. * @param gradient defines the gradient to remove
  14960. * @returns the current particle system
  14961. */
  14962. removeColorRemapGradient(gradient: number): IParticleSystem;
  14963. /**
  14964. * Adds a new alpha remap gradient
  14965. * @param gradient defines the gradient to use (between 0 and 1)
  14966. * @param min defines the alpha remap minimal range
  14967. * @param max defines the alpha remap maximal range
  14968. * @returns the current particle system
  14969. */
  14970. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14971. /**
  14972. * Remove a specific alpha remap gradient
  14973. * @param gradient defines the gradient to remove
  14974. * @returns the current particle system
  14975. */
  14976. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14977. /**
  14978. * Adds a new angular speed gradient
  14979. * @param gradient defines the gradient to use (between 0 and 1)
  14980. * @param factor defines the angular speed to affect to the specified gradient
  14981. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14982. * @returns the current particle system
  14983. */
  14984. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14985. /**
  14986. * Remove a specific angular speed gradient
  14987. * @param gradient defines the gradient to remove
  14988. * @returns the current particle system
  14989. */
  14990. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14991. /**
  14992. * Adds a new velocity gradient
  14993. * @param gradient defines the gradient to use (between 0 and 1)
  14994. * @param factor defines the velocity to affect to the specified gradient
  14995. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14996. * @returns the current particle system
  14997. */
  14998. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14999. /**
  15000. * Remove a specific velocity gradient
  15001. * @param gradient defines the gradient to remove
  15002. * @returns the current particle system
  15003. */
  15004. removeVelocityGradient(gradient: number): IParticleSystem;
  15005. /**
  15006. * Adds a new limit velocity gradient
  15007. * @param gradient defines the gradient to use (between 0 and 1)
  15008. * @param factor defines the limit velocity value to affect to the specified gradient
  15009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15010. * @returns the current particle system
  15011. */
  15012. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15013. /**
  15014. * Remove a specific limit velocity gradient
  15015. * @param gradient defines the gradient to remove
  15016. * @returns the current particle system
  15017. */
  15018. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15019. /**
  15020. * Adds a new drag gradient
  15021. * @param gradient defines the gradient to use (between 0 and 1)
  15022. * @param factor defines the drag value to affect to the specified gradient
  15023. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15024. * @returns the current particle system
  15025. */
  15026. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15027. /**
  15028. * Remove a specific drag gradient
  15029. * @param gradient defines the gradient to remove
  15030. * @returns the current particle system
  15031. */
  15032. removeDragGradient(gradient: number): IParticleSystem;
  15033. /**
  15034. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15035. * @param gradient defines the gradient to use (between 0 and 1)
  15036. * @param factor defines the emit rate value to affect to the specified gradient
  15037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15038. * @returns the current particle system
  15039. */
  15040. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15041. /**
  15042. * Remove a specific emit rate gradient
  15043. * @param gradient defines the gradient to remove
  15044. * @returns the current particle system
  15045. */
  15046. removeEmitRateGradient(gradient: number): IParticleSystem;
  15047. /**
  15048. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15049. * @param gradient defines the gradient to use (between 0 and 1)
  15050. * @param factor defines the start size value to affect to the specified gradient
  15051. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15052. * @returns the current particle system
  15053. */
  15054. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15055. /**
  15056. * Remove a specific start size gradient
  15057. * @param gradient defines the gradient to remove
  15058. * @returns the current particle system
  15059. */
  15060. removeStartSizeGradient(gradient: number): IParticleSystem;
  15061. private _createRampGradientTexture;
  15062. /**
  15063. * Gets the current list of ramp gradients.
  15064. * You must use addRampGradient and removeRampGradient to udpate this list
  15065. * @returns the list of ramp gradients
  15066. */
  15067. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15068. /**
  15069. * Adds a new ramp gradient used to remap particle colors
  15070. * @param gradient defines the gradient to use (between 0 and 1)
  15071. * @param color defines the color to affect to the specified gradient
  15072. * @returns the current particle system
  15073. */
  15074. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15075. /**
  15076. * Remove a specific ramp gradient
  15077. * @param gradient defines the gradient to remove
  15078. * @returns the current particle system
  15079. */
  15080. removeRampGradient(gradient: number): ParticleSystem;
  15081. /**
  15082. * Adds a new color gradient
  15083. * @param gradient defines the gradient to use (between 0 and 1)
  15084. * @param color1 defines the color to affect to the specified gradient
  15085. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15086. * @returns this particle system
  15087. */
  15088. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15089. /**
  15090. * Remove a specific color gradient
  15091. * @param gradient defines the gradient to remove
  15092. * @returns this particle system
  15093. */
  15094. removeColorGradient(gradient: number): IParticleSystem;
  15095. private _fetchR;
  15096. protected _reset(): void;
  15097. private _resetEffect;
  15098. private _createVertexBuffers;
  15099. private _createIndexBuffer;
  15100. /**
  15101. * Gets the maximum number of particles active at the same time.
  15102. * @returns The max number of active particles.
  15103. */
  15104. getCapacity(): number;
  15105. /**
  15106. * Gets whether there are still active particles in the system.
  15107. * @returns True if it is alive, otherwise false.
  15108. */
  15109. isAlive(): boolean;
  15110. /**
  15111. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15112. * @returns True if it has been started, otherwise false.
  15113. */
  15114. isStarted(): boolean;
  15115. private _prepareSubEmitterInternalArray;
  15116. /**
  15117. * Starts the particle system and begins to emit
  15118. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15119. */
  15120. start(delay?: number): void;
  15121. /**
  15122. * Stops the particle system.
  15123. * @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.
  15124. */
  15125. stop(stopSubEmitters?: boolean): void;
  15126. /**
  15127. * Remove all active particles
  15128. */
  15129. reset(): void;
  15130. /**
  15131. * @hidden (for internal use only)
  15132. */
  15133. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15134. /**
  15135. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15136. * Its lifetime will start back at 0.
  15137. */
  15138. recycleParticle: (particle: Particle) => void;
  15139. private _stopSubEmitters;
  15140. private _createParticle;
  15141. private _removeFromRoot;
  15142. private _emitFromParticle;
  15143. private _update;
  15144. /** @hidden */
  15145. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15146. /** @hidden */
  15147. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15148. /** @hidden */
  15149. private _getEffect;
  15150. /**
  15151. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15152. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15153. */
  15154. animate(preWarmOnly?: boolean): void;
  15155. private _appendParticleVertices;
  15156. /**
  15157. * Rebuilds the particle system.
  15158. */
  15159. rebuild(): void;
  15160. /**
  15161. * Is this system ready to be used/rendered
  15162. * @return true if the system is ready
  15163. */
  15164. isReady(): boolean;
  15165. private _render;
  15166. /**
  15167. * Renders the particle system in its current state.
  15168. * @returns the current number of particles
  15169. */
  15170. render(): number;
  15171. /**
  15172. * Disposes the particle system and free the associated resources
  15173. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15174. */
  15175. dispose(disposeTexture?: boolean): void;
  15176. /**
  15177. * Clones the particle system.
  15178. * @param name The name of the cloned object
  15179. * @param newEmitter The new emitter to use
  15180. * @returns the cloned particle system
  15181. */
  15182. clone(name: string, newEmitter: any): ParticleSystem;
  15183. /**
  15184. * Serializes the particle system to a JSON object.
  15185. * @returns the JSON object
  15186. */
  15187. serialize(): any;
  15188. /** @hidden */
  15189. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15190. /** @hidden */
  15191. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15192. /**
  15193. * Parses a JSON object to create a particle system.
  15194. * @param parsedParticleSystem The JSON object to parse
  15195. * @param scene The scene to create the particle system in
  15196. * @param rootUrl The root url to use to load external dependencies like texture
  15197. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15198. * @returns the Parsed particle system
  15199. */
  15200. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15201. }
  15202. }
  15203. declare module BABYLON {
  15204. /**
  15205. * A particle represents one of the element emitted by a particle system.
  15206. * This is mainly define by its coordinates, direction, velocity and age.
  15207. */
  15208. export class Particle {
  15209. /**
  15210. * The particle system the particle belongs to.
  15211. */
  15212. particleSystem: ParticleSystem;
  15213. private static _Count;
  15214. /**
  15215. * Unique ID of the particle
  15216. */
  15217. id: number;
  15218. /**
  15219. * The world position of the particle in the scene.
  15220. */
  15221. position: Vector3;
  15222. /**
  15223. * The world direction of the particle in the scene.
  15224. */
  15225. direction: Vector3;
  15226. /**
  15227. * The color of the particle.
  15228. */
  15229. color: Color4;
  15230. /**
  15231. * The color change of the particle per step.
  15232. */
  15233. colorStep: Color4;
  15234. /**
  15235. * Defines how long will the life of the particle be.
  15236. */
  15237. lifeTime: number;
  15238. /**
  15239. * The current age of the particle.
  15240. */
  15241. age: number;
  15242. /**
  15243. * The current size of the particle.
  15244. */
  15245. size: number;
  15246. /**
  15247. * The current scale of the particle.
  15248. */
  15249. scale: Vector2;
  15250. /**
  15251. * The current angle of the particle.
  15252. */
  15253. angle: number;
  15254. /**
  15255. * Defines how fast is the angle changing.
  15256. */
  15257. angularSpeed: number;
  15258. /**
  15259. * Defines the cell index used by the particle to be rendered from a sprite.
  15260. */
  15261. cellIndex: number;
  15262. /**
  15263. * The information required to support color remapping
  15264. */
  15265. remapData: Vector4;
  15266. /** @hidden */
  15267. _randomCellOffset?: number;
  15268. /** @hidden */
  15269. _initialDirection: Nullable<Vector3>;
  15270. /** @hidden */
  15271. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15272. /** @hidden */
  15273. _initialStartSpriteCellID: number;
  15274. /** @hidden */
  15275. _initialEndSpriteCellID: number;
  15276. /** @hidden */
  15277. _currentColorGradient: Nullable<ColorGradient>;
  15278. /** @hidden */
  15279. _currentColor1: Color4;
  15280. /** @hidden */
  15281. _currentColor2: Color4;
  15282. /** @hidden */
  15283. _currentSizeGradient: Nullable<FactorGradient>;
  15284. /** @hidden */
  15285. _currentSize1: number;
  15286. /** @hidden */
  15287. _currentSize2: number;
  15288. /** @hidden */
  15289. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15290. /** @hidden */
  15291. _currentAngularSpeed1: number;
  15292. /** @hidden */
  15293. _currentAngularSpeed2: number;
  15294. /** @hidden */
  15295. _currentVelocityGradient: Nullable<FactorGradient>;
  15296. /** @hidden */
  15297. _currentVelocity1: number;
  15298. /** @hidden */
  15299. _currentVelocity2: number;
  15300. /** @hidden */
  15301. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15302. /** @hidden */
  15303. _currentLimitVelocity1: number;
  15304. /** @hidden */
  15305. _currentLimitVelocity2: number;
  15306. /** @hidden */
  15307. _currentDragGradient: Nullable<FactorGradient>;
  15308. /** @hidden */
  15309. _currentDrag1: number;
  15310. /** @hidden */
  15311. _currentDrag2: number;
  15312. /** @hidden */
  15313. _randomNoiseCoordinates1: Vector3;
  15314. /** @hidden */
  15315. _randomNoiseCoordinates2: Vector3;
  15316. /**
  15317. * Creates a new instance Particle
  15318. * @param particleSystem the particle system the particle belongs to
  15319. */
  15320. constructor(
  15321. /**
  15322. * The particle system the particle belongs to.
  15323. */
  15324. particleSystem: ParticleSystem);
  15325. private updateCellInfoFromSystem;
  15326. /**
  15327. * Defines how the sprite cell index is updated for the particle
  15328. */
  15329. updateCellIndex(): void;
  15330. /** @hidden */
  15331. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15332. /** @hidden */
  15333. _inheritParticleInfoToSubEmitters(): void;
  15334. /** @hidden */
  15335. _reset(): void;
  15336. /**
  15337. * Copy the properties of particle to another one.
  15338. * @param other the particle to copy the information to.
  15339. */
  15340. copyTo(other: Particle): void;
  15341. }
  15342. }
  15343. declare module BABYLON {
  15344. /**
  15345. * Particle emitter represents a volume emitting particles.
  15346. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15347. */
  15348. export interface IParticleEmitterType {
  15349. /**
  15350. * Called by the particle System when the direction is computed for the created particle.
  15351. * @param worldMatrix is the world matrix of the particle system
  15352. * @param directionToUpdate is the direction vector to update with the result
  15353. * @param particle is the particle we are computed the direction for
  15354. */
  15355. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15356. /**
  15357. * Called by the particle System when the position is computed for the created particle.
  15358. * @param worldMatrix is the world matrix of the particle system
  15359. * @param positionToUpdate is the position vector to update with the result
  15360. * @param particle is the particle we are computed the position for
  15361. */
  15362. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15363. /**
  15364. * Clones the current emitter and returns a copy of it
  15365. * @returns the new emitter
  15366. */
  15367. clone(): IParticleEmitterType;
  15368. /**
  15369. * Called by the GPUParticleSystem to setup the update shader
  15370. * @param effect defines the update shader
  15371. */
  15372. applyToShader(effect: Effect): void;
  15373. /**
  15374. * Returns a string to use to update the GPU particles update shader
  15375. * @returns the effect defines string
  15376. */
  15377. getEffectDefines(): string;
  15378. /**
  15379. * Returns a string representing the class name
  15380. * @returns a string containing the class name
  15381. */
  15382. getClassName(): string;
  15383. /**
  15384. * Serializes the particle system to a JSON object.
  15385. * @returns the JSON object
  15386. */
  15387. serialize(): any;
  15388. /**
  15389. * Parse properties from a JSON object
  15390. * @param serializationObject defines the JSON object
  15391. */
  15392. parse(serializationObject: any): void;
  15393. }
  15394. }
  15395. declare module BABYLON {
  15396. /**
  15397. * Particle emitter emitting particles from the inside of a box.
  15398. * It emits the particles randomly between 2 given directions.
  15399. */
  15400. export class BoxParticleEmitter implements IParticleEmitterType {
  15401. /**
  15402. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15403. */
  15404. direction1: Vector3;
  15405. /**
  15406. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15407. */
  15408. direction2: Vector3;
  15409. /**
  15410. * 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.
  15411. */
  15412. minEmitBox: Vector3;
  15413. /**
  15414. * 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.
  15415. */
  15416. maxEmitBox: Vector3;
  15417. /**
  15418. * Creates a new instance BoxParticleEmitter
  15419. */
  15420. constructor();
  15421. /**
  15422. * Called by the particle System when the direction is computed for the created particle.
  15423. * @param worldMatrix is the world matrix of the particle system
  15424. * @param directionToUpdate is the direction vector to update with the result
  15425. * @param particle is the particle we are computed the direction for
  15426. */
  15427. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15428. /**
  15429. * Called by the particle System when the position is computed for the created particle.
  15430. * @param worldMatrix is the world matrix of the particle system
  15431. * @param positionToUpdate is the position vector to update with the result
  15432. * @param particle is the particle we are computed the position for
  15433. */
  15434. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15435. /**
  15436. * Clones the current emitter and returns a copy of it
  15437. * @returns the new emitter
  15438. */
  15439. clone(): BoxParticleEmitter;
  15440. /**
  15441. * Called by the GPUParticleSystem to setup the update shader
  15442. * @param effect defines the update shader
  15443. */
  15444. applyToShader(effect: Effect): void;
  15445. /**
  15446. * Returns a string to use to update the GPU particles update shader
  15447. * @returns a string containng the defines string
  15448. */
  15449. getEffectDefines(): string;
  15450. /**
  15451. * Returns the string "BoxParticleEmitter"
  15452. * @returns a string containing the class name
  15453. */
  15454. getClassName(): string;
  15455. /**
  15456. * Serializes the particle system to a JSON object.
  15457. * @returns the JSON object
  15458. */
  15459. serialize(): any;
  15460. /**
  15461. * Parse properties from a JSON object
  15462. * @param serializationObject defines the JSON object
  15463. */
  15464. parse(serializationObject: any): void;
  15465. }
  15466. }
  15467. declare module BABYLON {
  15468. /**
  15469. * Particle emitter emitting particles from the inside of a cone.
  15470. * It emits the particles alongside the cone volume from the base to the particle.
  15471. * The emission direction might be randomized.
  15472. */
  15473. export class ConeParticleEmitter implements IParticleEmitterType {
  15474. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15475. directionRandomizer: number;
  15476. private _radius;
  15477. private _angle;
  15478. private _height;
  15479. /**
  15480. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15481. */
  15482. radiusRange: number;
  15483. /**
  15484. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15485. */
  15486. heightRange: number;
  15487. /**
  15488. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15489. */
  15490. emitFromSpawnPointOnly: boolean;
  15491. /**
  15492. * Gets or sets the radius of the emission cone
  15493. */
  15494. radius: number;
  15495. /**
  15496. * Gets or sets the angle of the emission cone
  15497. */
  15498. angle: number;
  15499. private _buildHeight;
  15500. /**
  15501. * Creates a new instance ConeParticleEmitter
  15502. * @param radius the radius of the emission cone (1 by default)
  15503. * @param angle the cone base angle (PI by default)
  15504. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15505. */
  15506. constructor(radius?: number, angle?: number,
  15507. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15508. directionRandomizer?: number);
  15509. /**
  15510. * Called by the particle System when the direction is computed for the created particle.
  15511. * @param worldMatrix is the world matrix of the particle system
  15512. * @param directionToUpdate is the direction vector to update with the result
  15513. * @param particle is the particle we are computed the direction for
  15514. */
  15515. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15516. /**
  15517. * Called by the particle System when the position is computed for the created particle.
  15518. * @param worldMatrix is the world matrix of the particle system
  15519. * @param positionToUpdate is the position vector to update with the result
  15520. * @param particle is the particle we are computed the position for
  15521. */
  15522. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15523. /**
  15524. * Clones the current emitter and returns a copy of it
  15525. * @returns the new emitter
  15526. */
  15527. clone(): ConeParticleEmitter;
  15528. /**
  15529. * Called by the GPUParticleSystem to setup the update shader
  15530. * @param effect defines the update shader
  15531. */
  15532. applyToShader(effect: Effect): void;
  15533. /**
  15534. * Returns a string to use to update the GPU particles update shader
  15535. * @returns a string containng the defines string
  15536. */
  15537. getEffectDefines(): string;
  15538. /**
  15539. * Returns the string "ConeParticleEmitter"
  15540. * @returns a string containing the class name
  15541. */
  15542. getClassName(): string;
  15543. /**
  15544. * Serializes the particle system to a JSON object.
  15545. * @returns the JSON object
  15546. */
  15547. serialize(): any;
  15548. /**
  15549. * Parse properties from a JSON object
  15550. * @param serializationObject defines the JSON object
  15551. */
  15552. parse(serializationObject: any): void;
  15553. }
  15554. }
  15555. declare module BABYLON {
  15556. /**
  15557. * Particle emitter emitting particles from the inside of a cylinder.
  15558. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15559. */
  15560. export class CylinderParticleEmitter implements IParticleEmitterType {
  15561. /**
  15562. * The radius of the emission cylinder.
  15563. */
  15564. radius: number;
  15565. /**
  15566. * The height of the emission cylinder.
  15567. */
  15568. height: number;
  15569. /**
  15570. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15571. */
  15572. radiusRange: number;
  15573. /**
  15574. * How much to randomize the particle direction [0-1].
  15575. */
  15576. directionRandomizer: number;
  15577. /**
  15578. * Creates a new instance CylinderParticleEmitter
  15579. * @param radius the radius of the emission cylinder (1 by default)
  15580. * @param height the height of the emission cylinder (1 by default)
  15581. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15582. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15583. */
  15584. constructor(
  15585. /**
  15586. * The radius of the emission cylinder.
  15587. */
  15588. radius?: number,
  15589. /**
  15590. * The height of the emission cylinder.
  15591. */
  15592. height?: number,
  15593. /**
  15594. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15595. */
  15596. radiusRange?: number,
  15597. /**
  15598. * How much to randomize the particle direction [0-1].
  15599. */
  15600. directionRandomizer?: number);
  15601. /**
  15602. * Called by the particle System when the direction is computed for the created particle.
  15603. * @param worldMatrix is the world matrix of the particle system
  15604. * @param directionToUpdate is the direction vector to update with the result
  15605. * @param particle is the particle we are computed the direction for
  15606. */
  15607. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15608. /**
  15609. * Called by the particle System when the position is computed for the created particle.
  15610. * @param worldMatrix is the world matrix of the particle system
  15611. * @param positionToUpdate is the position vector to update with the result
  15612. * @param particle is the particle we are computed the position for
  15613. */
  15614. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15615. /**
  15616. * Clones the current emitter and returns a copy of it
  15617. * @returns the new emitter
  15618. */
  15619. clone(): CylinderParticleEmitter;
  15620. /**
  15621. * Called by the GPUParticleSystem to setup the update shader
  15622. * @param effect defines the update shader
  15623. */
  15624. applyToShader(effect: Effect): void;
  15625. /**
  15626. * Returns a string to use to update the GPU particles update shader
  15627. * @returns a string containng the defines string
  15628. */
  15629. getEffectDefines(): string;
  15630. /**
  15631. * Returns the string "CylinderParticleEmitter"
  15632. * @returns a string containing the class name
  15633. */
  15634. getClassName(): string;
  15635. /**
  15636. * Serializes the particle system to a JSON object.
  15637. * @returns the JSON object
  15638. */
  15639. serialize(): any;
  15640. /**
  15641. * Parse properties from a JSON object
  15642. * @param serializationObject defines the JSON object
  15643. */
  15644. parse(serializationObject: any): void;
  15645. }
  15646. /**
  15647. * Particle emitter emitting particles from the inside of a cylinder.
  15648. * It emits the particles randomly between two vectors.
  15649. */
  15650. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15651. /**
  15652. * The min limit of the emission direction.
  15653. */
  15654. direction1: Vector3;
  15655. /**
  15656. * The max limit of the emission direction.
  15657. */
  15658. direction2: Vector3;
  15659. /**
  15660. * Creates a new instance CylinderDirectedParticleEmitter
  15661. * @param radius the radius of the emission cylinder (1 by default)
  15662. * @param height the height of the emission cylinder (1 by default)
  15663. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15664. * @param direction1 the min limit of the emission direction (up vector by default)
  15665. * @param direction2 the max limit of the emission direction (up vector by default)
  15666. */
  15667. constructor(radius?: number, height?: number, radiusRange?: number,
  15668. /**
  15669. * The min limit of the emission direction.
  15670. */
  15671. direction1?: Vector3,
  15672. /**
  15673. * The max limit of the emission direction.
  15674. */
  15675. direction2?: Vector3);
  15676. /**
  15677. * Called by the particle System when the direction is computed for the created particle.
  15678. * @param worldMatrix is the world matrix of the particle system
  15679. * @param directionToUpdate is the direction vector to update with the result
  15680. * @param particle is the particle we are computed the direction for
  15681. */
  15682. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15683. /**
  15684. * Clones the current emitter and returns a copy of it
  15685. * @returns the new emitter
  15686. */
  15687. clone(): CylinderDirectedParticleEmitter;
  15688. /**
  15689. * Called by the GPUParticleSystem to setup the update shader
  15690. * @param effect defines the update shader
  15691. */
  15692. applyToShader(effect: Effect): void;
  15693. /**
  15694. * Returns a string to use to update the GPU particles update shader
  15695. * @returns a string containng the defines string
  15696. */
  15697. getEffectDefines(): string;
  15698. /**
  15699. * Returns the string "CylinderDirectedParticleEmitter"
  15700. * @returns a string containing the class name
  15701. */
  15702. getClassName(): string;
  15703. /**
  15704. * Serializes the particle system to a JSON object.
  15705. * @returns the JSON object
  15706. */
  15707. serialize(): any;
  15708. /**
  15709. * Parse properties from a JSON object
  15710. * @param serializationObject defines the JSON object
  15711. */
  15712. parse(serializationObject: any): void;
  15713. }
  15714. }
  15715. declare module BABYLON {
  15716. /**
  15717. * Particle emitter emitting particles from the inside of a hemisphere.
  15718. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15719. */
  15720. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15721. /**
  15722. * The radius of the emission hemisphere.
  15723. */
  15724. radius: number;
  15725. /**
  15726. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15727. */
  15728. radiusRange: number;
  15729. /**
  15730. * How much to randomize the particle direction [0-1].
  15731. */
  15732. directionRandomizer: number;
  15733. /**
  15734. * Creates a new instance HemisphericParticleEmitter
  15735. * @param radius the radius of the emission hemisphere (1 by default)
  15736. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15737. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15738. */
  15739. constructor(
  15740. /**
  15741. * The radius of the emission hemisphere.
  15742. */
  15743. radius?: number,
  15744. /**
  15745. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15746. */
  15747. radiusRange?: number,
  15748. /**
  15749. * How much to randomize the particle direction [0-1].
  15750. */
  15751. directionRandomizer?: number);
  15752. /**
  15753. * Called by the particle System when the direction is computed for the created particle.
  15754. * @param worldMatrix is the world matrix of the particle system
  15755. * @param directionToUpdate is the direction vector to update with the result
  15756. * @param particle is the particle we are computed the direction for
  15757. */
  15758. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15759. /**
  15760. * Called by the particle System when the position is computed for the created particle.
  15761. * @param worldMatrix is the world matrix of the particle system
  15762. * @param positionToUpdate is the position vector to update with the result
  15763. * @param particle is the particle we are computed the position for
  15764. */
  15765. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15766. /**
  15767. * Clones the current emitter and returns a copy of it
  15768. * @returns the new emitter
  15769. */
  15770. clone(): HemisphericParticleEmitter;
  15771. /**
  15772. * Called by the GPUParticleSystem to setup the update shader
  15773. * @param effect defines the update shader
  15774. */
  15775. applyToShader(effect: Effect): void;
  15776. /**
  15777. * Returns a string to use to update the GPU particles update shader
  15778. * @returns a string containng the defines string
  15779. */
  15780. getEffectDefines(): string;
  15781. /**
  15782. * Returns the string "HemisphericParticleEmitter"
  15783. * @returns a string containing the class name
  15784. */
  15785. getClassName(): string;
  15786. /**
  15787. * Serializes the particle system to a JSON object.
  15788. * @returns the JSON object
  15789. */
  15790. serialize(): any;
  15791. /**
  15792. * Parse properties from a JSON object
  15793. * @param serializationObject defines the JSON object
  15794. */
  15795. parse(serializationObject: any): void;
  15796. }
  15797. }
  15798. declare module BABYLON {
  15799. /**
  15800. * Particle emitter emitting particles from a point.
  15801. * It emits the particles randomly between 2 given directions.
  15802. */
  15803. export class PointParticleEmitter implements IParticleEmitterType {
  15804. /**
  15805. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15806. */
  15807. direction1: Vector3;
  15808. /**
  15809. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15810. */
  15811. direction2: Vector3;
  15812. /**
  15813. * Creates a new instance PointParticleEmitter
  15814. */
  15815. constructor();
  15816. /**
  15817. * Called by the particle System when the direction is computed for the created particle.
  15818. * @param worldMatrix is the world matrix of the particle system
  15819. * @param directionToUpdate is the direction vector to update with the result
  15820. * @param particle is the particle we are computed the direction for
  15821. */
  15822. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15823. /**
  15824. * Called by the particle System when the position is computed for the created particle.
  15825. * @param worldMatrix is the world matrix of the particle system
  15826. * @param positionToUpdate is the position vector to update with the result
  15827. * @param particle is the particle we are computed the position for
  15828. */
  15829. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15830. /**
  15831. * Clones the current emitter and returns a copy of it
  15832. * @returns the new emitter
  15833. */
  15834. clone(): PointParticleEmitter;
  15835. /**
  15836. * Called by the GPUParticleSystem to setup the update shader
  15837. * @param effect defines the update shader
  15838. */
  15839. applyToShader(effect: Effect): void;
  15840. /**
  15841. * Returns a string to use to update the GPU particles update shader
  15842. * @returns a string containng the defines string
  15843. */
  15844. getEffectDefines(): string;
  15845. /**
  15846. * Returns the string "PointParticleEmitter"
  15847. * @returns a string containing the class name
  15848. */
  15849. getClassName(): string;
  15850. /**
  15851. * Serializes the particle system to a JSON object.
  15852. * @returns the JSON object
  15853. */
  15854. serialize(): any;
  15855. /**
  15856. * Parse properties from a JSON object
  15857. * @param serializationObject defines the JSON object
  15858. */
  15859. parse(serializationObject: any): void;
  15860. }
  15861. }
  15862. declare module BABYLON {
  15863. /**
  15864. * Particle emitter emitting particles from the inside of a sphere.
  15865. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15866. */
  15867. export class SphereParticleEmitter implements IParticleEmitterType {
  15868. /**
  15869. * The radius of the emission sphere.
  15870. */
  15871. radius: number;
  15872. /**
  15873. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15874. */
  15875. radiusRange: number;
  15876. /**
  15877. * How much to randomize the particle direction [0-1].
  15878. */
  15879. directionRandomizer: number;
  15880. /**
  15881. * Creates a new instance SphereParticleEmitter
  15882. * @param radius the radius of the emission sphere (1 by default)
  15883. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15884. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15885. */
  15886. constructor(
  15887. /**
  15888. * The radius of the emission sphere.
  15889. */
  15890. radius?: number,
  15891. /**
  15892. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15893. */
  15894. radiusRange?: number,
  15895. /**
  15896. * How much to randomize the particle direction [0-1].
  15897. */
  15898. directionRandomizer?: number);
  15899. /**
  15900. * Called by the particle System when the direction is computed for the created particle.
  15901. * @param worldMatrix is the world matrix of the particle system
  15902. * @param directionToUpdate is the direction vector to update with the result
  15903. * @param particle is the particle we are computed the direction for
  15904. */
  15905. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15906. /**
  15907. * Called by the particle System when the position is computed for the created particle.
  15908. * @param worldMatrix is the world matrix of the particle system
  15909. * @param positionToUpdate is the position vector to update with the result
  15910. * @param particle is the particle we are computed the position for
  15911. */
  15912. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15913. /**
  15914. * Clones the current emitter and returns a copy of it
  15915. * @returns the new emitter
  15916. */
  15917. clone(): SphereParticleEmitter;
  15918. /**
  15919. * Called by the GPUParticleSystem to setup the update shader
  15920. * @param effect defines the update shader
  15921. */
  15922. applyToShader(effect: Effect): void;
  15923. /**
  15924. * Returns a string to use to update the GPU particles update shader
  15925. * @returns a string containng the defines string
  15926. */
  15927. getEffectDefines(): string;
  15928. /**
  15929. * Returns the string "SphereParticleEmitter"
  15930. * @returns a string containing the class name
  15931. */
  15932. getClassName(): string;
  15933. /**
  15934. * Serializes the particle system to a JSON object.
  15935. * @returns the JSON object
  15936. */
  15937. serialize(): any;
  15938. /**
  15939. * Parse properties from a JSON object
  15940. * @param serializationObject defines the JSON object
  15941. */
  15942. parse(serializationObject: any): void;
  15943. }
  15944. /**
  15945. * Particle emitter emitting particles from the inside of a sphere.
  15946. * It emits the particles randomly between two vectors.
  15947. */
  15948. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15949. /**
  15950. * The min limit of the emission direction.
  15951. */
  15952. direction1: Vector3;
  15953. /**
  15954. * The max limit of the emission direction.
  15955. */
  15956. direction2: Vector3;
  15957. /**
  15958. * Creates a new instance SphereDirectedParticleEmitter
  15959. * @param radius the radius of the emission sphere (1 by default)
  15960. * @param direction1 the min limit of the emission direction (up vector by default)
  15961. * @param direction2 the max limit of the emission direction (up vector by default)
  15962. */
  15963. constructor(radius?: number,
  15964. /**
  15965. * The min limit of the emission direction.
  15966. */
  15967. direction1?: Vector3,
  15968. /**
  15969. * The max limit of the emission direction.
  15970. */
  15971. direction2?: Vector3);
  15972. /**
  15973. * Called by the particle System when the direction is computed for the created particle.
  15974. * @param worldMatrix is the world matrix of the particle system
  15975. * @param directionToUpdate is the direction vector to update with the result
  15976. * @param particle is the particle we are computed the direction for
  15977. */
  15978. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15979. /**
  15980. * Clones the current emitter and returns a copy of it
  15981. * @returns the new emitter
  15982. */
  15983. clone(): SphereDirectedParticleEmitter;
  15984. /**
  15985. * Called by the GPUParticleSystem to setup the update shader
  15986. * @param effect defines the update shader
  15987. */
  15988. applyToShader(effect: Effect): void;
  15989. /**
  15990. * Returns a string to use to update the GPU particles update shader
  15991. * @returns a string containng the defines string
  15992. */
  15993. getEffectDefines(): string;
  15994. /**
  15995. * Returns the string "SphereDirectedParticleEmitter"
  15996. * @returns a string containing the class name
  15997. */
  15998. getClassName(): string;
  15999. /**
  16000. * Serializes the particle system to a JSON object.
  16001. * @returns the JSON object
  16002. */
  16003. serialize(): any;
  16004. /**
  16005. * Parse properties from a JSON object
  16006. * @param serializationObject defines the JSON object
  16007. */
  16008. parse(serializationObject: any): void;
  16009. }
  16010. }
  16011. declare module BABYLON {
  16012. /**
  16013. * Interface representing a particle system in Babylon.js.
  16014. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16015. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16016. */
  16017. export interface IParticleSystem {
  16018. /**
  16019. * List of animations used by the particle system.
  16020. */
  16021. animations: Animation[];
  16022. /**
  16023. * The id of the Particle system.
  16024. */
  16025. id: string;
  16026. /**
  16027. * The name of the Particle system.
  16028. */
  16029. name: string;
  16030. /**
  16031. * The emitter represents the Mesh or position we are attaching the particle system to.
  16032. */
  16033. emitter: Nullable<AbstractMesh | Vector3>;
  16034. /**
  16035. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16036. */
  16037. isBillboardBased: boolean;
  16038. /**
  16039. * The rendering group used by the Particle system to chose when to render.
  16040. */
  16041. renderingGroupId: number;
  16042. /**
  16043. * The layer mask we are rendering the particles through.
  16044. */
  16045. layerMask: number;
  16046. /**
  16047. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16048. */
  16049. updateSpeed: number;
  16050. /**
  16051. * The amount of time the particle system is running (depends of the overall update speed).
  16052. */
  16053. targetStopDuration: number;
  16054. /**
  16055. * The texture used to render each particle. (this can be a spritesheet)
  16056. */
  16057. particleTexture: Nullable<Texture>;
  16058. /**
  16059. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16060. */
  16061. blendMode: number;
  16062. /**
  16063. * Minimum life time of emitting particles.
  16064. */
  16065. minLifeTime: number;
  16066. /**
  16067. * Maximum life time of emitting particles.
  16068. */
  16069. maxLifeTime: number;
  16070. /**
  16071. * Minimum Size of emitting particles.
  16072. */
  16073. minSize: number;
  16074. /**
  16075. * Maximum Size of emitting particles.
  16076. */
  16077. maxSize: number;
  16078. /**
  16079. * Minimum scale of emitting particles on X axis.
  16080. */
  16081. minScaleX: number;
  16082. /**
  16083. * Maximum scale of emitting particles on X axis.
  16084. */
  16085. maxScaleX: number;
  16086. /**
  16087. * Minimum scale of emitting particles on Y axis.
  16088. */
  16089. minScaleY: number;
  16090. /**
  16091. * Maximum scale of emitting particles on Y axis.
  16092. */
  16093. maxScaleY: number;
  16094. /**
  16095. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16096. */
  16097. color1: Color4;
  16098. /**
  16099. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16100. */
  16101. color2: Color4;
  16102. /**
  16103. * Color the particle will have at the end of its lifetime.
  16104. */
  16105. colorDead: Color4;
  16106. /**
  16107. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16108. */
  16109. emitRate: number;
  16110. /**
  16111. * You can use gravity if you want to give an orientation to your particles.
  16112. */
  16113. gravity: Vector3;
  16114. /**
  16115. * Minimum power of emitting particles.
  16116. */
  16117. minEmitPower: number;
  16118. /**
  16119. * Maximum power of emitting particles.
  16120. */
  16121. maxEmitPower: number;
  16122. /**
  16123. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16124. */
  16125. minAngularSpeed: number;
  16126. /**
  16127. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16128. */
  16129. maxAngularSpeed: number;
  16130. /**
  16131. * Gets or sets the minimal initial rotation in radians.
  16132. */
  16133. minInitialRotation: number;
  16134. /**
  16135. * Gets or sets the maximal initial rotation in radians.
  16136. */
  16137. maxInitialRotation: number;
  16138. /**
  16139. * The particle emitter type defines the emitter used by the particle system.
  16140. * It can be for example box, sphere, or cone...
  16141. */
  16142. particleEmitterType: Nullable<IParticleEmitterType>;
  16143. /**
  16144. * Defines the delay in milliseconds before starting the system (0 by default)
  16145. */
  16146. startDelay: number;
  16147. /**
  16148. * 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
  16149. */
  16150. preWarmCycles: number;
  16151. /**
  16152. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16153. */
  16154. preWarmStepOffset: number;
  16155. /**
  16156. * 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)
  16157. */
  16158. spriteCellChangeSpeed: number;
  16159. /**
  16160. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16161. */
  16162. startSpriteCellID: number;
  16163. /**
  16164. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16165. */
  16166. endSpriteCellID: number;
  16167. /**
  16168. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16169. */
  16170. spriteCellWidth: number;
  16171. /**
  16172. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16173. */
  16174. spriteCellHeight: number;
  16175. /**
  16176. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16177. */
  16178. spriteRandomStartCell: boolean;
  16179. /**
  16180. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16181. */
  16182. isAnimationSheetEnabled: boolean;
  16183. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16184. translationPivot: Vector2;
  16185. /**
  16186. * Gets or sets a texture used to add random noise to particle positions
  16187. */
  16188. noiseTexture: Nullable<BaseTexture>;
  16189. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16190. noiseStrength: Vector3;
  16191. /**
  16192. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16193. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16194. */
  16195. billboardMode: number;
  16196. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16197. limitVelocityDamping: number;
  16198. /**
  16199. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16200. */
  16201. beginAnimationOnStart: boolean;
  16202. /**
  16203. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16204. */
  16205. beginAnimationFrom: number;
  16206. /**
  16207. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16208. */
  16209. beginAnimationTo: number;
  16210. /**
  16211. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16212. */
  16213. beginAnimationLoop: boolean;
  16214. /**
  16215. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16216. */
  16217. disposeOnStop: boolean;
  16218. /**
  16219. * Gets the maximum number of particles active at the same time.
  16220. * @returns The max number of active particles.
  16221. */
  16222. getCapacity(): number;
  16223. /**
  16224. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16225. * @returns True if it has been started, otherwise false.
  16226. */
  16227. isStarted(): boolean;
  16228. /**
  16229. * Animates the particle system for this frame.
  16230. */
  16231. animate(): void;
  16232. /**
  16233. * Renders the particle system in its current state.
  16234. * @returns the current number of particles
  16235. */
  16236. render(): number;
  16237. /**
  16238. * Dispose the particle system and frees its associated resources.
  16239. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16240. */
  16241. dispose(disposeTexture?: boolean): void;
  16242. /**
  16243. * Clones the particle system.
  16244. * @param name The name of the cloned object
  16245. * @param newEmitter The new emitter to use
  16246. * @returns the cloned particle system
  16247. */
  16248. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16249. /**
  16250. * Serializes the particle system to a JSON object.
  16251. * @returns the JSON object
  16252. */
  16253. serialize(): any;
  16254. /**
  16255. * Rebuild the particle system
  16256. */
  16257. rebuild(): void;
  16258. /**
  16259. * Starts the particle system and begins to emit
  16260. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16261. */
  16262. start(delay?: number): void;
  16263. /**
  16264. * Stops the particle system.
  16265. */
  16266. stop(): void;
  16267. /**
  16268. * Remove all active particles
  16269. */
  16270. reset(): void;
  16271. /**
  16272. * Is this system ready to be used/rendered
  16273. * @return true if the system is ready
  16274. */
  16275. isReady(): boolean;
  16276. /**
  16277. * Adds a new color gradient
  16278. * @param gradient defines the gradient to use (between 0 and 1)
  16279. * @param color1 defines the color to affect to the specified gradient
  16280. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16281. * @returns the current particle system
  16282. */
  16283. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16284. /**
  16285. * Remove a specific color gradient
  16286. * @param gradient defines the gradient to remove
  16287. * @returns the current particle system
  16288. */
  16289. removeColorGradient(gradient: number): IParticleSystem;
  16290. /**
  16291. * Adds a new size gradient
  16292. * @param gradient defines the gradient to use (between 0 and 1)
  16293. * @param factor defines the size factor to affect to the specified gradient
  16294. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16295. * @returns the current particle system
  16296. */
  16297. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16298. /**
  16299. * Remove a specific size gradient
  16300. * @param gradient defines the gradient to remove
  16301. * @returns the current particle system
  16302. */
  16303. removeSizeGradient(gradient: number): IParticleSystem;
  16304. /**
  16305. * Gets the current list of color gradients.
  16306. * You must use addColorGradient and removeColorGradient to udpate this list
  16307. * @returns the list of color gradients
  16308. */
  16309. getColorGradients(): Nullable<Array<ColorGradient>>;
  16310. /**
  16311. * Gets the current list of size gradients.
  16312. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16313. * @returns the list of size gradients
  16314. */
  16315. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16316. /**
  16317. * Gets the current list of angular speed gradients.
  16318. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16319. * @returns the list of angular speed gradients
  16320. */
  16321. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16322. /**
  16323. * Adds a new angular speed gradient
  16324. * @param gradient defines the gradient to use (between 0 and 1)
  16325. * @param factor defines the angular speed to affect to the specified gradient
  16326. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16327. * @returns the current particle system
  16328. */
  16329. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16330. /**
  16331. * Remove a specific angular speed gradient
  16332. * @param gradient defines the gradient to remove
  16333. * @returns the current particle system
  16334. */
  16335. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16336. /**
  16337. * Gets the current list of velocity gradients.
  16338. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16339. * @returns the list of velocity gradients
  16340. */
  16341. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16342. /**
  16343. * Adds a new velocity gradient
  16344. * @param gradient defines the gradient to use (between 0 and 1)
  16345. * @param factor defines the velocity to affect to the specified gradient
  16346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16347. * @returns the current particle system
  16348. */
  16349. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16350. /**
  16351. * Remove a specific velocity gradient
  16352. * @param gradient defines the gradient to remove
  16353. * @returns the current particle system
  16354. */
  16355. removeVelocityGradient(gradient: number): IParticleSystem;
  16356. /**
  16357. * Gets the current list of limit velocity gradients.
  16358. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16359. * @returns the list of limit velocity gradients
  16360. */
  16361. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16362. /**
  16363. * Adds a new limit velocity gradient
  16364. * @param gradient defines the gradient to use (between 0 and 1)
  16365. * @param factor defines the limit velocity to affect to the specified gradient
  16366. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16367. * @returns the current particle system
  16368. */
  16369. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16370. /**
  16371. * Remove a specific limit velocity gradient
  16372. * @param gradient defines the gradient to remove
  16373. * @returns the current particle system
  16374. */
  16375. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16376. /**
  16377. * Adds a new drag gradient
  16378. * @param gradient defines the gradient to use (between 0 and 1)
  16379. * @param factor defines the drag to affect to the specified gradient
  16380. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16381. * @returns the current particle system
  16382. */
  16383. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16384. /**
  16385. * Remove a specific drag gradient
  16386. * @param gradient defines the gradient to remove
  16387. * @returns the current particle system
  16388. */
  16389. removeDragGradient(gradient: number): IParticleSystem;
  16390. /**
  16391. * Gets the current list of drag gradients.
  16392. * You must use addDragGradient and removeDragGradient to udpate this list
  16393. * @returns the list of drag gradients
  16394. */
  16395. getDragGradients(): Nullable<Array<FactorGradient>>;
  16396. /**
  16397. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16398. * @param gradient defines the gradient to use (between 0 and 1)
  16399. * @param factor defines the emit rate to affect to the specified gradient
  16400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16401. * @returns the current particle system
  16402. */
  16403. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16404. /**
  16405. * Remove a specific emit rate gradient
  16406. * @param gradient defines the gradient to remove
  16407. * @returns the current particle system
  16408. */
  16409. removeEmitRateGradient(gradient: number): IParticleSystem;
  16410. /**
  16411. * Gets the current list of emit rate gradients.
  16412. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16413. * @returns the list of emit rate gradients
  16414. */
  16415. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16416. /**
  16417. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16418. * @param gradient defines the gradient to use (between 0 and 1)
  16419. * @param factor defines the start size to affect to the specified gradient
  16420. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16421. * @returns the current particle system
  16422. */
  16423. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16424. /**
  16425. * Remove a specific start size gradient
  16426. * @param gradient defines the gradient to remove
  16427. * @returns the current particle system
  16428. */
  16429. removeStartSizeGradient(gradient: number): IParticleSystem;
  16430. /**
  16431. * Gets the current list of start size gradients.
  16432. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16433. * @returns the list of start size gradients
  16434. */
  16435. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16436. /**
  16437. * Adds a new life time gradient
  16438. * @param gradient defines the gradient to use (between 0 and 1)
  16439. * @param factor defines the life time factor to affect to the specified gradient
  16440. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16441. * @returns the current particle system
  16442. */
  16443. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16444. /**
  16445. * Remove a specific life time gradient
  16446. * @param gradient defines the gradient to remove
  16447. * @returns the current particle system
  16448. */
  16449. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16450. /**
  16451. * Gets the current list of life time gradients.
  16452. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16453. * @returns the list of life time gradients
  16454. */
  16455. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16456. /**
  16457. * Gets the current list of color gradients.
  16458. * You must use addColorGradient and removeColorGradient to udpate this list
  16459. * @returns the list of color gradients
  16460. */
  16461. getColorGradients(): Nullable<Array<ColorGradient>>;
  16462. /**
  16463. * Adds a new ramp gradient used to remap particle colors
  16464. * @param gradient defines the gradient to use (between 0 and 1)
  16465. * @param color defines the color to affect to the specified gradient
  16466. * @returns the current particle system
  16467. */
  16468. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16469. /**
  16470. * Gets the current list of ramp gradients.
  16471. * You must use addRampGradient and removeRampGradient to udpate this list
  16472. * @returns the list of ramp gradients
  16473. */
  16474. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16475. /** Gets or sets a boolean indicating that ramp gradients must be used
  16476. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16477. */
  16478. useRampGradients: boolean;
  16479. /**
  16480. * Adds a new color remap gradient
  16481. * @param gradient defines the gradient to use (between 0 and 1)
  16482. * @param min defines the color remap minimal range
  16483. * @param max defines the color remap maximal range
  16484. * @returns the current particle system
  16485. */
  16486. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16487. /**
  16488. * Gets the current list of color remap gradients.
  16489. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16490. * @returns the list of color remap gradients
  16491. */
  16492. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16493. /**
  16494. * Adds a new alpha remap gradient
  16495. * @param gradient defines the gradient to use (between 0 and 1)
  16496. * @param min defines the alpha remap minimal range
  16497. * @param max defines the alpha remap maximal range
  16498. * @returns the current particle system
  16499. */
  16500. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16501. /**
  16502. * Gets the current list of alpha remap gradients.
  16503. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16504. * @returns the list of alpha remap gradients
  16505. */
  16506. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16507. /**
  16508. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16509. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16510. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16511. * @returns the emitter
  16512. */
  16513. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16514. /**
  16515. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16516. * @param radius The radius of the hemisphere to emit from
  16517. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16518. * @returns the emitter
  16519. */
  16520. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16521. /**
  16522. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16523. * @param radius The radius of the sphere to emit from
  16524. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16525. * @returns the emitter
  16526. */
  16527. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16528. /**
  16529. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16530. * @param radius The radius of the sphere to emit from
  16531. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16532. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16533. * @returns the emitter
  16534. */
  16535. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16536. /**
  16537. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16538. * @param radius The radius of the emission cylinder
  16539. * @param height The height of the emission cylinder
  16540. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16541. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16542. * @returns the emitter
  16543. */
  16544. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16545. /**
  16546. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16547. * @param radius The radius of the cylinder to emit from
  16548. * @param height The height of the emission cylinder
  16549. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16550. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16551. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16552. * @returns the emitter
  16553. */
  16554. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16555. /**
  16556. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16557. * @param radius The radius of the cone to emit from
  16558. * @param angle The base angle of the cone
  16559. * @returns the emitter
  16560. */
  16561. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16562. /**
  16563. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16564. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16565. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16566. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16567. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16568. * @returns the emitter
  16569. */
  16570. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16571. /**
  16572. * Get hosting scene
  16573. * @returns the scene
  16574. */
  16575. getScene(): Scene;
  16576. }
  16577. }
  16578. declare module BABYLON {
  16579. /** @hidden */
  16580. export var linePixelShader: {
  16581. name: string;
  16582. shader: string;
  16583. };
  16584. }
  16585. declare module BABYLON {
  16586. /** @hidden */
  16587. export var lineVertexShader: {
  16588. name: string;
  16589. shader: string;
  16590. };
  16591. }
  16592. declare module BABYLON {
  16593. interface AbstractMesh {
  16594. /**
  16595. * Disables the mesh edge rendering mode
  16596. * @returns the currentAbstractMesh
  16597. */
  16598. disableEdgesRendering(): AbstractMesh;
  16599. /**
  16600. * Enables the edge rendering mode on the mesh.
  16601. * This mode makes the mesh edges visible
  16602. * @param epsilon defines the maximal distance between two angles to detect a face
  16603. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16604. * @returns the currentAbstractMesh
  16605. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16606. */
  16607. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16608. /**
  16609. * Gets the edgesRenderer associated with the mesh
  16610. */
  16611. edgesRenderer: Nullable<EdgesRenderer>;
  16612. }
  16613. interface LinesMesh {
  16614. /**
  16615. * Enables the edge rendering mode on the mesh.
  16616. * This mode makes the mesh edges visible
  16617. * @param epsilon defines the maximal distance between two angles to detect a face
  16618. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16619. * @returns the currentAbstractMesh
  16620. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16621. */
  16622. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16623. }
  16624. interface InstancedLinesMesh {
  16625. /**
  16626. * Enables the edge rendering mode on the mesh.
  16627. * This mode makes the mesh edges visible
  16628. * @param epsilon defines the maximal distance between two angles to detect a face
  16629. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16630. * @returns the current InstancedLinesMesh
  16631. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16632. */
  16633. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16634. }
  16635. /**
  16636. * Defines the minimum contract an Edges renderer should follow.
  16637. */
  16638. export interface IEdgesRenderer extends IDisposable {
  16639. /**
  16640. * Gets or sets a boolean indicating if the edgesRenderer is active
  16641. */
  16642. isEnabled: boolean;
  16643. /**
  16644. * Renders the edges of the attached mesh,
  16645. */
  16646. render(): void;
  16647. /**
  16648. * Checks wether or not the edges renderer is ready to render.
  16649. * @return true if ready, otherwise false.
  16650. */
  16651. isReady(): boolean;
  16652. }
  16653. /**
  16654. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16655. */
  16656. export class EdgesRenderer implements IEdgesRenderer {
  16657. /**
  16658. * Define the size of the edges with an orthographic camera
  16659. */
  16660. edgesWidthScalerForOrthographic: number;
  16661. /**
  16662. * Define the size of the edges with a perspective camera
  16663. */
  16664. edgesWidthScalerForPerspective: number;
  16665. protected _source: AbstractMesh;
  16666. protected _linesPositions: number[];
  16667. protected _linesNormals: number[];
  16668. protected _linesIndices: number[];
  16669. protected _epsilon: number;
  16670. protected _indicesCount: number;
  16671. protected _lineShader: ShaderMaterial;
  16672. protected _ib: WebGLBuffer;
  16673. protected _buffers: {
  16674. [key: string]: Nullable<VertexBuffer>;
  16675. };
  16676. protected _checkVerticesInsteadOfIndices: boolean;
  16677. private _meshRebuildObserver;
  16678. private _meshDisposeObserver;
  16679. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16680. isEnabled: boolean;
  16681. /**
  16682. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16683. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16684. * @param source Mesh used to create edges
  16685. * @param epsilon sum of angles in adjacency to check for edge
  16686. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16687. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16688. */
  16689. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16690. protected _prepareRessources(): void;
  16691. /** @hidden */
  16692. _rebuild(): void;
  16693. /**
  16694. * Releases the required resources for the edges renderer
  16695. */
  16696. dispose(): void;
  16697. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16698. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16699. /**
  16700. * Checks if the pair of p0 and p1 is en edge
  16701. * @param faceIndex
  16702. * @param edge
  16703. * @param faceNormals
  16704. * @param p0
  16705. * @param p1
  16706. * @private
  16707. */
  16708. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16709. /**
  16710. * push line into the position, normal and index buffer
  16711. * @protected
  16712. */
  16713. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16714. /**
  16715. * Generates lines edges from adjacencjes
  16716. * @private
  16717. */
  16718. _generateEdgesLines(): void;
  16719. /**
  16720. * Checks wether or not the edges renderer is ready to render.
  16721. * @return true if ready, otherwise false.
  16722. */
  16723. isReady(): boolean;
  16724. /**
  16725. * Renders the edges of the attached mesh,
  16726. */
  16727. render(): void;
  16728. }
  16729. /**
  16730. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16731. */
  16732. export class LineEdgesRenderer extends EdgesRenderer {
  16733. /**
  16734. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16735. * @param source LineMesh used to generate edges
  16736. * @param epsilon not important (specified angle for edge detection)
  16737. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16738. */
  16739. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16740. /**
  16741. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16742. */
  16743. _generateEdgesLines(): void;
  16744. }
  16745. }
  16746. declare module BABYLON {
  16747. /**
  16748. * This represents the object necessary to create a rendering group.
  16749. * This is exclusively used and created by the rendering manager.
  16750. * To modify the behavior, you use the available helpers in your scene or meshes.
  16751. * @hidden
  16752. */
  16753. export class RenderingGroup {
  16754. index: number;
  16755. private _scene;
  16756. private _opaqueSubMeshes;
  16757. private _transparentSubMeshes;
  16758. private _alphaTestSubMeshes;
  16759. private _depthOnlySubMeshes;
  16760. private _particleSystems;
  16761. private _spriteManagers;
  16762. private _opaqueSortCompareFn;
  16763. private _alphaTestSortCompareFn;
  16764. private _transparentSortCompareFn;
  16765. private _renderOpaque;
  16766. private _renderAlphaTest;
  16767. private _renderTransparent;
  16768. private _edgesRenderers;
  16769. onBeforeTransparentRendering: () => void;
  16770. /**
  16771. * Set the opaque sort comparison function.
  16772. * If null the sub meshes will be render in the order they were created
  16773. */
  16774. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16775. /**
  16776. * Set the alpha test sort comparison function.
  16777. * If null the sub meshes will be render in the order they were created
  16778. */
  16779. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16780. /**
  16781. * Set the transparent sort comparison function.
  16782. * If null the sub meshes will be render in the order they were created
  16783. */
  16784. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16785. /**
  16786. * Creates a new rendering group.
  16787. * @param index The rendering group index
  16788. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16789. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16790. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16791. */
  16792. 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>);
  16793. /**
  16794. * Render all the sub meshes contained in the group.
  16795. * @param customRenderFunction Used to override the default render behaviour of the group.
  16796. * @returns true if rendered some submeshes.
  16797. */
  16798. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16799. /**
  16800. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16801. * @param subMeshes The submeshes to render
  16802. */
  16803. private renderOpaqueSorted;
  16804. /**
  16805. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16806. * @param subMeshes The submeshes to render
  16807. */
  16808. private renderAlphaTestSorted;
  16809. /**
  16810. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16811. * @param subMeshes The submeshes to render
  16812. */
  16813. private renderTransparentSorted;
  16814. /**
  16815. * Renders the submeshes in a specified order.
  16816. * @param subMeshes The submeshes to sort before render
  16817. * @param sortCompareFn The comparison function use to sort
  16818. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16819. * @param transparent Specifies to activate blending if true
  16820. */
  16821. private static renderSorted;
  16822. /**
  16823. * Renders the submeshes in the order they were dispatched (no sort applied).
  16824. * @param subMeshes The submeshes to render
  16825. */
  16826. private static renderUnsorted;
  16827. /**
  16828. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16829. * are rendered back to front if in the same alpha index.
  16830. *
  16831. * @param a The first submesh
  16832. * @param b The second submesh
  16833. * @returns The result of the comparison
  16834. */
  16835. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16836. /**
  16837. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16838. * are rendered back to front.
  16839. *
  16840. * @param a The first submesh
  16841. * @param b The second submesh
  16842. * @returns The result of the comparison
  16843. */
  16844. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16845. /**
  16846. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16847. * are rendered front to back (prevent overdraw).
  16848. *
  16849. * @param a The first submesh
  16850. * @param b The second submesh
  16851. * @returns The result of the comparison
  16852. */
  16853. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16854. /**
  16855. * Resets the different lists of submeshes to prepare a new frame.
  16856. */
  16857. prepare(): void;
  16858. dispose(): void;
  16859. /**
  16860. * Inserts the submesh in its correct queue depending on its material.
  16861. * @param subMesh The submesh to dispatch
  16862. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16863. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16864. */
  16865. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16866. dispatchSprites(spriteManager: ISpriteManager): void;
  16867. dispatchParticles(particleSystem: IParticleSystem): void;
  16868. private _renderParticles;
  16869. private _renderSprites;
  16870. }
  16871. }
  16872. declare module BABYLON {
  16873. /**
  16874. * Interface describing the different options available in the rendering manager
  16875. * regarding Auto Clear between groups.
  16876. */
  16877. export interface IRenderingManagerAutoClearSetup {
  16878. /**
  16879. * Defines whether or not autoclear is enable.
  16880. */
  16881. autoClear: boolean;
  16882. /**
  16883. * Defines whether or not to autoclear the depth buffer.
  16884. */
  16885. depth: boolean;
  16886. /**
  16887. * Defines whether or not to autoclear the stencil buffer.
  16888. */
  16889. stencil: boolean;
  16890. }
  16891. /**
  16892. * This class is used by the onRenderingGroupObservable
  16893. */
  16894. export class RenderingGroupInfo {
  16895. /**
  16896. * The Scene that being rendered
  16897. */
  16898. scene: Scene;
  16899. /**
  16900. * The camera currently used for the rendering pass
  16901. */
  16902. camera: Nullable<Camera>;
  16903. /**
  16904. * The ID of the renderingGroup being processed
  16905. */
  16906. renderingGroupId: number;
  16907. }
  16908. /**
  16909. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16910. * It is enable to manage the different groups as well as the different necessary sort functions.
  16911. * This should not be used directly aside of the few static configurations
  16912. */
  16913. export class RenderingManager {
  16914. /**
  16915. * The max id used for rendering groups (not included)
  16916. */
  16917. static MAX_RENDERINGGROUPS: number;
  16918. /**
  16919. * The min id used for rendering groups (included)
  16920. */
  16921. static MIN_RENDERINGGROUPS: number;
  16922. /**
  16923. * Used to globally prevent autoclearing scenes.
  16924. */
  16925. static AUTOCLEAR: boolean;
  16926. /**
  16927. * @hidden
  16928. */
  16929. _useSceneAutoClearSetup: boolean;
  16930. private _scene;
  16931. private _renderingGroups;
  16932. private _depthStencilBufferAlreadyCleaned;
  16933. private _autoClearDepthStencil;
  16934. private _customOpaqueSortCompareFn;
  16935. private _customAlphaTestSortCompareFn;
  16936. private _customTransparentSortCompareFn;
  16937. private _renderingGroupInfo;
  16938. /**
  16939. * Instantiates a new rendering group for a particular scene
  16940. * @param scene Defines the scene the groups belongs to
  16941. */
  16942. constructor(scene: Scene);
  16943. private _clearDepthStencilBuffer;
  16944. /**
  16945. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16946. * @hidden
  16947. */
  16948. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16949. /**
  16950. * Resets the different information of the group to prepare a new frame
  16951. * @hidden
  16952. */
  16953. reset(): void;
  16954. /**
  16955. * Dispose and release the group and its associated resources.
  16956. * @hidden
  16957. */
  16958. dispose(): void;
  16959. /**
  16960. * Clear the info related to rendering groups preventing retention points during dispose.
  16961. */
  16962. freeRenderingGroups(): void;
  16963. private _prepareRenderingGroup;
  16964. /**
  16965. * Add a sprite manager to the rendering manager in order to render it this frame.
  16966. * @param spriteManager Define the sprite manager to render
  16967. */
  16968. dispatchSprites(spriteManager: ISpriteManager): void;
  16969. /**
  16970. * Add a particle system to the rendering manager in order to render it this frame.
  16971. * @param particleSystem Define the particle system to render
  16972. */
  16973. dispatchParticles(particleSystem: IParticleSystem): void;
  16974. /**
  16975. * Add a submesh to the manager in order to render it this frame
  16976. * @param subMesh The submesh to dispatch
  16977. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16978. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16979. */
  16980. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16981. /**
  16982. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16983. * This allowed control for front to back rendering or reversly depending of the special needs.
  16984. *
  16985. * @param renderingGroupId The rendering group id corresponding to its index
  16986. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16987. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16988. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16989. */
  16990. 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;
  16991. /**
  16992. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16993. *
  16994. * @param renderingGroupId The rendering group id corresponding to its index
  16995. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16996. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16997. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16998. */
  16999. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17000. /**
  17001. * Gets the current auto clear configuration for one rendering group of the rendering
  17002. * manager.
  17003. * @param index the rendering group index to get the information for
  17004. * @returns The auto clear setup for the requested rendering group
  17005. */
  17006. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17007. }
  17008. }
  17009. declare module BABYLON {
  17010. /**
  17011. * This Helps creating a texture that will be created from a camera in your scene.
  17012. * It is basically a dynamic texture that could be used to create special effects for instance.
  17013. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17014. */
  17015. export class RenderTargetTexture extends Texture {
  17016. isCube: boolean;
  17017. /**
  17018. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17019. */
  17020. static readonly REFRESHRATE_RENDER_ONCE: number;
  17021. /**
  17022. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17023. */
  17024. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17025. /**
  17026. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17027. * the central point of your effect and can save a lot of performances.
  17028. */
  17029. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17030. /**
  17031. * Use this predicate to dynamically define the list of mesh you want to render.
  17032. * If set, the renderList property will be overwritten.
  17033. */
  17034. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17035. private _renderList;
  17036. /**
  17037. * Use this list to define the list of mesh you want to render.
  17038. */
  17039. renderList: Nullable<Array<AbstractMesh>>;
  17040. private _hookArray;
  17041. /**
  17042. * Define if particles should be rendered in your texture.
  17043. */
  17044. renderParticles: boolean;
  17045. /**
  17046. * Define if sprites should be rendered in your texture.
  17047. */
  17048. renderSprites: boolean;
  17049. /**
  17050. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17051. */
  17052. coordinatesMode: number;
  17053. /**
  17054. * Define the camera used to render the texture.
  17055. */
  17056. activeCamera: Nullable<Camera>;
  17057. /**
  17058. * Override the render function of the texture with your own one.
  17059. */
  17060. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17061. /**
  17062. * Define if camera post processes should be use while rendering the texture.
  17063. */
  17064. useCameraPostProcesses: boolean;
  17065. /**
  17066. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17067. */
  17068. ignoreCameraViewport: boolean;
  17069. private _postProcessManager;
  17070. private _postProcesses;
  17071. private _resizeObserver;
  17072. /**
  17073. * An event triggered when the texture is unbind.
  17074. */
  17075. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17076. /**
  17077. * An event triggered when the texture is unbind.
  17078. */
  17079. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17080. private _onAfterUnbindObserver;
  17081. /**
  17082. * Set a after unbind callback in the texture.
  17083. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17084. */
  17085. onAfterUnbind: () => void;
  17086. /**
  17087. * An event triggered before rendering the texture
  17088. */
  17089. onBeforeRenderObservable: Observable<number>;
  17090. private _onBeforeRenderObserver;
  17091. /**
  17092. * Set a before render callback in the texture.
  17093. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17094. */
  17095. onBeforeRender: (faceIndex: number) => void;
  17096. /**
  17097. * An event triggered after rendering the texture
  17098. */
  17099. onAfterRenderObservable: Observable<number>;
  17100. private _onAfterRenderObserver;
  17101. /**
  17102. * Set a after render callback in the texture.
  17103. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17104. */
  17105. onAfterRender: (faceIndex: number) => void;
  17106. /**
  17107. * An event triggered after the texture clear
  17108. */
  17109. onClearObservable: Observable<Engine>;
  17110. private _onClearObserver;
  17111. /**
  17112. * Set a clear callback in the texture.
  17113. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17114. */
  17115. onClear: (Engine: Engine) => void;
  17116. /**
  17117. * Define the clear color of the Render Target if it should be different from the scene.
  17118. */
  17119. clearColor: Color4;
  17120. protected _size: number | {
  17121. width: number;
  17122. height: number;
  17123. };
  17124. protected _initialSizeParameter: number | {
  17125. width: number;
  17126. height: number;
  17127. } | {
  17128. ratio: number;
  17129. };
  17130. protected _sizeRatio: Nullable<number>;
  17131. /** @hidden */
  17132. _generateMipMaps: boolean;
  17133. protected _renderingManager: RenderingManager;
  17134. /** @hidden */
  17135. _waitingRenderList: string[];
  17136. protected _doNotChangeAspectRatio: boolean;
  17137. protected _currentRefreshId: number;
  17138. protected _refreshRate: number;
  17139. protected _textureMatrix: Matrix;
  17140. protected _samples: number;
  17141. protected _renderTargetOptions: RenderTargetCreationOptions;
  17142. /**
  17143. * Gets render target creation options that were used.
  17144. */
  17145. readonly renderTargetOptions: RenderTargetCreationOptions;
  17146. protected _engine: Engine;
  17147. protected _onRatioRescale(): void;
  17148. /**
  17149. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17150. * It must define where the camera used to render the texture is set
  17151. */
  17152. boundingBoxPosition: Vector3;
  17153. private _boundingBoxSize;
  17154. /**
  17155. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17156. * When defined, the cubemap will switch to local mode
  17157. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17158. * @example https://www.babylonjs-playground.com/#RNASML
  17159. */
  17160. boundingBoxSize: Vector3;
  17161. /**
  17162. * In case the RTT has been created with a depth texture, get the associated
  17163. * depth texture.
  17164. * Otherwise, return null.
  17165. */
  17166. depthStencilTexture: Nullable<InternalTexture>;
  17167. /**
  17168. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17169. * or used a shadow, depth texture...
  17170. * @param name The friendly name of the texture
  17171. * @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)
  17172. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17173. * @param generateMipMaps True if mip maps need to be generated after render.
  17174. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17175. * @param type The type of the buffer in the RTT (int, half float, float...)
  17176. * @param isCube True if a cube texture needs to be created
  17177. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17178. * @param generateDepthBuffer True to generate a depth buffer
  17179. * @param generateStencilBuffer True to generate a stencil buffer
  17180. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17181. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17182. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17183. */
  17184. constructor(name: string, size: number | {
  17185. width: number;
  17186. height: number;
  17187. } | {
  17188. ratio: number;
  17189. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17190. /**
  17191. * Creates a depth stencil texture.
  17192. * This is only available in WebGL 2 or with the depth texture extension available.
  17193. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17194. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17195. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17196. */
  17197. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17198. private _processSizeParameter;
  17199. /**
  17200. * Define the number of samples to use in case of MSAA.
  17201. * It defaults to one meaning no MSAA has been enabled.
  17202. */
  17203. samples: number;
  17204. /**
  17205. * Resets the refresh counter of the texture and start bak from scratch.
  17206. * Could be useful to regenerate the texture if it is setup to render only once.
  17207. */
  17208. resetRefreshCounter(): void;
  17209. /**
  17210. * Define the refresh rate of the texture or the rendering frequency.
  17211. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17212. */
  17213. refreshRate: number;
  17214. /**
  17215. * Adds a post process to the render target rendering passes.
  17216. * @param postProcess define the post process to add
  17217. */
  17218. addPostProcess(postProcess: PostProcess): void;
  17219. /**
  17220. * Clear all the post processes attached to the render target
  17221. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17222. */
  17223. clearPostProcesses(dispose?: boolean): void;
  17224. /**
  17225. * Remove one of the post process from the list of attached post processes to the texture
  17226. * @param postProcess define the post process to remove from the list
  17227. */
  17228. removePostProcess(postProcess: PostProcess): void;
  17229. /** @hidden */
  17230. _shouldRender(): boolean;
  17231. /**
  17232. * Gets the actual render size of the texture.
  17233. * @returns the width of the render size
  17234. */
  17235. getRenderSize(): number;
  17236. /**
  17237. * Gets the actual render width of the texture.
  17238. * @returns the width of the render size
  17239. */
  17240. getRenderWidth(): number;
  17241. /**
  17242. * Gets the actual render height of the texture.
  17243. * @returns the height of the render size
  17244. */
  17245. getRenderHeight(): number;
  17246. /**
  17247. * Get if the texture can be rescaled or not.
  17248. */
  17249. readonly canRescale: boolean;
  17250. /**
  17251. * Resize the texture using a ratio.
  17252. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17253. */
  17254. scale(ratio: number): void;
  17255. /**
  17256. * Get the texture reflection matrix used to rotate/transform the reflection.
  17257. * @returns the reflection matrix
  17258. */
  17259. getReflectionTextureMatrix(): Matrix;
  17260. /**
  17261. * Resize the texture to a new desired size.
  17262. * Be carrefull as it will recreate all the data in the new texture.
  17263. * @param size Define the new size. It can be:
  17264. * - a number for squared texture,
  17265. * - an object containing { width: number, height: number }
  17266. * - or an object containing a ratio { ratio: number }
  17267. */
  17268. resize(size: number | {
  17269. width: number;
  17270. height: number;
  17271. } | {
  17272. ratio: number;
  17273. }): void;
  17274. /**
  17275. * Renders all the objects from the render list into the texture.
  17276. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17277. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17278. */
  17279. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17280. private _bestReflectionRenderTargetDimension;
  17281. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17282. private renderToTarget;
  17283. /**
  17284. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17285. * This allowed control for front to back rendering or reversly depending of the special needs.
  17286. *
  17287. * @param renderingGroupId The rendering group id corresponding to its index
  17288. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17289. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17290. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17291. */
  17292. 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;
  17293. /**
  17294. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17295. *
  17296. * @param renderingGroupId The rendering group id corresponding to its index
  17297. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17298. */
  17299. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17300. /**
  17301. * Clones the texture.
  17302. * @returns the cloned texture
  17303. */
  17304. clone(): RenderTargetTexture;
  17305. /**
  17306. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17307. * @returns The JSON representation of the texture
  17308. */
  17309. serialize(): any;
  17310. /**
  17311. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17312. */
  17313. disposeFramebufferObjects(): void;
  17314. /**
  17315. * Dispose the texture and release its associated resources.
  17316. */
  17317. dispose(): void;
  17318. /** @hidden */
  17319. _rebuild(): void;
  17320. /**
  17321. * Clear the info related to rendering groups preventing retention point in material dispose.
  17322. */
  17323. freeRenderingGroups(): void;
  17324. }
  17325. }
  17326. declare module BABYLON {
  17327. /**
  17328. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17329. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17330. * You can then easily use it as a reflectionTexture on a flat surface.
  17331. * In case the surface is not a plane, please consider relying on reflection probes.
  17332. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17333. */
  17334. export class MirrorTexture extends RenderTargetTexture {
  17335. private scene;
  17336. /**
  17337. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17338. * 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.
  17339. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17340. */
  17341. mirrorPlane: Plane;
  17342. /**
  17343. * Define the blur ratio used to blur the reflection if needed.
  17344. */
  17345. blurRatio: number;
  17346. /**
  17347. * Define the adaptive blur kernel used to blur the reflection if needed.
  17348. * This will autocompute the closest best match for the `blurKernel`
  17349. */
  17350. adaptiveBlurKernel: number;
  17351. /**
  17352. * Define the blur kernel used to blur the reflection if needed.
  17353. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17354. */
  17355. blurKernel: number;
  17356. /**
  17357. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17358. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17359. */
  17360. blurKernelX: number;
  17361. /**
  17362. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17363. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17364. */
  17365. blurKernelY: number;
  17366. private _autoComputeBlurKernel;
  17367. protected _onRatioRescale(): void;
  17368. private _updateGammaSpace;
  17369. private _imageProcessingConfigChangeObserver;
  17370. private _transformMatrix;
  17371. private _mirrorMatrix;
  17372. private _savedViewMatrix;
  17373. private _blurX;
  17374. private _blurY;
  17375. private _adaptiveBlurKernel;
  17376. private _blurKernelX;
  17377. private _blurKernelY;
  17378. private _blurRatio;
  17379. /**
  17380. * Instantiates a Mirror Texture.
  17381. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17382. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17383. * You can then easily use it as a reflectionTexture on a flat surface.
  17384. * In case the surface is not a plane, please consider relying on reflection probes.
  17385. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17386. * @param name
  17387. * @param size
  17388. * @param scene
  17389. * @param generateMipMaps
  17390. * @param type
  17391. * @param samplingMode
  17392. * @param generateDepthBuffer
  17393. */
  17394. constructor(name: string, size: number | {
  17395. width: number;
  17396. height: number;
  17397. } | {
  17398. ratio: number;
  17399. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17400. private _preparePostProcesses;
  17401. /**
  17402. * Clone the mirror texture.
  17403. * @returns the cloned texture
  17404. */
  17405. clone(): MirrorTexture;
  17406. /**
  17407. * Serialize the texture to a JSON representation you could use in Parse later on
  17408. * @returns the serialized JSON representation
  17409. */
  17410. serialize(): any;
  17411. /**
  17412. * Dispose the texture and release its associated resources.
  17413. */
  17414. dispose(): void;
  17415. }
  17416. }
  17417. declare module BABYLON {
  17418. /**
  17419. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17420. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17421. */
  17422. export class Texture extends BaseTexture {
  17423. /** @hidden */
  17424. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17425. /** @hidden */
  17426. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17427. /** @hidden */
  17428. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17429. /** nearest is mag = nearest and min = nearest and mip = linear */
  17430. static readonly NEAREST_SAMPLINGMODE: number;
  17431. /** nearest is mag = nearest and min = nearest and mip = linear */
  17432. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17433. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17434. static readonly BILINEAR_SAMPLINGMODE: number;
  17435. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17436. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17437. /** Trilinear is mag = linear and min = linear and mip = linear */
  17438. static readonly TRILINEAR_SAMPLINGMODE: number;
  17439. /** Trilinear is mag = linear and min = linear and mip = linear */
  17440. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17441. /** mag = nearest and min = nearest and mip = nearest */
  17442. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17443. /** mag = nearest and min = linear and mip = nearest */
  17444. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17445. /** mag = nearest and min = linear and mip = linear */
  17446. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17447. /** mag = nearest and min = linear and mip = none */
  17448. static readonly NEAREST_LINEAR: number;
  17449. /** mag = nearest and min = nearest and mip = none */
  17450. static readonly NEAREST_NEAREST: number;
  17451. /** mag = linear and min = nearest and mip = nearest */
  17452. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17453. /** mag = linear and min = nearest and mip = linear */
  17454. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17455. /** mag = linear and min = linear and mip = none */
  17456. static readonly LINEAR_LINEAR: number;
  17457. /** mag = linear and min = nearest and mip = none */
  17458. static readonly LINEAR_NEAREST: number;
  17459. /** Explicit coordinates mode */
  17460. static readonly EXPLICIT_MODE: number;
  17461. /** Spherical coordinates mode */
  17462. static readonly SPHERICAL_MODE: number;
  17463. /** Planar coordinates mode */
  17464. static readonly PLANAR_MODE: number;
  17465. /** Cubic coordinates mode */
  17466. static readonly CUBIC_MODE: number;
  17467. /** Projection coordinates mode */
  17468. static readonly PROJECTION_MODE: number;
  17469. /** Inverse Cubic coordinates mode */
  17470. static readonly SKYBOX_MODE: number;
  17471. /** Inverse Cubic coordinates mode */
  17472. static readonly INVCUBIC_MODE: number;
  17473. /** Equirectangular coordinates mode */
  17474. static readonly EQUIRECTANGULAR_MODE: number;
  17475. /** Equirectangular Fixed coordinates mode */
  17476. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17477. /** Equirectangular Fixed Mirrored coordinates mode */
  17478. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17479. /** Texture is not repeating outside of 0..1 UVs */
  17480. static readonly CLAMP_ADDRESSMODE: number;
  17481. /** Texture is repeating outside of 0..1 UVs */
  17482. static readonly WRAP_ADDRESSMODE: number;
  17483. /** Texture is repeating and mirrored */
  17484. static readonly MIRROR_ADDRESSMODE: number;
  17485. /**
  17486. * 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
  17487. */
  17488. static UseSerializedUrlIfAny: boolean;
  17489. /**
  17490. * Define the url of the texture.
  17491. */
  17492. url: Nullable<string>;
  17493. /**
  17494. * Define an offset on the texture to offset the u coordinates of the UVs
  17495. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17496. */
  17497. uOffset: number;
  17498. /**
  17499. * Define an offset on the texture to offset the v coordinates of the UVs
  17500. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17501. */
  17502. vOffset: number;
  17503. /**
  17504. * Define an offset on the texture to scale the u coordinates of the UVs
  17505. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17506. */
  17507. uScale: number;
  17508. /**
  17509. * Define an offset on the texture to scale the v coordinates of the UVs
  17510. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17511. */
  17512. vScale: number;
  17513. /**
  17514. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17515. * @see http://doc.babylonjs.com/how_to/more_materials
  17516. */
  17517. uAng: number;
  17518. /**
  17519. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17520. * @see http://doc.babylonjs.com/how_to/more_materials
  17521. */
  17522. vAng: number;
  17523. /**
  17524. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17525. * @see http://doc.babylonjs.com/how_to/more_materials
  17526. */
  17527. wAng: number;
  17528. /**
  17529. * Defines the center of rotation (U)
  17530. */
  17531. uRotationCenter: number;
  17532. /**
  17533. * Defines the center of rotation (V)
  17534. */
  17535. vRotationCenter: number;
  17536. /**
  17537. * Defines the center of rotation (W)
  17538. */
  17539. wRotationCenter: number;
  17540. /**
  17541. * Are mip maps generated for this texture or not.
  17542. */
  17543. readonly noMipmap: boolean;
  17544. private _noMipmap;
  17545. /** @hidden */
  17546. _invertY: boolean;
  17547. private _rowGenerationMatrix;
  17548. private _cachedTextureMatrix;
  17549. private _projectionModeMatrix;
  17550. private _t0;
  17551. private _t1;
  17552. private _t2;
  17553. private _cachedUOffset;
  17554. private _cachedVOffset;
  17555. private _cachedUScale;
  17556. private _cachedVScale;
  17557. private _cachedUAng;
  17558. private _cachedVAng;
  17559. private _cachedWAng;
  17560. private _cachedProjectionMatrixId;
  17561. private _cachedCoordinatesMode;
  17562. /** @hidden */
  17563. protected _initialSamplingMode: number;
  17564. /** @hidden */
  17565. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17566. private _deleteBuffer;
  17567. protected _format: Nullable<number>;
  17568. private _delayedOnLoad;
  17569. private _delayedOnError;
  17570. /**
  17571. * Observable triggered once the texture has been loaded.
  17572. */
  17573. onLoadObservable: Observable<Texture>;
  17574. protected _isBlocking: boolean;
  17575. /**
  17576. * Is the texture preventing material to render while loading.
  17577. * If false, a default texture will be used instead of the loading one during the preparation step.
  17578. */
  17579. isBlocking: boolean;
  17580. /**
  17581. * Get the current sampling mode associated with the texture.
  17582. */
  17583. readonly samplingMode: number;
  17584. /**
  17585. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  17586. */
  17587. readonly invertY: boolean;
  17588. /**
  17589. * Instantiates a new texture.
  17590. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17591. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17592. * @param url define the url of the picture to load as a texture
  17593. * @param scene define the scene the texture will belong to
  17594. * @param noMipmap define if the texture will require mip maps or not
  17595. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17596. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17597. * @param onLoad define a callback triggered when the texture has been loaded
  17598. * @param onError define a callback triggered when an error occurred during the loading session
  17599. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17600. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17601. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17602. */
  17603. 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);
  17604. /**
  17605. * Update the url (and optional buffer) of this texture if url was null during construction.
  17606. * @param url the url of the texture
  17607. * @param buffer the buffer of the texture (defaults to null)
  17608. * @param onLoad callback called when the texture is loaded (defaults to null)
  17609. */
  17610. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  17611. /**
  17612. * Finish the loading sequence of a texture flagged as delayed load.
  17613. * @hidden
  17614. */
  17615. delayLoad(): void;
  17616. private _prepareRowForTextureGeneration;
  17617. /**
  17618. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  17619. * @returns the transform matrix of the texture.
  17620. */
  17621. getTextureMatrix(): Matrix;
  17622. /**
  17623. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  17624. * @returns The reflection texture transform
  17625. */
  17626. getReflectionTextureMatrix(): Matrix;
  17627. /**
  17628. * Clones the texture.
  17629. * @returns the cloned texture
  17630. */
  17631. clone(): Texture;
  17632. /**
  17633. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17634. * @returns The JSON representation of the texture
  17635. */
  17636. serialize(): any;
  17637. /**
  17638. * Get the current class name of the texture useful for serialization or dynamic coding.
  17639. * @returns "Texture"
  17640. */
  17641. getClassName(): string;
  17642. /**
  17643. * Dispose the texture and release its associated resources.
  17644. */
  17645. dispose(): void;
  17646. /**
  17647. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  17648. * @param parsedTexture Define the JSON representation of the texture
  17649. * @param scene Define the scene the parsed texture should be instantiated in
  17650. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  17651. * @returns The parsed texture if successful
  17652. */
  17653. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  17654. /**
  17655. * Creates a texture from its base 64 representation.
  17656. * @param data Define the base64 payload without the data: prefix
  17657. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17658. * @param scene Define the scene the texture should belong to
  17659. * @param noMipmap Forces the texture to not create mip map information if true
  17660. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17661. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17662. * @param onLoad define a callback triggered when the texture has been loaded
  17663. * @param onError define a callback triggered when an error occurred during the loading session
  17664. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17665. * @returns the created texture
  17666. */
  17667. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  17668. /**
  17669. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  17670. * @param data Define the base64 payload without the data: prefix
  17671. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17672. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17673. * @param scene Define the scene the texture should belong to
  17674. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17675. * @param noMipmap Forces the texture to not create mip map information if true
  17676. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17677. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17678. * @param onLoad define a callback triggered when the texture has been loaded
  17679. * @param onError define a callback triggered when an error occurred during the loading session
  17680. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17681. * @returns the created texture
  17682. */
  17683. 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;
  17684. }
  17685. }
  17686. declare module BABYLON {
  17687. /**
  17688. * Defines the options associated with the creation of a shader material.
  17689. */
  17690. export interface IShaderMaterialOptions {
  17691. /**
  17692. * Does the material work in alpha blend mode
  17693. */
  17694. needAlphaBlending: boolean;
  17695. /**
  17696. * Does the material work in alpha test mode
  17697. */
  17698. needAlphaTesting: boolean;
  17699. /**
  17700. * The list of attribute names used in the shader
  17701. */
  17702. attributes: string[];
  17703. /**
  17704. * The list of unifrom names used in the shader
  17705. */
  17706. uniforms: string[];
  17707. /**
  17708. * The list of UBO names used in the shader
  17709. */
  17710. uniformBuffers: string[];
  17711. /**
  17712. * The list of sampler names used in the shader
  17713. */
  17714. samplers: string[];
  17715. /**
  17716. * The list of defines used in the shader
  17717. */
  17718. defines: string[];
  17719. }
  17720. /**
  17721. * 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.
  17722. *
  17723. * This returned material effects how the mesh will look based on the code in the shaders.
  17724. *
  17725. * @see http://doc.babylonjs.com/how_to/shader_material
  17726. */
  17727. export class ShaderMaterial extends Material {
  17728. private _shaderPath;
  17729. private _options;
  17730. private _textures;
  17731. private _textureArrays;
  17732. private _floats;
  17733. private _ints;
  17734. private _floatsArrays;
  17735. private _colors3;
  17736. private _colors3Arrays;
  17737. private _colors4;
  17738. private _vectors2;
  17739. private _vectors3;
  17740. private _vectors4;
  17741. private _matrices;
  17742. private _matrices3x3;
  17743. private _matrices2x2;
  17744. private _vectors2Arrays;
  17745. private _vectors3Arrays;
  17746. private _cachedWorldViewMatrix;
  17747. private _renderId;
  17748. /**
  17749. * Instantiate a new shader material.
  17750. * 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.
  17751. * This returned material effects how the mesh will look based on the code in the shaders.
  17752. * @see http://doc.babylonjs.com/how_to/shader_material
  17753. * @param name Define the name of the material in the scene
  17754. * @param scene Define the scene the material belongs to
  17755. * @param shaderPath Defines the route to the shader code in one of three ways:
  17756. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17757. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17758. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17759. * @param options Define the options used to create the shader
  17760. */
  17761. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17762. /**
  17763. * Gets the current class name of the material e.g. "ShaderMaterial"
  17764. * Mainly use in serialization.
  17765. * @returns the class name
  17766. */
  17767. getClassName(): string;
  17768. /**
  17769. * Specifies if the material will require alpha blending
  17770. * @returns a boolean specifying if alpha blending is needed
  17771. */
  17772. needAlphaBlending(): boolean;
  17773. /**
  17774. * Specifies if this material should be rendered in alpha test mode
  17775. * @returns a boolean specifying if an alpha test is needed.
  17776. */
  17777. needAlphaTesting(): boolean;
  17778. private _checkUniform;
  17779. /**
  17780. * Set a texture in the shader.
  17781. * @param name Define the name of the uniform samplers as defined in the shader
  17782. * @param texture Define the texture to bind to this sampler
  17783. * @return the material itself allowing "fluent" like uniform updates
  17784. */
  17785. setTexture(name: string, texture: Texture): ShaderMaterial;
  17786. /**
  17787. * Set a texture array in the shader.
  17788. * @param name Define the name of the uniform sampler array as defined in the shader
  17789. * @param textures Define the list of textures to bind to this sampler
  17790. * @return the material itself allowing "fluent" like uniform updates
  17791. */
  17792. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17793. /**
  17794. * Set a float in the shader.
  17795. * @param name Define the name of the uniform as defined in the shader
  17796. * @param value Define the value to give to the uniform
  17797. * @return the material itself allowing "fluent" like uniform updates
  17798. */
  17799. setFloat(name: string, value: number): ShaderMaterial;
  17800. /**
  17801. * Set a int in the shader.
  17802. * @param name Define the name of the uniform as defined in the shader
  17803. * @param value Define the value to give to the uniform
  17804. * @return the material itself allowing "fluent" like uniform updates
  17805. */
  17806. setInt(name: string, value: number): ShaderMaterial;
  17807. /**
  17808. * Set an array of floats in the shader.
  17809. * @param name Define the name of the uniform as defined in the shader
  17810. * @param value Define the value to give to the uniform
  17811. * @return the material itself allowing "fluent" like uniform updates
  17812. */
  17813. setFloats(name: string, value: number[]): ShaderMaterial;
  17814. /**
  17815. * Set a vec3 in the shader from a Color3.
  17816. * @param name Define the name of the uniform as defined in the shader
  17817. * @param value Define the value to give to the uniform
  17818. * @return the material itself allowing "fluent" like uniform updates
  17819. */
  17820. setColor3(name: string, value: Color3): ShaderMaterial;
  17821. /**
  17822. * Set a vec3 array in the shader from a Color3 array.
  17823. * @param name Define the name of the uniform as defined in the shader
  17824. * @param value Define the value to give to the uniform
  17825. * @return the material itself allowing "fluent" like uniform updates
  17826. */
  17827. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17828. /**
  17829. * Set a vec4 in the shader from a Color4.
  17830. * @param name Define the name of the uniform as defined in the shader
  17831. * @param value Define the value to give to the uniform
  17832. * @return the material itself allowing "fluent" like uniform updates
  17833. */
  17834. setColor4(name: string, value: Color4): ShaderMaterial;
  17835. /**
  17836. * Set a vec2 in the shader from a Vector2.
  17837. * @param name Define the name of the uniform as defined in the shader
  17838. * @param value Define the value to give to the uniform
  17839. * @return the material itself allowing "fluent" like uniform updates
  17840. */
  17841. setVector2(name: string, value: Vector2): ShaderMaterial;
  17842. /**
  17843. * Set a vec3 in the shader from a Vector3.
  17844. * @param name Define the name of the uniform as defined in the shader
  17845. * @param value Define the value to give to the uniform
  17846. * @return the material itself allowing "fluent" like uniform updates
  17847. */
  17848. setVector3(name: string, value: Vector3): ShaderMaterial;
  17849. /**
  17850. * Set a vec4 in the shader from a Vector4.
  17851. * @param name Define the name of the uniform as defined in the shader
  17852. * @param value Define the value to give to the uniform
  17853. * @return the material itself allowing "fluent" like uniform updates
  17854. */
  17855. setVector4(name: string, value: Vector4): ShaderMaterial;
  17856. /**
  17857. * Set a mat4 in the shader from a Matrix.
  17858. * @param name Define the name of the uniform as defined in the shader
  17859. * @param value Define the value to give to the uniform
  17860. * @return the material itself allowing "fluent" like uniform updates
  17861. */
  17862. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17863. /**
  17864. * Set a mat3 in the shader from a Float32Array.
  17865. * @param name Define the name of the uniform as defined in the shader
  17866. * @param value Define the value to give to the uniform
  17867. * @return the material itself allowing "fluent" like uniform updates
  17868. */
  17869. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17870. /**
  17871. * Set a mat2 in the shader from a Float32Array.
  17872. * @param name Define the name of the uniform as defined in the shader
  17873. * @param value Define the value to give to the uniform
  17874. * @return the material itself allowing "fluent" like uniform updates
  17875. */
  17876. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17877. /**
  17878. * Set a vec2 array in the shader from a number array.
  17879. * @param name Define the name of the uniform as defined in the shader
  17880. * @param value Define the value to give to the uniform
  17881. * @return the material itself allowing "fluent" like uniform updates
  17882. */
  17883. setArray2(name: string, value: number[]): ShaderMaterial;
  17884. /**
  17885. * Set a vec3 array in the shader from a number array.
  17886. * @param name Define the name of the uniform as defined in the shader
  17887. * @param value Define the value to give to the uniform
  17888. * @return the material itself allowing "fluent" like uniform updates
  17889. */
  17890. setArray3(name: string, value: number[]): ShaderMaterial;
  17891. private _checkCache;
  17892. /**
  17893. * Checks if the material is ready to render the requested mesh
  17894. * @param mesh Define the mesh to render
  17895. * @param useInstances Define whether or not the material is used with instances
  17896. * @returns true if ready, otherwise false
  17897. */
  17898. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17899. /**
  17900. * Binds the world matrix to the material
  17901. * @param world defines the world transformation matrix
  17902. */
  17903. bindOnlyWorldMatrix(world: Matrix): void;
  17904. /**
  17905. * Binds the material to the mesh
  17906. * @param world defines the world transformation matrix
  17907. * @param mesh defines the mesh to bind the material to
  17908. */
  17909. bind(world: Matrix, mesh?: Mesh): void;
  17910. /**
  17911. * Gets the active textures from the material
  17912. * @returns an array of textures
  17913. */
  17914. getActiveTextures(): BaseTexture[];
  17915. /**
  17916. * Specifies if the material uses a texture
  17917. * @param texture defines the texture to check against the material
  17918. * @returns a boolean specifying if the material uses the texture
  17919. */
  17920. hasTexture(texture: BaseTexture): boolean;
  17921. /**
  17922. * Makes a duplicate of the material, and gives it a new name
  17923. * @param name defines the new name for the duplicated material
  17924. * @returns the cloned material
  17925. */
  17926. clone(name: string): ShaderMaterial;
  17927. /**
  17928. * Disposes the material
  17929. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17930. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17931. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17932. */
  17933. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17934. /**
  17935. * Serializes this material in a JSON representation
  17936. * @returns the serialized material object
  17937. */
  17938. serialize(): any;
  17939. /**
  17940. * Creates a shader material from parsed shader material data
  17941. * @param source defines the JSON represnetation of the material
  17942. * @param scene defines the hosting scene
  17943. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17944. * @returns a new material
  17945. */
  17946. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17947. }
  17948. }
  17949. declare module BABYLON {
  17950. /** @hidden */
  17951. export var colorPixelShader: {
  17952. name: string;
  17953. shader: string;
  17954. };
  17955. }
  17956. declare module BABYLON {
  17957. /** @hidden */
  17958. export var colorVertexShader: {
  17959. name: string;
  17960. shader: string;
  17961. };
  17962. }
  17963. declare module BABYLON {
  17964. /**
  17965. * Line mesh
  17966. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17967. */
  17968. export class LinesMesh extends Mesh {
  17969. /**
  17970. * If vertex color should be applied to the mesh
  17971. */
  17972. useVertexColor?: boolean | undefined;
  17973. /**
  17974. * If vertex alpha should be applied to the mesh
  17975. */
  17976. useVertexAlpha?: boolean | undefined;
  17977. /**
  17978. * Color of the line (Default: White)
  17979. */
  17980. color: Color3;
  17981. /**
  17982. * Alpha of the line (Default: 1)
  17983. */
  17984. alpha: number;
  17985. /**
  17986. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17987. * This margin is expressed in world space coordinates, so its value may vary.
  17988. * Default value is 0.1
  17989. */
  17990. intersectionThreshold: number;
  17991. private _colorShader;
  17992. /**
  17993. * Creates a new LinesMesh
  17994. * @param name defines the name
  17995. * @param scene defines the hosting scene
  17996. * @param parent defines the parent mesh if any
  17997. * @param source defines the optional source LinesMesh used to clone data from
  17998. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17999. * When false, achieved by calling a clone(), also passing False.
  18000. * This will make creation of children, recursive.
  18001. * @param useVertexColor defines if this LinesMesh supports vertex color
  18002. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  18003. */
  18004. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  18005. /**
  18006. * If vertex color should be applied to the mesh
  18007. */
  18008. useVertexColor?: boolean | undefined,
  18009. /**
  18010. * If vertex alpha should be applied to the mesh
  18011. */
  18012. useVertexAlpha?: boolean | undefined);
  18013. /**
  18014. * Returns the string "LineMesh"
  18015. */
  18016. getClassName(): string;
  18017. /**
  18018. * @hidden
  18019. */
  18020. /**
  18021. * @hidden
  18022. */
  18023. material: Material;
  18024. /**
  18025. * @hidden
  18026. */
  18027. readonly checkCollisions: boolean;
  18028. /** @hidden */
  18029. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  18030. /** @hidden */
  18031. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  18032. /**
  18033. * Disposes of the line mesh
  18034. * @param doNotRecurse If children should be disposed
  18035. */
  18036. dispose(doNotRecurse?: boolean): void;
  18037. /**
  18038. * Returns a new LineMesh object cloned from the current one.
  18039. */
  18040. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  18041. /**
  18042. * Creates a new InstancedLinesMesh object from the mesh model.
  18043. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  18044. * @param name defines the name of the new instance
  18045. * @returns a new InstancedLinesMesh
  18046. */
  18047. createInstance(name: string): InstancedLinesMesh;
  18048. }
  18049. /**
  18050. * Creates an instance based on a source LinesMesh
  18051. */
  18052. export class InstancedLinesMesh extends InstancedMesh {
  18053. /**
  18054. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18055. * This margin is expressed in world space coordinates, so its value may vary.
  18056. * Initilized with the intersectionThreshold value of the source LinesMesh
  18057. */
  18058. intersectionThreshold: number;
  18059. constructor(name: string, source: LinesMesh);
  18060. /**
  18061. * Returns the string "InstancedLinesMesh".
  18062. */
  18063. getClassName(): string;
  18064. }
  18065. }
  18066. declare module BABYLON {
  18067. /**
  18068. * Mesh representing the gorund
  18069. */
  18070. export class GroundMesh extends Mesh {
  18071. /** If octree should be generated */
  18072. generateOctree: boolean;
  18073. private _heightQuads;
  18074. /** @hidden */
  18075. _subdivisionsX: number;
  18076. /** @hidden */
  18077. _subdivisionsY: number;
  18078. /** @hidden */
  18079. _width: number;
  18080. /** @hidden */
  18081. _height: number;
  18082. /** @hidden */
  18083. _minX: number;
  18084. /** @hidden */
  18085. _maxX: number;
  18086. /** @hidden */
  18087. _minZ: number;
  18088. /** @hidden */
  18089. _maxZ: number;
  18090. constructor(name: string, scene: Scene);
  18091. /**
  18092. * "GroundMesh"
  18093. * @returns "GroundMesh"
  18094. */
  18095. getClassName(): string;
  18096. /**
  18097. * The minimum of x and y subdivisions
  18098. */
  18099. readonly subdivisions: number;
  18100. /**
  18101. * X subdivisions
  18102. */
  18103. readonly subdivisionsX: number;
  18104. /**
  18105. * Y subdivisions
  18106. */
  18107. readonly subdivisionsY: number;
  18108. /**
  18109. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  18110. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18111. * @param chunksCount the number of subdivisions for x and y
  18112. * @param octreeBlocksSize (Default: 32)
  18113. */
  18114. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18115. /**
  18116. * Returns a height (y) value in the Worl system :
  18117. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18118. * @param x x coordinate
  18119. * @param z z coordinate
  18120. * @returns the ground y position if (x, z) are outside the ground surface.
  18121. */
  18122. getHeightAtCoordinates(x: number, z: number): number;
  18123. /**
  18124. * Returns a normalized vector (Vector3) orthogonal to the ground
  18125. * at the ground coordinates (x, z) expressed in the World system.
  18126. * @param x x coordinate
  18127. * @param z z coordinate
  18128. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18129. */
  18130. getNormalAtCoordinates(x: number, z: number): Vector3;
  18131. /**
  18132. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18133. * at the ground coordinates (x, z) expressed in the World system.
  18134. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18135. * @param x x coordinate
  18136. * @param z z coordinate
  18137. * @param ref vector to store the result
  18138. * @returns the GroundMesh.
  18139. */
  18140. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18141. /**
  18142. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18143. * if the ground has been updated.
  18144. * This can be used in the render loop.
  18145. * @returns the GroundMesh.
  18146. */
  18147. updateCoordinateHeights(): GroundMesh;
  18148. private _getFacetAt;
  18149. private _initHeightQuads;
  18150. private _computeHeightQuads;
  18151. /**
  18152. * Serializes this ground mesh
  18153. * @param serializationObject object to write serialization to
  18154. */
  18155. serialize(serializationObject: any): void;
  18156. /**
  18157. * Parses a serialized ground mesh
  18158. * @param parsedMesh the serialized mesh
  18159. * @param scene the scene to create the ground mesh in
  18160. * @returns the created ground mesh
  18161. */
  18162. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18163. }
  18164. }
  18165. declare module BABYLON {
  18166. /**
  18167. * Interface for Physics-Joint data
  18168. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18169. */
  18170. export interface PhysicsJointData {
  18171. /**
  18172. * The main pivot of the joint
  18173. */
  18174. mainPivot?: Vector3;
  18175. /**
  18176. * The connected pivot of the joint
  18177. */
  18178. connectedPivot?: Vector3;
  18179. /**
  18180. * The main axis of the joint
  18181. */
  18182. mainAxis?: Vector3;
  18183. /**
  18184. * The connected axis of the joint
  18185. */
  18186. connectedAxis?: Vector3;
  18187. /**
  18188. * The collision of the joint
  18189. */
  18190. collision?: boolean;
  18191. /**
  18192. * Native Oimo/Cannon/Energy data
  18193. */
  18194. nativeParams?: any;
  18195. }
  18196. /**
  18197. * This is a holder class for the physics joint created by the physics plugin
  18198. * It holds a set of functions to control the underlying joint
  18199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18200. */
  18201. export class PhysicsJoint {
  18202. /**
  18203. * The type of the physics joint
  18204. */
  18205. type: number;
  18206. /**
  18207. * The data for the physics joint
  18208. */
  18209. jointData: PhysicsJointData;
  18210. private _physicsJoint;
  18211. protected _physicsPlugin: IPhysicsEnginePlugin;
  18212. /**
  18213. * Initializes the physics joint
  18214. * @param type The type of the physics joint
  18215. * @param jointData The data for the physics joint
  18216. */
  18217. constructor(
  18218. /**
  18219. * The type of the physics joint
  18220. */
  18221. type: number,
  18222. /**
  18223. * The data for the physics joint
  18224. */
  18225. jointData: PhysicsJointData);
  18226. /**
  18227. * Gets the physics joint
  18228. */
  18229. /**
  18230. * Sets the physics joint
  18231. */
  18232. physicsJoint: any;
  18233. /**
  18234. * Sets the physics plugin
  18235. */
  18236. physicsPlugin: IPhysicsEnginePlugin;
  18237. /**
  18238. * Execute a function that is physics-plugin specific.
  18239. * @param {Function} func the function that will be executed.
  18240. * It accepts two parameters: the physics world and the physics joint
  18241. */
  18242. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  18243. /**
  18244. * Distance-Joint type
  18245. */
  18246. static DistanceJoint: number;
  18247. /**
  18248. * Hinge-Joint type
  18249. */
  18250. static HingeJoint: number;
  18251. /**
  18252. * Ball-and-Socket joint type
  18253. */
  18254. static BallAndSocketJoint: number;
  18255. /**
  18256. * Wheel-Joint type
  18257. */
  18258. static WheelJoint: number;
  18259. /**
  18260. * Slider-Joint type
  18261. */
  18262. static SliderJoint: number;
  18263. /**
  18264. * Prismatic-Joint type
  18265. */
  18266. static PrismaticJoint: number;
  18267. /**
  18268. * Universal-Joint type
  18269. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  18270. */
  18271. static UniversalJoint: number;
  18272. /**
  18273. * Hinge-Joint 2 type
  18274. */
  18275. static Hinge2Joint: number;
  18276. /**
  18277. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  18278. */
  18279. static PointToPointJoint: number;
  18280. /**
  18281. * Spring-Joint type
  18282. */
  18283. static SpringJoint: number;
  18284. /**
  18285. * Lock-Joint type
  18286. */
  18287. static LockJoint: number;
  18288. }
  18289. /**
  18290. * A class representing a physics distance joint
  18291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18292. */
  18293. export class DistanceJoint extends PhysicsJoint {
  18294. /**
  18295. *
  18296. * @param jointData The data for the Distance-Joint
  18297. */
  18298. constructor(jointData: DistanceJointData);
  18299. /**
  18300. * Update the predefined distance.
  18301. * @param maxDistance The maximum preferred distance
  18302. * @param minDistance The minimum preferred distance
  18303. */
  18304. updateDistance(maxDistance: number, minDistance?: number): void;
  18305. }
  18306. /**
  18307. * Represents a Motor-Enabled Joint
  18308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18309. */
  18310. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  18311. /**
  18312. * Initializes the Motor-Enabled Joint
  18313. * @param type The type of the joint
  18314. * @param jointData The physica joint data for the joint
  18315. */
  18316. constructor(type: number, jointData: PhysicsJointData);
  18317. /**
  18318. * Set the motor values.
  18319. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18320. * @param force the force to apply
  18321. * @param maxForce max force for this motor.
  18322. */
  18323. setMotor(force?: number, maxForce?: number): void;
  18324. /**
  18325. * Set the motor's limits.
  18326. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18327. * @param upperLimit The upper limit of the motor
  18328. * @param lowerLimit The lower limit of the motor
  18329. */
  18330. setLimit(upperLimit: number, lowerLimit?: number): void;
  18331. }
  18332. /**
  18333. * This class represents a single physics Hinge-Joint
  18334. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18335. */
  18336. export class HingeJoint extends MotorEnabledJoint {
  18337. /**
  18338. * Initializes the Hinge-Joint
  18339. * @param jointData The joint data for the Hinge-Joint
  18340. */
  18341. constructor(jointData: PhysicsJointData);
  18342. /**
  18343. * Set the motor values.
  18344. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18345. * @param {number} force the force to apply
  18346. * @param {number} maxForce max force for this motor.
  18347. */
  18348. setMotor(force?: number, maxForce?: number): void;
  18349. /**
  18350. * Set the motor's limits.
  18351. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18352. * @param upperLimit The upper limit of the motor
  18353. * @param lowerLimit The lower limit of the motor
  18354. */
  18355. setLimit(upperLimit: number, lowerLimit?: number): void;
  18356. }
  18357. /**
  18358. * This class represents a dual hinge physics joint (same as wheel joint)
  18359. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18360. */
  18361. export class Hinge2Joint extends MotorEnabledJoint {
  18362. /**
  18363. * Initializes the Hinge2-Joint
  18364. * @param jointData The joint data for the Hinge2-Joint
  18365. */
  18366. constructor(jointData: PhysicsJointData);
  18367. /**
  18368. * Set the motor values.
  18369. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18370. * @param {number} force the force to apply
  18371. * @param {number} maxForce max force for this motor.
  18372. * @param {motorIndex} the motor's index, 0 or 1.
  18373. */
  18374. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18375. /**
  18376. * Set the motor limits.
  18377. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18378. * @param {number} upperLimit the upper limit
  18379. * @param {number} lowerLimit lower limit
  18380. * @param {motorIndex} the motor's index, 0 or 1.
  18381. */
  18382. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18383. }
  18384. /**
  18385. * Interface for a motor enabled joint
  18386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18387. */
  18388. export interface IMotorEnabledJoint {
  18389. /**
  18390. * Physics joint
  18391. */
  18392. physicsJoint: any;
  18393. /**
  18394. * Sets the motor of the motor-enabled joint
  18395. * @param force The force of the motor
  18396. * @param maxForce The maximum force of the motor
  18397. * @param motorIndex The index of the motor
  18398. */
  18399. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18400. /**
  18401. * Sets the limit of the motor
  18402. * @param upperLimit The upper limit of the motor
  18403. * @param lowerLimit The lower limit of the motor
  18404. * @param motorIndex The index of the motor
  18405. */
  18406. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18407. }
  18408. /**
  18409. * Joint data for a Distance-Joint
  18410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18411. */
  18412. export interface DistanceJointData extends PhysicsJointData {
  18413. /**
  18414. * Max distance the 2 joint objects can be apart
  18415. */
  18416. maxDistance: number;
  18417. }
  18418. /**
  18419. * Joint data from a spring joint
  18420. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18421. */
  18422. export interface SpringJointData extends PhysicsJointData {
  18423. /**
  18424. * Length of the spring
  18425. */
  18426. length: number;
  18427. /**
  18428. * Stiffness of the spring
  18429. */
  18430. stiffness: number;
  18431. /**
  18432. * Damping of the spring
  18433. */
  18434. damping: number;
  18435. /** this callback will be called when applying the force to the impostors. */
  18436. forceApplicationCallback: () => void;
  18437. }
  18438. }
  18439. declare module BABYLON {
  18440. /**
  18441. * Interface used to describe a physics joint
  18442. */
  18443. export interface PhysicsImpostorJoint {
  18444. /** Defines the main impostor to which the joint is linked */
  18445. mainImpostor: PhysicsImpostor;
  18446. /** Defines the impostor that is connected to the main impostor using this joint */
  18447. connectedImpostor: PhysicsImpostor;
  18448. /** Defines the joint itself */
  18449. joint: PhysicsJoint;
  18450. }
  18451. /** @hidden */
  18452. export interface IPhysicsEnginePlugin {
  18453. world: any;
  18454. name: string;
  18455. setGravity(gravity: Vector3): void;
  18456. setTimeStep(timeStep: number): void;
  18457. getTimeStep(): number;
  18458. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18459. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18460. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18461. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18462. removePhysicsBody(impostor: PhysicsImpostor): void;
  18463. generateJoint(joint: PhysicsImpostorJoint): void;
  18464. removeJoint(joint: PhysicsImpostorJoint): void;
  18465. isSupported(): boolean;
  18466. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18467. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18468. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18469. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18470. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18471. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18472. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18473. getBodyMass(impostor: PhysicsImpostor): number;
  18474. getBodyFriction(impostor: PhysicsImpostor): number;
  18475. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18476. getBodyRestitution(impostor: PhysicsImpostor): number;
  18477. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18478. sleepBody(impostor: PhysicsImpostor): void;
  18479. wakeUpBody(impostor: PhysicsImpostor): void;
  18480. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18481. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18482. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18483. getRadius(impostor: PhysicsImpostor): number;
  18484. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18485. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18486. dispose(): void;
  18487. }
  18488. /**
  18489. * Interface used to define a physics engine
  18490. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18491. */
  18492. export interface IPhysicsEngine {
  18493. /**
  18494. * Gets the gravity vector used by the simulation
  18495. */
  18496. gravity: Vector3;
  18497. /**
  18498. * Sets the gravity vector used by the simulation
  18499. * @param gravity defines the gravity vector to use
  18500. */
  18501. setGravity(gravity: Vector3): void;
  18502. /**
  18503. * Set the time step of the physics engine.
  18504. * Default is 1/60.
  18505. * To slow it down, enter 1/600 for example.
  18506. * To speed it up, 1/30
  18507. * @param newTimeStep the new timestep to apply to this world.
  18508. */
  18509. setTimeStep(newTimeStep: number): void;
  18510. /**
  18511. * Get the time step of the physics engine.
  18512. * @returns the current time step
  18513. */
  18514. getTimeStep(): number;
  18515. /**
  18516. * Release all resources
  18517. */
  18518. dispose(): void;
  18519. /**
  18520. * Gets the name of the current physics plugin
  18521. * @returns the name of the plugin
  18522. */
  18523. getPhysicsPluginName(): string;
  18524. /**
  18525. * Adding a new impostor for the impostor tracking.
  18526. * This will be done by the impostor itself.
  18527. * @param impostor the impostor to add
  18528. */
  18529. addImpostor(impostor: PhysicsImpostor): void;
  18530. /**
  18531. * Remove an impostor from the engine.
  18532. * This impostor and its mesh will not longer be updated by the physics engine.
  18533. * @param impostor the impostor to remove
  18534. */
  18535. removeImpostor(impostor: PhysicsImpostor): void;
  18536. /**
  18537. * Add a joint to the physics engine
  18538. * @param mainImpostor defines the main impostor to which the joint is added.
  18539. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  18540. * @param joint defines the joint that will connect both impostors.
  18541. */
  18542. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18543. /**
  18544. * Removes a joint from the simulation
  18545. * @param mainImpostor defines the impostor used with the joint
  18546. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  18547. * @param joint defines the joint to remove
  18548. */
  18549. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18550. /**
  18551. * Gets the current plugin used to run the simulation
  18552. * @returns current plugin
  18553. */
  18554. getPhysicsPlugin(): IPhysicsEnginePlugin;
  18555. /**
  18556. * Gets the list of physic impostors
  18557. * @returns an array of PhysicsImpostor
  18558. */
  18559. getImpostors(): Array<PhysicsImpostor>;
  18560. /**
  18561. * Gets the impostor for a physics enabled object
  18562. * @param object defines the object impersonated by the impostor
  18563. * @returns the PhysicsImpostor or null if not found
  18564. */
  18565. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18566. /**
  18567. * Gets the impostor for a physics body object
  18568. * @param body defines physics body used by the impostor
  18569. * @returns the PhysicsImpostor or null if not found
  18570. */
  18571. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  18572. /**
  18573. * Called by the scene. No need to call it.
  18574. * @param delta defines the timespam between frames
  18575. */
  18576. _step(delta: number): void;
  18577. }
  18578. }
  18579. declare module BABYLON {
  18580. /**
  18581. * The interface for the physics imposter parameters
  18582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18583. */
  18584. export interface PhysicsImpostorParameters {
  18585. /**
  18586. * The mass of the physics imposter
  18587. */
  18588. mass: number;
  18589. /**
  18590. * The friction of the physics imposter
  18591. */
  18592. friction?: number;
  18593. /**
  18594. * The coefficient of restitution of the physics imposter
  18595. */
  18596. restitution?: number;
  18597. /**
  18598. * The native options of the physics imposter
  18599. */
  18600. nativeOptions?: any;
  18601. /**
  18602. * Specifies if the parent should be ignored
  18603. */
  18604. ignoreParent?: boolean;
  18605. /**
  18606. * Specifies if bi-directional transformations should be disabled
  18607. */
  18608. disableBidirectionalTransformation?: boolean;
  18609. }
  18610. /**
  18611. * Interface for a physics-enabled object
  18612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18613. */
  18614. export interface IPhysicsEnabledObject {
  18615. /**
  18616. * The position of the physics-enabled object
  18617. */
  18618. position: Vector3;
  18619. /**
  18620. * The rotation of the physics-enabled object
  18621. */
  18622. rotationQuaternion: Nullable<Quaternion>;
  18623. /**
  18624. * The scale of the physics-enabled object
  18625. */
  18626. scaling: Vector3;
  18627. /**
  18628. * The rotation of the physics-enabled object
  18629. */
  18630. rotation?: Vector3;
  18631. /**
  18632. * The parent of the physics-enabled object
  18633. */
  18634. parent?: any;
  18635. /**
  18636. * The bounding info of the physics-enabled object
  18637. * @returns The bounding info of the physics-enabled object
  18638. */
  18639. getBoundingInfo(): BoundingInfo;
  18640. /**
  18641. * Computes the world matrix
  18642. * @param force Specifies if the world matrix should be computed by force
  18643. * @returns A world matrix
  18644. */
  18645. computeWorldMatrix(force: boolean): Matrix;
  18646. /**
  18647. * Gets the world matrix
  18648. * @returns A world matrix
  18649. */
  18650. getWorldMatrix?(): Matrix;
  18651. /**
  18652. * Gets the child meshes
  18653. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  18654. * @returns An array of abstract meshes
  18655. */
  18656. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  18657. /**
  18658. * Gets the vertex data
  18659. * @param kind The type of vertex data
  18660. * @returns A nullable array of numbers, or a float32 array
  18661. */
  18662. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  18663. /**
  18664. * Gets the indices from the mesh
  18665. * @returns A nullable array of index arrays
  18666. */
  18667. getIndices?(): Nullable<IndicesArray>;
  18668. /**
  18669. * Gets the scene from the mesh
  18670. * @returns the indices array or null
  18671. */
  18672. getScene?(): Scene;
  18673. /**
  18674. * Gets the absolute position from the mesh
  18675. * @returns the absolute position
  18676. */
  18677. getAbsolutePosition(): Vector3;
  18678. /**
  18679. * Gets the absolute pivot point from the mesh
  18680. * @returns the absolute pivot point
  18681. */
  18682. getAbsolutePivotPoint(): Vector3;
  18683. /**
  18684. * Rotates the mesh
  18685. * @param axis The axis of rotation
  18686. * @param amount The amount of rotation
  18687. * @param space The space of the rotation
  18688. * @returns The rotation transform node
  18689. */
  18690. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  18691. /**
  18692. * Translates the mesh
  18693. * @param axis The axis of translation
  18694. * @param distance The distance of translation
  18695. * @param space The space of the translation
  18696. * @returns The transform node
  18697. */
  18698. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  18699. /**
  18700. * Sets the absolute position of the mesh
  18701. * @param absolutePosition The absolute position of the mesh
  18702. * @returns The transform node
  18703. */
  18704. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  18705. /**
  18706. * Gets the class name of the mesh
  18707. * @returns The class name
  18708. */
  18709. getClassName(): string;
  18710. }
  18711. /**
  18712. * Represents a physics imposter
  18713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18714. */
  18715. export class PhysicsImpostor {
  18716. /**
  18717. * The physics-enabled object used as the physics imposter
  18718. */
  18719. object: IPhysicsEnabledObject;
  18720. /**
  18721. * The type of the physics imposter
  18722. */
  18723. type: number;
  18724. private _options;
  18725. private _scene?;
  18726. /**
  18727. * The default object size of the imposter
  18728. */
  18729. static DEFAULT_OBJECT_SIZE: Vector3;
  18730. /**
  18731. * The identity quaternion of the imposter
  18732. */
  18733. static IDENTITY_QUATERNION: Quaternion;
  18734. /** @hidden */
  18735. _pluginData: any;
  18736. private _physicsEngine;
  18737. private _physicsBody;
  18738. private _bodyUpdateRequired;
  18739. private _onBeforePhysicsStepCallbacks;
  18740. private _onAfterPhysicsStepCallbacks;
  18741. /** @hidden */
  18742. _onPhysicsCollideCallbacks: Array<{
  18743. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  18744. otherImpostors: Array<PhysicsImpostor>;
  18745. }>;
  18746. private _deltaPosition;
  18747. private _deltaRotation;
  18748. private _deltaRotationConjugated;
  18749. private _parent;
  18750. private _isDisposed;
  18751. private static _tmpVecs;
  18752. private static _tmpQuat;
  18753. /**
  18754. * Specifies if the physics imposter is disposed
  18755. */
  18756. readonly isDisposed: boolean;
  18757. /**
  18758. * Gets the mass of the physics imposter
  18759. */
  18760. mass: number;
  18761. /**
  18762. * Gets the coefficient of friction
  18763. */
  18764. /**
  18765. * Sets the coefficient of friction
  18766. */
  18767. friction: number;
  18768. /**
  18769. * Gets the coefficient of restitution
  18770. */
  18771. /**
  18772. * Sets the coefficient of restitution
  18773. */
  18774. restitution: number;
  18775. /**
  18776. * The unique id of the physics imposter
  18777. * set by the physics engine when adding this impostor to the array
  18778. */
  18779. uniqueId: number;
  18780. private _joints;
  18781. /**
  18782. * Initializes the physics imposter
  18783. * @param object The physics-enabled object used as the physics imposter
  18784. * @param type The type of the physics imposter
  18785. * @param _options The options for the physics imposter
  18786. * @param _scene The Babylon scene
  18787. */
  18788. constructor(
  18789. /**
  18790. * The physics-enabled object used as the physics imposter
  18791. */
  18792. object: IPhysicsEnabledObject,
  18793. /**
  18794. * The type of the physics imposter
  18795. */
  18796. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  18797. /**
  18798. * This function will completly initialize this impostor.
  18799. * It will create a new body - but only if this mesh has no parent.
  18800. * If it has, this impostor will not be used other than to define the impostor
  18801. * of the child mesh.
  18802. * @hidden
  18803. */
  18804. _init(): void;
  18805. private _getPhysicsParent;
  18806. /**
  18807. * Should a new body be generated.
  18808. * @returns boolean specifying if body initialization is required
  18809. */
  18810. isBodyInitRequired(): boolean;
  18811. /**
  18812. * Sets the updated scaling
  18813. * @param updated Specifies if the scaling is updated
  18814. */
  18815. setScalingUpdated(): void;
  18816. /**
  18817. * Force a regeneration of this or the parent's impostor's body.
  18818. * Use under cautious - This will remove all joints already implemented.
  18819. */
  18820. forceUpdate(): void;
  18821. /**
  18822. * Gets the body that holds this impostor. Either its own, or its parent.
  18823. */
  18824. /**
  18825. * Set the physics body. Used mainly by the physics engine/plugin
  18826. */
  18827. physicsBody: any;
  18828. /**
  18829. * Get the parent of the physics imposter
  18830. * @returns Physics imposter or null
  18831. */
  18832. /**
  18833. * Sets the parent of the physics imposter
  18834. */
  18835. parent: Nullable<PhysicsImpostor>;
  18836. /**
  18837. * Resets the update flags
  18838. */
  18839. resetUpdateFlags(): void;
  18840. /**
  18841. * Gets the object extend size
  18842. * @returns the object extend size
  18843. */
  18844. getObjectExtendSize(): Vector3;
  18845. /**
  18846. * Gets the object center
  18847. * @returns The object center
  18848. */
  18849. getObjectCenter(): Vector3;
  18850. /**
  18851. * Get a specific parametes from the options parameter
  18852. * @param paramName The object parameter name
  18853. * @returns The object parameter
  18854. */
  18855. getParam(paramName: string): any;
  18856. /**
  18857. * Sets a specific parameter in the options given to the physics plugin
  18858. * @param paramName The parameter name
  18859. * @param value The value of the parameter
  18860. */
  18861. setParam(paramName: string, value: number): void;
  18862. /**
  18863. * Specifically change the body's mass option. Won't recreate the physics body object
  18864. * @param mass The mass of the physics imposter
  18865. */
  18866. setMass(mass: number): void;
  18867. /**
  18868. * Gets the linear velocity
  18869. * @returns linear velocity or null
  18870. */
  18871. getLinearVelocity(): Nullable<Vector3>;
  18872. /**
  18873. * Sets the linear velocity
  18874. * @param velocity linear velocity or null
  18875. */
  18876. setLinearVelocity(velocity: Nullable<Vector3>): void;
  18877. /**
  18878. * Gets the angular velocity
  18879. * @returns angular velocity or null
  18880. */
  18881. getAngularVelocity(): Nullable<Vector3>;
  18882. /**
  18883. * Sets the angular velocity
  18884. * @param velocity The velocity or null
  18885. */
  18886. setAngularVelocity(velocity: Nullable<Vector3>): void;
  18887. /**
  18888. * Execute a function with the physics plugin native code
  18889. * Provide a function the will have two variables - the world object and the physics body object
  18890. * @param func The function to execute with the physics plugin native code
  18891. */
  18892. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  18893. /**
  18894. * Register a function that will be executed before the physics world is stepping forward
  18895. * @param func The function to execute before the physics world is stepped forward
  18896. */
  18897. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18898. /**
  18899. * Unregister a function that will be executed before the physics world is stepping forward
  18900. * @param func The function to execute before the physics world is stepped forward
  18901. */
  18902. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18903. /**
  18904. * Register a function that will be executed after the physics step
  18905. * @param func The function to execute after physics step
  18906. */
  18907. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18908. /**
  18909. * Unregisters a function that will be executed after the physics step
  18910. * @param func The function to execute after physics step
  18911. */
  18912. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18913. /**
  18914. * register a function that will be executed when this impostor collides against a different body
  18915. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  18916. * @param func Callback that is executed on collision
  18917. */
  18918. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  18919. /**
  18920. * Unregisters the physics imposter on contact
  18921. * @param collideAgainst The physics object to collide against
  18922. * @param func Callback to execute on collision
  18923. */
  18924. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  18925. private _tmpQuat;
  18926. private _tmpQuat2;
  18927. /**
  18928. * Get the parent rotation
  18929. * @returns The parent rotation
  18930. */
  18931. getParentsRotation(): Quaternion;
  18932. /**
  18933. * this function is executed by the physics engine.
  18934. */
  18935. beforeStep: () => void;
  18936. /**
  18937. * this function is executed by the physics engine
  18938. */
  18939. afterStep: () => void;
  18940. /**
  18941. * Legacy collision detection event support
  18942. */
  18943. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  18944. /**
  18945. * event and body object due to cannon's event-based architecture.
  18946. */
  18947. onCollide: (e: {
  18948. body: any;
  18949. }) => void;
  18950. /**
  18951. * Apply a force
  18952. * @param force The force to apply
  18953. * @param contactPoint The contact point for the force
  18954. * @returns The physics imposter
  18955. */
  18956. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18957. /**
  18958. * Apply an impulse
  18959. * @param force The impulse force
  18960. * @param contactPoint The contact point for the impulse force
  18961. * @returns The physics imposter
  18962. */
  18963. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18964. /**
  18965. * A help function to create a joint
  18966. * @param otherImpostor A physics imposter used to create a joint
  18967. * @param jointType The type of joint
  18968. * @param jointData The data for the joint
  18969. * @returns The physics imposter
  18970. */
  18971. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  18972. /**
  18973. * Add a joint to this impostor with a different impostor
  18974. * @param otherImpostor A physics imposter used to add a joint
  18975. * @param joint The joint to add
  18976. * @returns The physics imposter
  18977. */
  18978. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  18979. /**
  18980. * Will keep this body still, in a sleep mode.
  18981. * @returns the physics imposter
  18982. */
  18983. sleep(): PhysicsImpostor;
  18984. /**
  18985. * Wake the body up.
  18986. * @returns The physics imposter
  18987. */
  18988. wakeUp(): PhysicsImpostor;
  18989. /**
  18990. * Clones the physics imposter
  18991. * @param newObject The physics imposter clones to this physics-enabled object
  18992. * @returns A nullable physics imposter
  18993. */
  18994. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18995. /**
  18996. * Disposes the physics imposter
  18997. */
  18998. dispose(): void;
  18999. /**
  19000. * Sets the delta position
  19001. * @param position The delta position amount
  19002. */
  19003. setDeltaPosition(position: Vector3): void;
  19004. /**
  19005. * Sets the delta rotation
  19006. * @param rotation The delta rotation amount
  19007. */
  19008. setDeltaRotation(rotation: Quaternion): void;
  19009. /**
  19010. * Gets the box size of the physics imposter and stores the result in the input parameter
  19011. * @param result Stores the box size
  19012. * @returns The physics imposter
  19013. */
  19014. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19015. /**
  19016. * Gets the radius of the physics imposter
  19017. * @returns Radius of the physics imposter
  19018. */
  19019. getRadius(): number;
  19020. /**
  19021. * Sync a bone with this impostor
  19022. * @param bone The bone to sync to the impostor.
  19023. * @param boneMesh The mesh that the bone is influencing.
  19024. * @param jointPivot The pivot of the joint / bone in local space.
  19025. * @param distToJoint Optional distance from the impostor to the joint.
  19026. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19027. */
  19028. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19029. /**
  19030. * Sync impostor to a bone
  19031. * @param bone The bone that the impostor will be synced to.
  19032. * @param boneMesh The mesh that the bone is influencing.
  19033. * @param jointPivot The pivot of the joint / bone in local space.
  19034. * @param distToJoint Optional distance from the impostor to the joint.
  19035. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19036. * @param boneAxis Optional vector3 axis the bone is aligned with
  19037. */
  19038. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19039. /**
  19040. * No-Imposter type
  19041. */
  19042. static NoImpostor: number;
  19043. /**
  19044. * Sphere-Imposter type
  19045. */
  19046. static SphereImpostor: number;
  19047. /**
  19048. * Box-Imposter type
  19049. */
  19050. static BoxImpostor: number;
  19051. /**
  19052. * Plane-Imposter type
  19053. */
  19054. static PlaneImpostor: number;
  19055. /**
  19056. * Mesh-imposter type
  19057. */
  19058. static MeshImpostor: number;
  19059. /**
  19060. * Cylinder-Imposter type
  19061. */
  19062. static CylinderImpostor: number;
  19063. /**
  19064. * Particle-Imposter type
  19065. */
  19066. static ParticleImpostor: number;
  19067. /**
  19068. * Heightmap-Imposter type
  19069. */
  19070. static HeightmapImpostor: number;
  19071. }
  19072. }
  19073. declare module BABYLON {
  19074. /**
  19075. * Class used to represent a specific level of detail of a mesh
  19076. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19077. */
  19078. export class MeshLODLevel {
  19079. /** Defines the distance where this level should star being displayed */
  19080. distance: number;
  19081. /** Defines the mesh to use to render this level */
  19082. mesh: Nullable<Mesh>;
  19083. /**
  19084. * Creates a new LOD level
  19085. * @param distance defines the distance where this level should star being displayed
  19086. * @param mesh defines the mesh to use to render this level
  19087. */
  19088. constructor(
  19089. /** Defines the distance where this level should star being displayed */
  19090. distance: number,
  19091. /** Defines the mesh to use to render this level */
  19092. mesh: Nullable<Mesh>);
  19093. }
  19094. /**
  19095. * @hidden
  19096. **/
  19097. export class _CreationDataStorage {
  19098. closePath?: boolean;
  19099. closeArray?: boolean;
  19100. idx: number[];
  19101. dashSize: number;
  19102. gapSize: number;
  19103. path3D: Path3D;
  19104. pathArray: Vector3[][];
  19105. arc: number;
  19106. radius: number;
  19107. cap: number;
  19108. tessellation: number;
  19109. }
  19110. /**
  19111. * @hidden
  19112. **/
  19113. class _InstanceDataStorage {
  19114. visibleInstances: any;
  19115. renderIdForInstances: number[];
  19116. batchCache: _InstancesBatch;
  19117. instancesBufferSize: number;
  19118. instancesBuffer: Nullable<Buffer>;
  19119. instancesData: Float32Array;
  19120. overridenInstanceCount: number;
  19121. }
  19122. /**
  19123. * @hidden
  19124. **/
  19125. export class _InstancesBatch {
  19126. mustReturn: boolean;
  19127. visibleInstances: Nullable<InstancedMesh[]>[];
  19128. renderSelf: boolean[];
  19129. }
  19130. /**
  19131. * Class used to represent renderable models
  19132. */
  19133. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19134. /**
  19135. * Mesh side orientation : usually the external or front surface
  19136. */
  19137. static readonly FRONTSIDE: number;
  19138. /**
  19139. * Mesh side orientation : usually the internal or back surface
  19140. */
  19141. static readonly BACKSIDE: number;
  19142. /**
  19143. * Mesh side orientation : both internal and external or front and back surfaces
  19144. */
  19145. static readonly DOUBLESIDE: number;
  19146. /**
  19147. * Mesh side orientation : by default, `FRONTSIDE`
  19148. */
  19149. static readonly DEFAULTSIDE: number;
  19150. /**
  19151. * Mesh cap setting : no cap
  19152. */
  19153. static readonly NO_CAP: number;
  19154. /**
  19155. * Mesh cap setting : one cap at the beginning of the mesh
  19156. */
  19157. static readonly CAP_START: number;
  19158. /**
  19159. * Mesh cap setting : one cap at the end of the mesh
  19160. */
  19161. static readonly CAP_END: number;
  19162. /**
  19163. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19164. */
  19165. static readonly CAP_ALL: number;
  19166. /**
  19167. * Gets the default side orientation.
  19168. * @param orientation the orientation to value to attempt to get
  19169. * @returns the default orientation
  19170. * @hidden
  19171. */
  19172. static _GetDefaultSideOrientation(orientation?: number): number;
  19173. private _onBeforeRenderObservable;
  19174. private _onBeforeBindObservable;
  19175. private _onAfterRenderObservable;
  19176. private _onBeforeDrawObservable;
  19177. /**
  19178. * An event triggered before rendering the mesh
  19179. */
  19180. readonly onBeforeRenderObservable: Observable<Mesh>;
  19181. /**
  19182. * An event triggered before binding the mesh
  19183. */
  19184. readonly onBeforeBindObservable: Observable<Mesh>;
  19185. /**
  19186. * An event triggered after rendering the mesh
  19187. */
  19188. readonly onAfterRenderObservable: Observable<Mesh>;
  19189. /**
  19190. * An event triggered before drawing the mesh
  19191. */
  19192. readonly onBeforeDrawObservable: Observable<Mesh>;
  19193. private _onBeforeDrawObserver;
  19194. /**
  19195. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  19196. */
  19197. onBeforeDraw: () => void;
  19198. /**
  19199. * Gets the delay loading state of the mesh (when delay loading is turned on)
  19200. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  19201. */
  19202. delayLoadState: number;
  19203. /**
  19204. * Gets the list of instances created from this mesh
  19205. * it is not supposed to be modified manually.
  19206. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  19207. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19208. */
  19209. instances: InstancedMesh[];
  19210. /**
  19211. * Gets the file containing delay loading data for this mesh
  19212. */
  19213. delayLoadingFile: string;
  19214. /** @hidden */
  19215. _binaryInfo: any;
  19216. private _LODLevels;
  19217. /**
  19218. * User defined function used to change how LOD level selection is done
  19219. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19220. */
  19221. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  19222. private _morphTargetManager;
  19223. /**
  19224. * Gets or sets the morph target manager
  19225. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19226. */
  19227. morphTargetManager: Nullable<MorphTargetManager>;
  19228. /** @hidden */
  19229. _creationDataStorage: Nullable<_CreationDataStorage>;
  19230. /** @hidden */
  19231. _geometry: Nullable<Geometry>;
  19232. /** @hidden */
  19233. _delayInfo: Array<string>;
  19234. /** @hidden */
  19235. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19236. /** @hidden */
  19237. _instanceDataStorage: _InstanceDataStorage;
  19238. private _effectiveMaterial;
  19239. /** @hidden */
  19240. _shouldGenerateFlatShading: boolean;
  19241. private _preActivateId;
  19242. /** @hidden */
  19243. _originalBuilderSideOrientation: number;
  19244. /**
  19245. * Use this property to change the original side orientation defined at construction time
  19246. */
  19247. overrideMaterialSideOrientation: Nullable<number>;
  19248. private _areNormalsFrozen;
  19249. private _sourcePositions;
  19250. private _sourceNormals;
  19251. private _source;
  19252. private meshMap;
  19253. /**
  19254. * Gets the source mesh (the one used to clone this one from)
  19255. */
  19256. readonly source: Nullable<Mesh>;
  19257. /**
  19258. * Gets or sets a boolean indicating that this mesh does not use index buffer
  19259. */
  19260. isUnIndexed: boolean;
  19261. /**
  19262. * @constructor
  19263. * @param name The value used by scene.getMeshByName() to do a lookup.
  19264. * @param scene The scene to add this mesh to.
  19265. * @param parent The parent of this mesh, if it has one
  19266. * @param source An optional Mesh from which geometry is shared, cloned.
  19267. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19268. * When false, achieved by calling a clone(), also passing False.
  19269. * This will make creation of children, recursive.
  19270. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19271. */
  19272. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19273. /**
  19274. * Gets the class name
  19275. * @returns the string "Mesh".
  19276. */
  19277. getClassName(): string;
  19278. /** @hidden */
  19279. readonly _isMesh: boolean;
  19280. /**
  19281. * Returns a description of this mesh
  19282. * @param fullDetails define if full details about this mesh must be used
  19283. * @returns a descriptive string representing this mesh
  19284. */
  19285. toString(fullDetails?: boolean): string;
  19286. /** @hidden */
  19287. _unBindEffect(): void;
  19288. /**
  19289. * Gets a boolean indicating if this mesh has LOD
  19290. */
  19291. readonly hasLODLevels: boolean;
  19292. /**
  19293. * Gets the list of MeshLODLevel associated with the current mesh
  19294. * @returns an array of MeshLODLevel
  19295. */
  19296. getLODLevels(): MeshLODLevel[];
  19297. private _sortLODLevels;
  19298. /**
  19299. * Add a mesh as LOD level triggered at the given distance.
  19300. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19301. * @param distance The distance from the center of the object to show this level
  19302. * @param mesh The mesh to be added as LOD level (can be null)
  19303. * @return This mesh (for chaining)
  19304. */
  19305. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  19306. /**
  19307. * Returns the LOD level mesh at the passed distance or null if not found.
  19308. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19309. * @param distance The distance from the center of the object to show this level
  19310. * @returns a Mesh or `null`
  19311. */
  19312. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19313. /**
  19314. * Remove a mesh from the LOD array
  19315. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19316. * @param mesh defines the mesh to be removed
  19317. * @return This mesh (for chaining)
  19318. */
  19319. removeLODLevel(mesh: Mesh): Mesh;
  19320. /**
  19321. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19322. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19323. * @param camera defines the camera to use to compute distance
  19324. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  19325. * @return This mesh (for chaining)
  19326. */
  19327. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  19328. /**
  19329. * Gets the mesh internal Geometry object
  19330. */
  19331. readonly geometry: Nullable<Geometry>;
  19332. /**
  19333. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19334. * @returns the total number of vertices
  19335. */
  19336. getTotalVertices(): number;
  19337. /**
  19338. * Returns the content of an associated vertex buffer
  19339. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19340. * - VertexBuffer.PositionKind
  19341. * - VertexBuffer.UVKind
  19342. * - VertexBuffer.UV2Kind
  19343. * - VertexBuffer.UV3Kind
  19344. * - VertexBuffer.UV4Kind
  19345. * - VertexBuffer.UV5Kind
  19346. * - VertexBuffer.UV6Kind
  19347. * - VertexBuffer.ColorKind
  19348. * - VertexBuffer.MatricesIndicesKind
  19349. * - VertexBuffer.MatricesIndicesExtraKind
  19350. * - VertexBuffer.MatricesWeightsKind
  19351. * - VertexBuffer.MatricesWeightsExtraKind
  19352. * @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
  19353. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  19354. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  19355. */
  19356. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19357. /**
  19358. * Returns the mesh VertexBuffer object from the requested `kind`
  19359. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19360. * - VertexBuffer.PositionKind
  19361. * - VertexBuffer.UVKind
  19362. * - VertexBuffer.UV2Kind
  19363. * - VertexBuffer.UV3Kind
  19364. * - VertexBuffer.UV4Kind
  19365. * - VertexBuffer.UV5Kind
  19366. * - VertexBuffer.UV6Kind
  19367. * - VertexBuffer.ColorKind
  19368. * - VertexBuffer.MatricesIndicesKind
  19369. * - VertexBuffer.MatricesIndicesExtraKind
  19370. * - VertexBuffer.MatricesWeightsKind
  19371. * - VertexBuffer.MatricesWeightsExtraKind
  19372. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  19373. */
  19374. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19375. /**
  19376. * Tests if a specific vertex buffer is associated with this mesh
  19377. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19378. * - VertexBuffer.PositionKind
  19379. * - VertexBuffer.UVKind
  19380. * - VertexBuffer.UV2Kind
  19381. * - VertexBuffer.UV3Kind
  19382. * - VertexBuffer.UV4Kind
  19383. * - VertexBuffer.UV5Kind
  19384. * - VertexBuffer.UV6Kind
  19385. * - VertexBuffer.ColorKind
  19386. * - VertexBuffer.MatricesIndicesKind
  19387. * - VertexBuffer.MatricesIndicesExtraKind
  19388. * - VertexBuffer.MatricesWeightsKind
  19389. * - VertexBuffer.MatricesWeightsExtraKind
  19390. * @returns a boolean
  19391. */
  19392. isVerticesDataPresent(kind: string): boolean;
  19393. /**
  19394. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19395. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19396. * - VertexBuffer.PositionKind
  19397. * - VertexBuffer.UVKind
  19398. * - VertexBuffer.UV2Kind
  19399. * - VertexBuffer.UV3Kind
  19400. * - VertexBuffer.UV4Kind
  19401. * - VertexBuffer.UV5Kind
  19402. * - VertexBuffer.UV6Kind
  19403. * - VertexBuffer.ColorKind
  19404. * - VertexBuffer.MatricesIndicesKind
  19405. * - VertexBuffer.MatricesIndicesExtraKind
  19406. * - VertexBuffer.MatricesWeightsKind
  19407. * - VertexBuffer.MatricesWeightsExtraKind
  19408. * @returns a boolean
  19409. */
  19410. isVertexBufferUpdatable(kind: string): boolean;
  19411. /**
  19412. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  19413. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19414. * - VertexBuffer.PositionKind
  19415. * - VertexBuffer.UVKind
  19416. * - VertexBuffer.UV2Kind
  19417. * - VertexBuffer.UV3Kind
  19418. * - VertexBuffer.UV4Kind
  19419. * - VertexBuffer.UV5Kind
  19420. * - VertexBuffer.UV6Kind
  19421. * - VertexBuffer.ColorKind
  19422. * - VertexBuffer.MatricesIndicesKind
  19423. * - VertexBuffer.MatricesIndicesExtraKind
  19424. * - VertexBuffer.MatricesWeightsKind
  19425. * - VertexBuffer.MatricesWeightsExtraKind
  19426. * @returns an array of strings
  19427. */
  19428. getVerticesDataKinds(): string[];
  19429. /**
  19430. * Returns a positive integer : the total number of indices in this mesh geometry.
  19431. * @returns the numner of indices or zero if the mesh has no geometry.
  19432. */
  19433. getTotalIndices(): number;
  19434. /**
  19435. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19436. * @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.
  19437. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19438. * @returns the indices array or an empty array if the mesh has no geometry
  19439. */
  19440. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  19441. readonly isBlocked: boolean;
  19442. /**
  19443. * Determine if the current mesh is ready to be rendered
  19444. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19445. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  19446. * @returns true if all associated assets are ready (material, textures, shaders)
  19447. */
  19448. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  19449. /**
  19450. * 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.
  19451. */
  19452. readonly areNormalsFrozen: boolean;
  19453. /**
  19454. * 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.
  19455. * @returns the current mesh
  19456. */
  19457. freezeNormals(): Mesh;
  19458. /**
  19459. * 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
  19460. * @returns the current mesh
  19461. */
  19462. unfreezeNormals(): Mesh;
  19463. /**
  19464. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  19465. */
  19466. overridenInstanceCount: number;
  19467. /** @hidden */
  19468. _preActivate(): Mesh;
  19469. /** @hidden */
  19470. _preActivateForIntermediateRendering(renderId: number): Mesh;
  19471. /** @hidden */
  19472. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  19473. /**
  19474. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19475. * This means the mesh underlying bounding box and sphere are recomputed.
  19476. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19477. * @returns the current mesh
  19478. */
  19479. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  19480. /** @hidden */
  19481. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  19482. /**
  19483. * This function will subdivide the mesh into multiple submeshes
  19484. * @param count defines the expected number of submeshes
  19485. */
  19486. subdivide(count: number): void;
  19487. /**
  19488. * Copy a FloatArray into a specific associated vertex buffer
  19489. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19490. * - VertexBuffer.PositionKind
  19491. * - VertexBuffer.UVKind
  19492. * - VertexBuffer.UV2Kind
  19493. * - VertexBuffer.UV3Kind
  19494. * - VertexBuffer.UV4Kind
  19495. * - VertexBuffer.UV5Kind
  19496. * - VertexBuffer.UV6Kind
  19497. * - VertexBuffer.ColorKind
  19498. * - VertexBuffer.MatricesIndicesKind
  19499. * - VertexBuffer.MatricesIndicesExtraKind
  19500. * - VertexBuffer.MatricesWeightsKind
  19501. * - VertexBuffer.MatricesWeightsExtraKind
  19502. * @param data defines the data source
  19503. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19504. * @param stride defines the data stride size (can be null)
  19505. * @returns the current mesh
  19506. */
  19507. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19508. /**
  19509. * Flags an associated vertex buffer as updatable
  19510. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  19511. * - VertexBuffer.PositionKind
  19512. * - VertexBuffer.UVKind
  19513. * - VertexBuffer.UV2Kind
  19514. * - VertexBuffer.UV3Kind
  19515. * - VertexBuffer.UV4Kind
  19516. * - VertexBuffer.UV5Kind
  19517. * - VertexBuffer.UV6Kind
  19518. * - VertexBuffer.ColorKind
  19519. * - VertexBuffer.MatricesIndicesKind
  19520. * - VertexBuffer.MatricesIndicesExtraKind
  19521. * - VertexBuffer.MatricesWeightsKind
  19522. * - VertexBuffer.MatricesWeightsExtraKind
  19523. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19524. */
  19525. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  19526. /**
  19527. * Sets the mesh global Vertex Buffer
  19528. * @param buffer defines the buffer to use
  19529. * @returns the current mesh
  19530. */
  19531. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  19532. /**
  19533. * Update a specific associated vertex buffer
  19534. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19535. * - VertexBuffer.PositionKind
  19536. * - VertexBuffer.UVKind
  19537. * - VertexBuffer.UV2Kind
  19538. * - VertexBuffer.UV3Kind
  19539. * - VertexBuffer.UV4Kind
  19540. * - VertexBuffer.UV5Kind
  19541. * - VertexBuffer.UV6Kind
  19542. * - VertexBuffer.ColorKind
  19543. * - VertexBuffer.MatricesIndicesKind
  19544. * - VertexBuffer.MatricesIndicesExtraKind
  19545. * - VertexBuffer.MatricesWeightsKind
  19546. * - VertexBuffer.MatricesWeightsExtraKind
  19547. * @param data defines the data source
  19548. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  19549. * @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)
  19550. * @returns the current mesh
  19551. */
  19552. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19553. /**
  19554. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  19555. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  19556. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  19557. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  19558. * @returns the current mesh
  19559. */
  19560. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  19561. /**
  19562. * Creates a un-shared specific occurence of the geometry for the mesh.
  19563. * @returns the current mesh
  19564. */
  19565. makeGeometryUnique(): Mesh;
  19566. /**
  19567. * Set the index buffer of this mesh
  19568. * @param indices defines the source data
  19569. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  19570. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  19571. * @returns the current mesh
  19572. */
  19573. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  19574. /**
  19575. * Update the current index buffer
  19576. * @param indices defines the source data
  19577. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  19578. * @returns the current mesh
  19579. */
  19580. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  19581. /**
  19582. * Invert the geometry to move from a right handed system to a left handed one.
  19583. * @returns the current mesh
  19584. */
  19585. toLeftHanded(): Mesh;
  19586. /** @hidden */
  19587. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19588. /** @hidden */
  19589. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  19590. /**
  19591. * Registers for this mesh a javascript function called just before the rendering process
  19592. * @param func defines the function to call before rendering this mesh
  19593. * @returns the current mesh
  19594. */
  19595. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19596. /**
  19597. * Disposes a previously registered javascript function called before the rendering
  19598. * @param func defines the function to remove
  19599. * @returns the current mesh
  19600. */
  19601. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19602. /**
  19603. * Registers for this mesh a javascript function called just after the rendering is complete
  19604. * @param func defines the function to call after rendering this mesh
  19605. * @returns the current mesh
  19606. */
  19607. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19608. /**
  19609. * Disposes a previously registered javascript function called after the rendering.
  19610. * @param func defines the function to remove
  19611. * @returns the current mesh
  19612. */
  19613. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19614. /** @hidden */
  19615. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  19616. /** @hidden */
  19617. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  19618. /** @hidden */
  19619. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  19620. /**
  19621. * 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
  19622. * @param subMesh defines the subMesh to render
  19623. * @param enableAlphaMode defines if alpha mode can be changed
  19624. * @returns the current mesh
  19625. */
  19626. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  19627. private _onBeforeDraw;
  19628. /**
  19629. * Renormalize the mesh and patch it up if there are no weights
  19630. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  19631. * However in the case of zero weights then we set just a single influence to 1.
  19632. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  19633. */
  19634. cleanMatrixWeights(): void;
  19635. private normalizeSkinFourWeights;
  19636. private normalizeSkinWeightsAndExtra;
  19637. /**
  19638. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  19639. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  19640. * the user know there was an issue with importing the mesh
  19641. * @returns a validation object with skinned, valid and report string
  19642. */
  19643. validateSkinning(): {
  19644. skinned: boolean;
  19645. valid: boolean;
  19646. report: string;
  19647. };
  19648. /** @hidden */
  19649. _checkDelayState(): Mesh;
  19650. private _queueLoad;
  19651. /**
  19652. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19653. * A mesh is in the frustum if its bounding box intersects the frustum
  19654. * @param frustumPlanes defines the frustum to test
  19655. * @returns true if the mesh is in the frustum planes
  19656. */
  19657. isInFrustum(frustumPlanes: Plane[]): boolean;
  19658. /**
  19659. * Sets the mesh material by the material or multiMaterial `id` property
  19660. * @param id is a string identifying the material or the multiMaterial
  19661. * @returns the current mesh
  19662. */
  19663. setMaterialByID(id: string): Mesh;
  19664. /**
  19665. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  19666. * @returns an array of IAnimatable
  19667. */
  19668. getAnimatables(): IAnimatable[];
  19669. /**
  19670. * Modifies the mesh geometry according to the passed transformation matrix.
  19671. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  19672. * The mesh normals are modified using the same transformation.
  19673. * Note that, under the hood, this method sets a new VertexBuffer each call.
  19674. * @param transform defines the transform matrix to use
  19675. * @see http://doc.babylonjs.com/resources/baking_transformations
  19676. * @returns the current mesh
  19677. */
  19678. bakeTransformIntoVertices(transform: Matrix): Mesh;
  19679. /**
  19680. * Modifies the mesh geometry according to its own current World Matrix.
  19681. * The mesh World Matrix is then reset.
  19682. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  19683. * Note that, under the hood, this method sets a new VertexBuffer each call.
  19684. * @see http://doc.babylonjs.com/resources/baking_transformations
  19685. * @returns the current mesh
  19686. */
  19687. bakeCurrentTransformIntoVertices(): Mesh;
  19688. /** @hidden */
  19689. readonly _positions: Nullable<Vector3[]>;
  19690. /** @hidden */
  19691. _resetPointsArrayCache(): Mesh;
  19692. /** @hidden */
  19693. _generatePointsArray(): boolean;
  19694. /**
  19695. * Returns a new Mesh object generated from the current mesh properties.
  19696. * This method must not get confused with createInstance()
  19697. * @param name is a string, the name given to the new mesh
  19698. * @param newParent can be any Node object (default `null`)
  19699. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  19700. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  19701. * @returns a new mesh
  19702. */
  19703. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  19704. /**
  19705. * Releases resources associated with this mesh.
  19706. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19707. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19708. */
  19709. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19710. /**
  19711. * Modifies the mesh geometry according to a displacement map.
  19712. * 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.
  19713. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  19714. * @param url is a string, the URL from the image file is to be downloaded.
  19715. * @param minHeight is the lower limit of the displacement.
  19716. * @param maxHeight is the upper limit of the displacement.
  19717. * @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.
  19718. * @param uvOffset is an optional vector2 used to offset UV.
  19719. * @param uvScale is an optional vector2 used to scale UV.
  19720. * @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.
  19721. * @returns the Mesh.
  19722. */
  19723. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  19724. /**
  19725. * Modifies the mesh geometry according to a displacementMap buffer.
  19726. * 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.
  19727. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  19728. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  19729. * @param heightMapWidth is the width of the buffer image.
  19730. * @param heightMapHeight is the height of the buffer image.
  19731. * @param minHeight is the lower limit of the displacement.
  19732. * @param maxHeight is the upper limit of the displacement.
  19733. * @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.
  19734. * @param uvOffset is an optional vector2 used to offset UV.
  19735. * @param uvScale is an optional vector2 used to scale UV.
  19736. * @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.
  19737. * @returns the Mesh.
  19738. */
  19739. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  19740. /**
  19741. * Modify the mesh to get a flat shading rendering.
  19742. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  19743. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  19744. * @returns current mesh
  19745. */
  19746. convertToFlatShadedMesh(): Mesh;
  19747. /**
  19748. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  19749. * In other words, more vertices, no more indices and a single bigger VBO.
  19750. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  19751. * @returns current mesh
  19752. */
  19753. convertToUnIndexedMesh(): Mesh;
  19754. /**
  19755. * Inverses facet orientations.
  19756. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  19757. * @param flipNormals will also inverts the normals
  19758. * @returns current mesh
  19759. */
  19760. flipFaces(flipNormals?: boolean): Mesh;
  19761. /** @hidden */
  19762. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  19763. /** @hidden */
  19764. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  19765. /**
  19766. * Creates a new InstancedMesh object from the mesh model.
  19767. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19768. * @param name defines the name of the new instance
  19769. * @returns a new InstancedMesh
  19770. */
  19771. createInstance(name: string): InstancedMesh;
  19772. /**
  19773. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  19774. * After this call, all the mesh instances have the same submeshes than the current mesh.
  19775. * @returns the current mesh
  19776. */
  19777. synchronizeInstances(): Mesh;
  19778. /**
  19779. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  19780. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  19781. * This should be used together with the simplification to avoid disappearing triangles.
  19782. * @param successCallback an optional success callback to be called after the optimization finished.
  19783. * @returns the current mesh
  19784. */
  19785. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  19786. /**
  19787. * Serialize current mesh
  19788. * @param serializationObject defines the object which will receive the serialization data
  19789. */
  19790. serialize(serializationObject: any): void;
  19791. /** @hidden */
  19792. _syncGeometryWithMorphTargetManager(): void;
  19793. /** @hidden */
  19794. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  19795. /**
  19796. * Returns a new Mesh object parsed from the source provided.
  19797. * @param parsedMesh is the source
  19798. * @param scene defines the hosting scene
  19799. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  19800. * @returns a new Mesh
  19801. */
  19802. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  19803. /**
  19804. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  19805. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19806. * @param name defines the name of the mesh to create
  19807. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  19808. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  19809. * @param closePath creates a seam between the first and the last points of each path of the path array
  19810. * @param offset is taken in account only if the `pathArray` is containing a single path
  19811. * @param scene defines the hosting scene
  19812. * @param updatable defines if the mesh must be flagged as updatable
  19813. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19814. * @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)
  19815. * @returns a new Mesh
  19816. */
  19817. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19818. /**
  19819. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  19820. * @param name defines the name of the mesh to create
  19821. * @param radius sets the radius size (float) of the polygon (default 0.5)
  19822. * @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
  19823. * @param scene defines the hosting scene
  19824. * @param updatable defines if the mesh must be flagged as updatable
  19825. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19826. * @returns a new Mesh
  19827. */
  19828. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19829. /**
  19830. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  19831. * @param name defines the name of the mesh to create
  19832. * @param size sets the size (float) of each box side (default 1)
  19833. * @param scene defines the hosting scene
  19834. * @param updatable defines if the mesh must be flagged as updatable
  19835. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19836. * @returns a new Mesh
  19837. */
  19838. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19839. /**
  19840. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  19841. * @param name defines the name of the mesh to create
  19842. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  19843. * @param diameter sets the diameter size (float) of the sphere (default 1)
  19844. * @param scene defines the hosting scene
  19845. * @param updatable defines if the mesh must be flagged as updatable
  19846. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19847. * @returns a new Mesh
  19848. */
  19849. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19850. /**
  19851. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  19852. * @param name defines the name of the mesh to create
  19853. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  19854. * @param diameterTop set the top cap diameter (floats, default 1)
  19855. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  19856. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  19857. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  19858. * @param scene defines the hosting scene
  19859. * @param updatable defines if the mesh must be flagged as updatable
  19860. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19861. * @returns a new Mesh
  19862. */
  19863. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  19864. /**
  19865. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  19866. * @param name defines the name of the mesh to create
  19867. * @param diameter sets the diameter size (float) of the torus (default 1)
  19868. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  19869. * @param tessellation sets the number of torus sides (postive integer, default 16)
  19870. * @param scene defines the hosting scene
  19871. * @param updatable defines if the mesh must be flagged as updatable
  19872. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19873. * @returns a new Mesh
  19874. */
  19875. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19876. /**
  19877. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  19878. * @param name defines the name of the mesh to create
  19879. * @param radius sets the global radius size (float) of the torus knot (default 2)
  19880. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  19881. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  19882. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  19883. * @param p the number of windings on X axis (positive integers, default 2)
  19884. * @param q the number of windings on Y axis (positive integers, default 3)
  19885. * @param scene defines the hosting scene
  19886. * @param updatable defines if the mesh must be flagged as updatable
  19887. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19888. * @returns a new Mesh
  19889. */
  19890. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19891. /**
  19892. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  19893. * @param name defines the name of the mesh to create
  19894. * @param points is an array successive Vector3
  19895. * @param scene defines the hosting scene
  19896. * @param updatable defines if the mesh must be flagged as updatable
  19897. * @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).
  19898. * @returns a new Mesh
  19899. */
  19900. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  19901. /**
  19902. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  19903. * @param name defines the name of the mesh to create
  19904. * @param points is an array successive Vector3
  19905. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  19906. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  19907. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  19908. * @param scene defines the hosting scene
  19909. * @param updatable defines if the mesh must be flagged as updatable
  19910. * @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)
  19911. * @returns a new Mesh
  19912. */
  19913. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  19914. /**
  19915. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  19916. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  19917. * 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.
  19918. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19919. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19920. * Remember you can only change the shape positions, not their number when updating a polygon.
  19921. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  19922. * @param name defines the name of the mesh to create
  19923. * @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
  19924. * @param scene defines the hosting scene
  19925. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19926. * @param updatable defines if the mesh must be flagged as updatable
  19927. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19928. * @param earcutInjection can be used to inject your own earcut reference
  19929. * @returns a new Mesh
  19930. */
  19931. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  19932. /**
  19933. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  19934. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  19935. * @param name defines the name of the mesh to create
  19936. * @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
  19937. * @param depth defines the height of extrusion
  19938. * @param scene defines the hosting scene
  19939. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19940. * @param updatable defines if the mesh must be flagged as updatable
  19941. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19942. * @param earcutInjection can be used to inject your own earcut reference
  19943. * @returns a new Mesh
  19944. */
  19945. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  19946. /**
  19947. * Creates an extruded shape mesh.
  19948. * 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
  19949. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19950. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19951. * @param name defines the name of the mesh to create
  19952. * @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
  19953. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19954. * @param scale is the value to scale the shape
  19955. * @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
  19956. * @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
  19957. * @param scene defines the hosting scene
  19958. * @param updatable defines if the mesh must be flagged as updatable
  19959. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19960. * @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)
  19961. * @returns a new Mesh
  19962. */
  19963. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19964. /**
  19965. * Creates an custom extruded shape mesh.
  19966. * The custom extrusion is a parametric shape.
  19967. * It has no predefined shape. Its final shape will depend on the input parameters.
  19968. * Please consider using the same method from the MeshBuilder class instead
  19969. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19970. * @param name defines the name of the mesh to create
  19971. * @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
  19972. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19973. * @param scaleFunction is a custom Javascript function called on each path point
  19974. * @param rotationFunction is a custom Javascript function called on each path point
  19975. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  19976. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  19977. * @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
  19978. * @param scene defines the hosting scene
  19979. * @param updatable defines if the mesh must be flagged as updatable
  19980. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19981. * @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)
  19982. * @returns a new Mesh
  19983. */
  19984. 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;
  19985. /**
  19986. * Creates lathe mesh.
  19987. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  19988. * Please consider using the same method from the MeshBuilder class instead
  19989. * @param name defines the name of the mesh to create
  19990. * @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
  19991. * @param radius is the radius value of the lathe
  19992. * @param tessellation is the side number of the lathe.
  19993. * @param scene defines the hosting scene
  19994. * @param updatable defines if the mesh must be flagged as updatable
  19995. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19996. * @returns a new Mesh
  19997. */
  19998. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19999. /**
  20000. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  20001. * @param name defines the name of the mesh to create
  20002. * @param size sets the size (float) of both sides of the plane at once (default 1)
  20003. * @param scene defines the hosting scene
  20004. * @param updatable defines if the mesh must be flagged as updatable
  20005. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20006. * @returns a new Mesh
  20007. */
  20008. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20009. /**
  20010. * Creates a ground mesh.
  20011. * Please consider using the same method from the MeshBuilder class instead
  20012. * @param name defines the name of the mesh to create
  20013. * @param width set the width of the ground
  20014. * @param height set the height of the ground
  20015. * @param subdivisions sets the number of subdivisions per side
  20016. * @param scene defines the hosting scene
  20017. * @param updatable defines if the mesh must be flagged as updatable
  20018. * @returns a new Mesh
  20019. */
  20020. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20021. /**
  20022. * Creates a tiled ground mesh.
  20023. * Please consider using the same method from the MeshBuilder class instead
  20024. * @param name defines the name of the mesh to create
  20025. * @param xmin set the ground minimum X coordinate
  20026. * @param zmin set the ground minimum Y coordinate
  20027. * @param xmax set the ground maximum X coordinate
  20028. * @param zmax set the ground maximum Z coordinate
  20029. * @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
  20030. * @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
  20031. * @param scene defines the hosting scene
  20032. * @param updatable defines if the mesh must be flagged as updatable
  20033. * @returns a new Mesh
  20034. */
  20035. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20036. w: number;
  20037. h: number;
  20038. }, precision: {
  20039. w: number;
  20040. h: number;
  20041. }, scene: Scene, updatable?: boolean): Mesh;
  20042. /**
  20043. * Creates a ground mesh from a height map.
  20044. * Please consider using the same method from the MeshBuilder class instead
  20045. * @see http://doc.babylonjs.com/babylon101/height_map
  20046. * @param name defines the name of the mesh to create
  20047. * @param url sets the URL of the height map image resource
  20048. * @param width set the ground width size
  20049. * @param height set the ground height size
  20050. * @param subdivisions sets the number of subdivision per side
  20051. * @param minHeight is the minimum altitude on the ground
  20052. * @param maxHeight is the maximum altitude on the ground
  20053. * @param scene defines the hosting scene
  20054. * @param updatable defines if the mesh must be flagged as updatable
  20055. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  20056. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  20057. * @returns a new Mesh
  20058. */
  20059. 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;
  20060. /**
  20061. * Creates a tube mesh.
  20062. * The tube is a parametric shape.
  20063. * It has no predefined shape. Its final shape will depend on the input parameters.
  20064. * Please consider using the same method from the MeshBuilder class instead
  20065. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20066. * @param name defines the name of the mesh to create
  20067. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  20068. * @param radius sets the tube radius size
  20069. * @param tessellation is the number of sides on the tubular surface
  20070. * @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
  20071. * @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
  20072. * @param scene defines the hosting scene
  20073. * @param updatable defines if the mesh must be flagged as updatable
  20074. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20075. * @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)
  20076. * @returns a new Mesh
  20077. */
  20078. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  20079. (i: number, distance: number): number;
  20080. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20081. /**
  20082. * Creates a polyhedron mesh.
  20083. * Please consider using the same method from the MeshBuilder class instead.
  20084. * * 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
  20085. * * The parameter `size` (positive float, default 1) sets the polygon size
  20086. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  20087. * * 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`
  20088. * * 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
  20089. * * 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)`)
  20090. * * 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
  20091. * * 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
  20092. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20093. * * 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
  20094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20095. * @param name defines the name of the mesh to create
  20096. * @param options defines the options used to create the mesh
  20097. * @param scene defines the hosting scene
  20098. * @returns a new Mesh
  20099. */
  20100. static CreatePolyhedron(name: string, options: {
  20101. type?: number;
  20102. size?: number;
  20103. sizeX?: number;
  20104. sizeY?: number;
  20105. sizeZ?: number;
  20106. custom?: any;
  20107. faceUV?: Vector4[];
  20108. faceColors?: Color4[];
  20109. updatable?: boolean;
  20110. sideOrientation?: number;
  20111. }, scene: Scene): Mesh;
  20112. /**
  20113. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  20114. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  20115. * * 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`)
  20116. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  20117. * * 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
  20118. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20119. * * 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
  20120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20121. * @param name defines the name of the mesh
  20122. * @param options defines the options used to create the mesh
  20123. * @param scene defines the hosting scene
  20124. * @returns a new Mesh
  20125. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  20126. */
  20127. static CreateIcoSphere(name: string, options: {
  20128. radius?: number;
  20129. flat?: boolean;
  20130. subdivisions?: number;
  20131. sideOrientation?: number;
  20132. updatable?: boolean;
  20133. }, scene: Scene): Mesh;
  20134. /**
  20135. * Creates a decal mesh.
  20136. * Please consider using the same method from the MeshBuilder class instead.
  20137. * A decal is a mesh usually applied as a model onto the surface of another mesh
  20138. * @param name defines the name of the mesh
  20139. * @param sourceMesh defines the mesh receiving the decal
  20140. * @param position sets the position of the decal in world coordinates
  20141. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  20142. * @param size sets the decal scaling
  20143. * @param angle sets the angle to rotate the decal
  20144. * @returns a new Mesh
  20145. */
  20146. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20147. /**
  20148. * Prepare internal position array for software CPU skinning
  20149. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  20150. */
  20151. setPositionsForCPUSkinning(): Float32Array;
  20152. /**
  20153. * Prepare internal normal array for software CPU skinning
  20154. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20155. */
  20156. setNormalsForCPUSkinning(): Float32Array;
  20157. /**
  20158. * Updates the vertex buffer by applying transformation from the bones
  20159. * @param skeleton defines the skeleton to apply to current mesh
  20160. * @returns the current mesh
  20161. */
  20162. applySkeleton(skeleton: Skeleton): Mesh;
  20163. /**
  20164. * 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
  20165. * @param meshes defines the list of meshes to scan
  20166. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  20167. */
  20168. static MinMax(meshes: AbstractMesh[]): {
  20169. min: Vector3;
  20170. max: Vector3;
  20171. };
  20172. /**
  20173. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  20174. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  20175. * @returns a vector3
  20176. */
  20177. static Center(meshesOrMinMaxVector: {
  20178. min: Vector3;
  20179. max: Vector3;
  20180. } | AbstractMesh[]): Vector3;
  20181. /**
  20182. * Merge the array of meshes into a single mesh for performance reasons.
  20183. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  20184. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  20185. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  20186. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20187. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  20188. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  20189. * @returns a new mesh
  20190. */
  20191. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  20192. /** @hidden */
  20193. addInstance(instance: InstancedMesh): void;
  20194. /** @hidden */
  20195. removeInstance(instance: InstancedMesh): void;
  20196. }
  20197. }
  20198. declare module BABYLON {
  20199. /**
  20200. * Base class for the main features of a material in Babylon.js
  20201. */
  20202. export class Material implements IAnimatable {
  20203. /**
  20204. * Returns the triangle fill mode
  20205. */
  20206. static readonly TriangleFillMode: number;
  20207. /**
  20208. * Returns the wireframe mode
  20209. */
  20210. static readonly WireFrameFillMode: number;
  20211. /**
  20212. * Returns the point fill mode
  20213. */
  20214. static readonly PointFillMode: number;
  20215. /**
  20216. * Returns the point list draw mode
  20217. */
  20218. static readonly PointListDrawMode: number;
  20219. /**
  20220. * Returns the line list draw mode
  20221. */
  20222. static readonly LineListDrawMode: number;
  20223. /**
  20224. * Returns the line loop draw mode
  20225. */
  20226. static readonly LineLoopDrawMode: number;
  20227. /**
  20228. * Returns the line strip draw mode
  20229. */
  20230. static readonly LineStripDrawMode: number;
  20231. /**
  20232. * Returns the triangle strip draw mode
  20233. */
  20234. static readonly TriangleStripDrawMode: number;
  20235. /**
  20236. * Returns the triangle fan draw mode
  20237. */
  20238. static readonly TriangleFanDrawMode: number;
  20239. /**
  20240. * Stores the clock-wise side orientation
  20241. */
  20242. static readonly ClockWiseSideOrientation: number;
  20243. /**
  20244. * Stores the counter clock-wise side orientation
  20245. */
  20246. static readonly CounterClockWiseSideOrientation: number;
  20247. /**
  20248. * The dirty texture flag value
  20249. */
  20250. static readonly TextureDirtyFlag: number;
  20251. /**
  20252. * The dirty light flag value
  20253. */
  20254. static readonly LightDirtyFlag: number;
  20255. /**
  20256. * The dirty fresnel flag value
  20257. */
  20258. static readonly FresnelDirtyFlag: number;
  20259. /**
  20260. * The dirty attribute flag value
  20261. */
  20262. static readonly AttributesDirtyFlag: number;
  20263. /**
  20264. * The dirty misc flag value
  20265. */
  20266. static readonly MiscDirtyFlag: number;
  20267. /**
  20268. * The all dirty flag value
  20269. */
  20270. static readonly AllDirtyFlag: number;
  20271. /**
  20272. * The ID of the material
  20273. */
  20274. id: string;
  20275. /**
  20276. * Gets or sets the unique id of the material
  20277. */
  20278. uniqueId: number;
  20279. /**
  20280. * The name of the material
  20281. */
  20282. name: string;
  20283. /**
  20284. * Gets or sets user defined metadata
  20285. */
  20286. metadata: any;
  20287. /**
  20288. * For internal use only. Please do not use.
  20289. */
  20290. reservedDataStore: any;
  20291. /**
  20292. * Specifies if the ready state should be checked on each call
  20293. */
  20294. checkReadyOnEveryCall: boolean;
  20295. /**
  20296. * Specifies if the ready state should be checked once
  20297. */
  20298. checkReadyOnlyOnce: boolean;
  20299. /**
  20300. * The state of the material
  20301. */
  20302. state: string;
  20303. /**
  20304. * The alpha value of the material
  20305. */
  20306. protected _alpha: number;
  20307. /**
  20308. * Sets the alpha value of the material
  20309. */
  20310. /**
  20311. * Gets the alpha value of the material
  20312. */
  20313. alpha: number;
  20314. /**
  20315. * Specifies if back face culling is enabled
  20316. */
  20317. protected _backFaceCulling: boolean;
  20318. /**
  20319. * Sets the back-face culling state
  20320. */
  20321. /**
  20322. * Gets the back-face culling state
  20323. */
  20324. backFaceCulling: boolean;
  20325. /**
  20326. * Stores the value for side orientation
  20327. */
  20328. sideOrientation: number;
  20329. /**
  20330. * Callback triggered when the material is compiled
  20331. */
  20332. onCompiled: (effect: Effect) => void;
  20333. /**
  20334. * Callback triggered when an error occurs
  20335. */
  20336. onError: (effect: Effect, errors: string) => void;
  20337. /**
  20338. * Callback triggered to get the render target textures
  20339. */
  20340. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  20341. /**
  20342. * Gets a boolean indicating that current material needs to register RTT
  20343. */
  20344. readonly hasRenderTargetTextures: boolean;
  20345. /**
  20346. * Specifies if the material should be serialized
  20347. */
  20348. doNotSerialize: boolean;
  20349. /**
  20350. * @hidden
  20351. */
  20352. _storeEffectOnSubMeshes: boolean;
  20353. /**
  20354. * Stores the animations for the material
  20355. */
  20356. animations: Array<Animation>;
  20357. /**
  20358. * An event triggered when the material is disposed
  20359. */
  20360. onDisposeObservable: Observable<Material>;
  20361. /**
  20362. * An observer which watches for dispose events
  20363. */
  20364. private _onDisposeObserver;
  20365. private _onUnBindObservable;
  20366. /**
  20367. * Called during a dispose event
  20368. */
  20369. onDispose: () => void;
  20370. private _onBindObservable;
  20371. /**
  20372. * An event triggered when the material is bound
  20373. */
  20374. readonly onBindObservable: Observable<AbstractMesh>;
  20375. /**
  20376. * An observer which watches for bind events
  20377. */
  20378. private _onBindObserver;
  20379. /**
  20380. * Called during a bind event
  20381. */
  20382. onBind: (Mesh: AbstractMesh) => void;
  20383. /**
  20384. * An event triggered when the material is unbound
  20385. */
  20386. readonly onUnBindObservable: Observable<Material>;
  20387. /**
  20388. * Stores the value of the alpha mode
  20389. */
  20390. private _alphaMode;
  20391. /**
  20392. * Sets the value of the alpha mode.
  20393. *
  20394. * | Value | Type | Description |
  20395. * | --- | --- | --- |
  20396. * | 0 | ALPHA_DISABLE | |
  20397. * | 1 | ALPHA_ADD | |
  20398. * | 2 | ALPHA_COMBINE | |
  20399. * | 3 | ALPHA_SUBTRACT | |
  20400. * | 4 | ALPHA_MULTIPLY | |
  20401. * | 5 | ALPHA_MAXIMIZED | |
  20402. * | 6 | ALPHA_ONEONE | |
  20403. * | 7 | ALPHA_PREMULTIPLIED | |
  20404. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20405. * | 9 | ALPHA_INTERPOLATE | |
  20406. * | 10 | ALPHA_SCREENMODE | |
  20407. *
  20408. */
  20409. /**
  20410. * Gets the value of the alpha mode
  20411. */
  20412. alphaMode: number;
  20413. /**
  20414. * Stores the state of the need depth pre-pass value
  20415. */
  20416. private _needDepthPrePass;
  20417. /**
  20418. * Sets the need depth pre-pass value
  20419. */
  20420. /**
  20421. * Gets the depth pre-pass value
  20422. */
  20423. needDepthPrePass: boolean;
  20424. /**
  20425. * Specifies if depth writing should be disabled
  20426. */
  20427. disableDepthWrite: boolean;
  20428. /**
  20429. * Specifies if depth writing should be forced
  20430. */
  20431. forceDepthWrite: boolean;
  20432. /**
  20433. * Specifies if there should be a separate pass for culling
  20434. */
  20435. separateCullingPass: boolean;
  20436. /**
  20437. * Stores the state specifing if fog should be enabled
  20438. */
  20439. private _fogEnabled;
  20440. /**
  20441. * Sets the state for enabling fog
  20442. */
  20443. /**
  20444. * Gets the value of the fog enabled state
  20445. */
  20446. fogEnabled: boolean;
  20447. /**
  20448. * Stores the size of points
  20449. */
  20450. pointSize: number;
  20451. /**
  20452. * Stores the z offset value
  20453. */
  20454. zOffset: number;
  20455. /**
  20456. * Gets a value specifying if wireframe mode is enabled
  20457. */
  20458. /**
  20459. * Sets the state of wireframe mode
  20460. */
  20461. wireframe: boolean;
  20462. /**
  20463. * Gets the value specifying if point clouds are enabled
  20464. */
  20465. /**
  20466. * Sets the state of point cloud mode
  20467. */
  20468. pointsCloud: boolean;
  20469. /**
  20470. * Gets the material fill mode
  20471. */
  20472. /**
  20473. * Sets the material fill mode
  20474. */
  20475. fillMode: number;
  20476. /**
  20477. * @hidden
  20478. * Stores the effects for the material
  20479. */
  20480. _effect: Nullable<Effect>;
  20481. /**
  20482. * @hidden
  20483. * Specifies if the material was previously ready
  20484. */
  20485. _wasPreviouslyReady: boolean;
  20486. /**
  20487. * Specifies if uniform buffers should be used
  20488. */
  20489. private _useUBO;
  20490. /**
  20491. * Stores a reference to the scene
  20492. */
  20493. private _scene;
  20494. /**
  20495. * Stores the fill mode state
  20496. */
  20497. private _fillMode;
  20498. /**
  20499. * Specifies if the depth write state should be cached
  20500. */
  20501. private _cachedDepthWriteState;
  20502. /**
  20503. * Stores the uniform buffer
  20504. */
  20505. protected _uniformBuffer: UniformBuffer;
  20506. /** @hidden */
  20507. _indexInSceneMaterialArray: number;
  20508. /** @hidden */
  20509. meshMap: Nullable<{
  20510. [id: string]: AbstractMesh | undefined;
  20511. }>;
  20512. /**
  20513. * Creates a material instance
  20514. * @param name defines the name of the material
  20515. * @param scene defines the scene to reference
  20516. * @param doNotAdd specifies if the material should be added to the scene
  20517. */
  20518. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20519. /**
  20520. * Returns a string representation of the current material
  20521. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20522. * @returns a string with material information
  20523. */
  20524. toString(fullDetails?: boolean): string;
  20525. /**
  20526. * Gets the class name of the material
  20527. * @returns a string with the class name of the material
  20528. */
  20529. getClassName(): string;
  20530. /**
  20531. * Specifies if updates for the material been locked
  20532. */
  20533. readonly isFrozen: boolean;
  20534. /**
  20535. * Locks updates for the material
  20536. */
  20537. freeze(): void;
  20538. /**
  20539. * Unlocks updates for the material
  20540. */
  20541. unfreeze(): void;
  20542. /**
  20543. * Specifies if the material is ready to be used
  20544. * @param mesh defines the mesh to check
  20545. * @param useInstances specifies if instances should be used
  20546. * @returns a boolean indicating if the material is ready to be used
  20547. */
  20548. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20549. /**
  20550. * Specifies that the submesh is ready to be used
  20551. * @param mesh defines the mesh to check
  20552. * @param subMesh defines which submesh to check
  20553. * @param useInstances specifies that instances should be used
  20554. * @returns a boolean indicating that the submesh is ready or not
  20555. */
  20556. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20557. /**
  20558. * Returns the material effect
  20559. * @returns the effect associated with the material
  20560. */
  20561. getEffect(): Nullable<Effect>;
  20562. /**
  20563. * Returns the current scene
  20564. * @returns a Scene
  20565. */
  20566. getScene(): Scene;
  20567. /**
  20568. * Specifies if the material will require alpha blending
  20569. * @returns a boolean specifying if alpha blending is needed
  20570. */
  20571. needAlphaBlending(): boolean;
  20572. /**
  20573. * Specifies if the mesh will require alpha blending
  20574. * @param mesh defines the mesh to check
  20575. * @returns a boolean specifying if alpha blending is needed for the mesh
  20576. */
  20577. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20578. /**
  20579. * Specifies if this material should be rendered in alpha test mode
  20580. * @returns a boolean specifying if an alpha test is needed.
  20581. */
  20582. needAlphaTesting(): boolean;
  20583. /**
  20584. * Gets the texture used for the alpha test
  20585. * @returns the texture to use for alpha testing
  20586. */
  20587. getAlphaTestTexture(): Nullable<BaseTexture>;
  20588. /**
  20589. * Marks the material to indicate that it needs to be re-calculated
  20590. */
  20591. markDirty(): void;
  20592. /** @hidden */
  20593. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20594. /**
  20595. * Binds the material to the mesh
  20596. * @param world defines the world transformation matrix
  20597. * @param mesh defines the mesh to bind the material to
  20598. */
  20599. bind(world: Matrix, mesh?: Mesh): void;
  20600. /**
  20601. * Binds the submesh to the material
  20602. * @param world defines the world transformation matrix
  20603. * @param mesh defines the mesh containing the submesh
  20604. * @param subMesh defines the submesh to bind the material to
  20605. */
  20606. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20607. /**
  20608. * Binds the world matrix to the material
  20609. * @param world defines the world transformation matrix
  20610. */
  20611. bindOnlyWorldMatrix(world: Matrix): void;
  20612. /**
  20613. * Binds the scene's uniform buffer to the effect.
  20614. * @param effect defines the effect to bind to the scene uniform buffer
  20615. * @param sceneUbo defines the uniform buffer storing scene data
  20616. */
  20617. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20618. /**
  20619. * Binds the view matrix to the effect
  20620. * @param effect defines the effect to bind the view matrix to
  20621. */
  20622. bindView(effect: Effect): void;
  20623. /**
  20624. * Binds the view projection matrix to the effect
  20625. * @param effect defines the effect to bind the view projection matrix to
  20626. */
  20627. bindViewProjection(effect: Effect): void;
  20628. /**
  20629. * Specifies if material alpha testing should be turned on for the mesh
  20630. * @param mesh defines the mesh to check
  20631. */
  20632. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20633. /**
  20634. * Processes to execute after binding the material to a mesh
  20635. * @param mesh defines the rendered mesh
  20636. */
  20637. protected _afterBind(mesh?: Mesh): void;
  20638. /**
  20639. * Unbinds the material from the mesh
  20640. */
  20641. unbind(): void;
  20642. /**
  20643. * Gets the active textures from the material
  20644. * @returns an array of textures
  20645. */
  20646. getActiveTextures(): BaseTexture[];
  20647. /**
  20648. * Specifies if the material uses a texture
  20649. * @param texture defines the texture to check against the material
  20650. * @returns a boolean specifying if the material uses the texture
  20651. */
  20652. hasTexture(texture: BaseTexture): boolean;
  20653. /**
  20654. * Makes a duplicate of the material, and gives it a new name
  20655. * @param name defines the new name for the duplicated material
  20656. * @returns the cloned material
  20657. */
  20658. clone(name: string): Nullable<Material>;
  20659. /**
  20660. * Gets the meshes bound to the material
  20661. * @returns an array of meshes bound to the material
  20662. */
  20663. getBindedMeshes(): AbstractMesh[];
  20664. /**
  20665. * Force shader compilation
  20666. * @param mesh defines the mesh associated with this material
  20667. * @param onCompiled defines a function to execute once the material is compiled
  20668. * @param options defines the options to configure the compilation
  20669. */
  20670. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20671. clipPlane: boolean;
  20672. }>): void;
  20673. /**
  20674. * Force shader compilation
  20675. * @param mesh defines the mesh that will use this material
  20676. * @param options defines additional options for compiling the shaders
  20677. * @returns a promise that resolves when the compilation completes
  20678. */
  20679. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20680. clipPlane: boolean;
  20681. }>): Promise<void>;
  20682. private static readonly _ImageProcessingDirtyCallBack;
  20683. private static readonly _TextureDirtyCallBack;
  20684. private static readonly _FresnelDirtyCallBack;
  20685. private static readonly _MiscDirtyCallBack;
  20686. private static readonly _LightsDirtyCallBack;
  20687. private static readonly _AttributeDirtyCallBack;
  20688. private static _FresnelAndMiscDirtyCallBack;
  20689. private static _TextureAndMiscDirtyCallBack;
  20690. private static readonly _DirtyCallbackArray;
  20691. private static readonly _RunDirtyCallBacks;
  20692. /**
  20693. * Marks a define in the material to indicate that it needs to be re-computed
  20694. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20695. */
  20696. markAsDirty(flag: number): void;
  20697. /**
  20698. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20699. * @param func defines a function which checks material defines against the submeshes
  20700. */
  20701. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20702. /**
  20703. * Indicates that image processing needs to be re-calculated for all submeshes
  20704. */
  20705. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20706. /**
  20707. * Indicates that textures need to be re-calculated for all submeshes
  20708. */
  20709. protected _markAllSubMeshesAsTexturesDirty(): void;
  20710. /**
  20711. * Indicates that fresnel needs to be re-calculated for all submeshes
  20712. */
  20713. protected _markAllSubMeshesAsFresnelDirty(): void;
  20714. /**
  20715. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20716. */
  20717. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20718. /**
  20719. * Indicates that lights need to be re-calculated for all submeshes
  20720. */
  20721. protected _markAllSubMeshesAsLightsDirty(): void;
  20722. /**
  20723. * Indicates that attributes need to be re-calculated for all submeshes
  20724. */
  20725. protected _markAllSubMeshesAsAttributesDirty(): void;
  20726. /**
  20727. * Indicates that misc needs to be re-calculated for all submeshes
  20728. */
  20729. protected _markAllSubMeshesAsMiscDirty(): void;
  20730. /**
  20731. * Indicates that textures and misc need to be re-calculated for all submeshes
  20732. */
  20733. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20734. /**
  20735. * Disposes the material
  20736. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20737. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20738. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20739. */
  20740. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20741. /** @hidden */
  20742. private releaseVertexArrayObject;
  20743. /**
  20744. * Serializes this material
  20745. * @returns the serialized material object
  20746. */
  20747. serialize(): any;
  20748. /**
  20749. * Creates a material from parsed material data
  20750. * @param parsedMaterial defines parsed material data
  20751. * @param scene defines the hosting scene
  20752. * @param rootUrl defines the root URL to use to load textures
  20753. * @returns a new material
  20754. */
  20755. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  20756. }
  20757. }
  20758. declare module BABYLON {
  20759. /**
  20760. * Base class for submeshes
  20761. */
  20762. export class BaseSubMesh {
  20763. /** @hidden */
  20764. _materialDefines: Nullable<MaterialDefines>;
  20765. /** @hidden */
  20766. _materialEffect: Nullable<Effect>;
  20767. /**
  20768. * Gets associated effect
  20769. */
  20770. readonly effect: Nullable<Effect>;
  20771. /**
  20772. * Sets associated effect (effect used to render this submesh)
  20773. * @param effect defines the effect to associate with
  20774. * @param defines defines the set of defines used to compile this effect
  20775. */
  20776. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20777. }
  20778. /**
  20779. * Defines a subdivision inside a mesh
  20780. */
  20781. export class SubMesh extends BaseSubMesh implements ICullable {
  20782. /** the material index to use */
  20783. materialIndex: number;
  20784. /** vertex index start */
  20785. verticesStart: number;
  20786. /** vertices count */
  20787. verticesCount: number;
  20788. /** index start */
  20789. indexStart: number;
  20790. /** indices count */
  20791. indexCount: number;
  20792. /** @hidden */
  20793. _linesIndexCount: number;
  20794. private _mesh;
  20795. private _renderingMesh;
  20796. private _boundingInfo;
  20797. private _linesIndexBuffer;
  20798. /** @hidden */
  20799. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20800. /** @hidden */
  20801. _trianglePlanes: Plane[];
  20802. /** @hidden */
  20803. _lastColliderTransformMatrix: Matrix;
  20804. /** @hidden */
  20805. _renderId: number;
  20806. /** @hidden */
  20807. _alphaIndex: number;
  20808. /** @hidden */
  20809. _distanceToCamera: number;
  20810. /** @hidden */
  20811. _id: number;
  20812. private _currentMaterial;
  20813. /**
  20814. * Add a new submesh to a mesh
  20815. * @param materialIndex defines the material index to use
  20816. * @param verticesStart defines vertex index start
  20817. * @param verticesCount defines vertices count
  20818. * @param indexStart defines index start
  20819. * @param indexCount defines indices count
  20820. * @param mesh defines the parent mesh
  20821. * @param renderingMesh defines an optional rendering mesh
  20822. * @param createBoundingBox defines if bounding box should be created for this submesh
  20823. * @returns the new submesh
  20824. */
  20825. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20826. /**
  20827. * Creates a new submesh
  20828. * @param materialIndex defines the material index to use
  20829. * @param verticesStart defines vertex index start
  20830. * @param verticesCount defines vertices count
  20831. * @param indexStart defines index start
  20832. * @param indexCount defines indices count
  20833. * @param mesh defines the parent mesh
  20834. * @param renderingMesh defines an optional rendering mesh
  20835. * @param createBoundingBox defines if bounding box should be created for this submesh
  20836. */
  20837. constructor(
  20838. /** the material index to use */
  20839. materialIndex: number,
  20840. /** vertex index start */
  20841. verticesStart: number,
  20842. /** vertices count */
  20843. verticesCount: number,
  20844. /** index start */
  20845. indexStart: number,
  20846. /** indices count */
  20847. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20848. /**
  20849. * Returns true if this submesh covers the entire parent mesh
  20850. * @ignorenaming
  20851. */
  20852. readonly IsGlobal: boolean;
  20853. /**
  20854. * Returns the submesh BoudingInfo object
  20855. * @returns current bounding info (or mesh's one if the submesh is global)
  20856. */
  20857. getBoundingInfo(): BoundingInfo;
  20858. /**
  20859. * Sets the submesh BoundingInfo
  20860. * @param boundingInfo defines the new bounding info to use
  20861. * @returns the SubMesh
  20862. */
  20863. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20864. /**
  20865. * Returns the mesh of the current submesh
  20866. * @return the parent mesh
  20867. */
  20868. getMesh(): AbstractMesh;
  20869. /**
  20870. * Returns the rendering mesh of the submesh
  20871. * @returns the rendering mesh (could be different from parent mesh)
  20872. */
  20873. getRenderingMesh(): Mesh;
  20874. /**
  20875. * Returns the submesh material
  20876. * @returns null or the current material
  20877. */
  20878. getMaterial(): Nullable<Material>;
  20879. /**
  20880. * Sets a new updated BoundingInfo object to the submesh
  20881. * @returns the SubMesh
  20882. */
  20883. refreshBoundingInfo(): SubMesh;
  20884. /** @hidden */
  20885. _checkCollision(collider: Collider): boolean;
  20886. /**
  20887. * Updates the submesh BoundingInfo
  20888. * @param world defines the world matrix to use to update the bounding info
  20889. * @returns the submesh
  20890. */
  20891. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20892. /**
  20893. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20894. * @param frustumPlanes defines the frustum planes
  20895. * @returns true if the submesh is intersecting with the frustum
  20896. */
  20897. isInFrustum(frustumPlanes: Plane[]): boolean;
  20898. /**
  20899. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20900. * @param frustumPlanes defines the frustum planes
  20901. * @returns true if the submesh is inside the frustum
  20902. */
  20903. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20904. /**
  20905. * Renders the submesh
  20906. * @param enableAlphaMode defines if alpha needs to be used
  20907. * @returns the submesh
  20908. */
  20909. render(enableAlphaMode: boolean): SubMesh;
  20910. /**
  20911. * @hidden
  20912. */
  20913. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  20914. /**
  20915. * Checks if the submesh intersects with a ray
  20916. * @param ray defines the ray to test
  20917. * @returns true is the passed ray intersects the submesh bounding box
  20918. */
  20919. canIntersects(ray: Ray): boolean;
  20920. /**
  20921. * Intersects current submesh with a ray
  20922. * @param ray defines the ray to test
  20923. * @param positions defines mesh's positions array
  20924. * @param indices defines mesh's indices array
  20925. * @param fastCheck defines if only bounding info should be used
  20926. * @returns intersection info or null if no intersection
  20927. */
  20928. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  20929. /** @hidden */
  20930. private _intersectLines;
  20931. /** @hidden */
  20932. private _intersectTriangles;
  20933. /** @hidden */
  20934. _rebuild(): void;
  20935. /**
  20936. * Creates a new submesh from the passed mesh
  20937. * @param newMesh defines the new hosting mesh
  20938. * @param newRenderingMesh defines an optional rendering mesh
  20939. * @returns the new submesh
  20940. */
  20941. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20942. /**
  20943. * Release associated resources
  20944. */
  20945. dispose(): void;
  20946. /**
  20947. * Gets the class name
  20948. * @returns the string "SubMesh".
  20949. */
  20950. getClassName(): string;
  20951. /**
  20952. * Creates a new submesh from indices data
  20953. * @param materialIndex the index of the main mesh material
  20954. * @param startIndex the index where to start the copy in the mesh indices array
  20955. * @param indexCount the number of indices to copy then from the startIndex
  20956. * @param mesh the main mesh to create the submesh from
  20957. * @param renderingMesh the optional rendering mesh
  20958. * @returns a new submesh
  20959. */
  20960. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20961. }
  20962. }
  20963. declare module BABYLON {
  20964. /**
  20965. * Class used to store geometry data (vertex buffers + index buffer)
  20966. */
  20967. export class Geometry implements IGetSetVerticesData {
  20968. /**
  20969. * Gets or sets the ID of the geometry
  20970. */
  20971. id: string;
  20972. /**
  20973. * Gets or sets the unique ID of the geometry
  20974. */
  20975. uniqueId: number;
  20976. /**
  20977. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20978. */
  20979. delayLoadState: number;
  20980. /**
  20981. * Gets the file containing the data to load when running in delay load state
  20982. */
  20983. delayLoadingFile: Nullable<string>;
  20984. /**
  20985. * Callback called when the geometry is updated
  20986. */
  20987. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20988. private _scene;
  20989. private _engine;
  20990. private _meshes;
  20991. private _totalVertices;
  20992. /** @hidden */
  20993. _indices: IndicesArray;
  20994. /** @hidden */
  20995. _vertexBuffers: {
  20996. [key: string]: VertexBuffer;
  20997. };
  20998. private _isDisposed;
  20999. private _extend;
  21000. private _boundingBias;
  21001. /** @hidden */
  21002. _delayInfo: Array<string>;
  21003. private _indexBuffer;
  21004. private _indexBufferIsUpdatable;
  21005. /** @hidden */
  21006. _boundingInfo: Nullable<BoundingInfo>;
  21007. /** @hidden */
  21008. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21009. /** @hidden */
  21010. _softwareSkinningFrameId: number;
  21011. private _vertexArrayObjects;
  21012. private _updatable;
  21013. /** @hidden */
  21014. _positions: Nullable<Vector3[]>;
  21015. /**
  21016. * 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
  21017. */
  21018. /**
  21019. * 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
  21020. */
  21021. boundingBias: Vector2;
  21022. /**
  21023. * Static function used to attach a new empty geometry to a mesh
  21024. * @param mesh defines the mesh to attach the geometry to
  21025. * @returns the new Geometry
  21026. */
  21027. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21028. /**
  21029. * Creates a new geometry
  21030. * @param id defines the unique ID
  21031. * @param scene defines the hosting scene
  21032. * @param vertexData defines the VertexData used to get geometry data
  21033. * @param updatable defines if geometry must be updatable (false by default)
  21034. * @param mesh defines the mesh that will be associated with the geometry
  21035. */
  21036. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21037. /**
  21038. * Gets the current extend of the geometry
  21039. */
  21040. readonly extend: {
  21041. minimum: Vector3;
  21042. maximum: Vector3;
  21043. };
  21044. /**
  21045. * Gets the hosting scene
  21046. * @returns the hosting Scene
  21047. */
  21048. getScene(): Scene;
  21049. /**
  21050. * Gets the hosting engine
  21051. * @returns the hosting Engine
  21052. */
  21053. getEngine(): Engine;
  21054. /**
  21055. * Defines if the geometry is ready to use
  21056. * @returns true if the geometry is ready to be used
  21057. */
  21058. isReady(): boolean;
  21059. /**
  21060. * Gets a value indicating that the geometry should not be serialized
  21061. */
  21062. readonly doNotSerialize: boolean;
  21063. /** @hidden */
  21064. _rebuild(): void;
  21065. /**
  21066. * Affects all geometry data in one call
  21067. * @param vertexData defines the geometry data
  21068. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21069. */
  21070. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21071. /**
  21072. * Set specific vertex data
  21073. * @param kind defines the data kind (Position, normal, etc...)
  21074. * @param data defines the vertex data to use
  21075. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21076. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21077. */
  21078. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21079. /**
  21080. * Removes a specific vertex data
  21081. * @param kind defines the data kind (Position, normal, etc...)
  21082. */
  21083. removeVerticesData(kind: string): void;
  21084. /**
  21085. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21086. * @param buffer defines the vertex buffer to use
  21087. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21088. */
  21089. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21090. /**
  21091. * Update a specific vertex buffer
  21092. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  21093. * It will do nothing if the buffer is not updatable
  21094. * @param kind defines the data kind (Position, normal, etc...)
  21095. * @param data defines the data to use
  21096. * @param offset defines the offset in the target buffer where to store the data
  21097. * @param useBytes set to true if the offset is in bytes
  21098. */
  21099. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21100. /**
  21101. * Update a specific vertex buffer
  21102. * This function will create a new buffer if the current one is not updatable
  21103. * @param kind defines the data kind (Position, normal, etc...)
  21104. * @param data defines the data to use
  21105. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21106. */
  21107. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21108. private _updateBoundingInfo;
  21109. /** @hidden */
  21110. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  21111. /**
  21112. * Gets total number of vertices
  21113. * @returns the total number of vertices
  21114. */
  21115. getTotalVertices(): number;
  21116. /**
  21117. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21118. * @param kind defines the data kind (Position, normal, etc...)
  21119. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21120. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21121. * @returns a float array containing vertex data
  21122. */
  21123. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21124. /**
  21125. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21126. * @param kind defines the data kind (Position, normal, etc...)
  21127. * @returns true if the vertex buffer with the specified kind is updatable
  21128. */
  21129. isVertexBufferUpdatable(kind: string): boolean;
  21130. /**
  21131. * Gets a specific vertex buffer
  21132. * @param kind defines the data kind (Position, normal, etc...)
  21133. * @returns a VertexBuffer
  21134. */
  21135. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21136. /**
  21137. * Returns all vertex buffers
  21138. * @return an object holding all vertex buffers indexed by kind
  21139. */
  21140. getVertexBuffers(): Nullable<{
  21141. [key: string]: VertexBuffer;
  21142. }>;
  21143. /**
  21144. * Gets a boolean indicating if specific vertex buffer is present
  21145. * @param kind defines the data kind (Position, normal, etc...)
  21146. * @returns true if data is present
  21147. */
  21148. isVerticesDataPresent(kind: string): boolean;
  21149. /**
  21150. * Gets a list of all attached data kinds (Position, normal, etc...)
  21151. * @returns a list of string containing all kinds
  21152. */
  21153. getVerticesDataKinds(): string[];
  21154. /**
  21155. * Update index buffer
  21156. * @param indices defines the indices to store in the index buffer
  21157. * @param offset defines the offset in the target buffer where to store the data
  21158. */
  21159. updateIndices(indices: IndicesArray, offset?: number): void;
  21160. /**
  21161. * Creates a new index buffer
  21162. * @param indices defines the indices to store in the index buffer
  21163. * @param totalVertices defines the total number of vertices (could be null)
  21164. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21165. */
  21166. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21167. /**
  21168. * Return the total number of indices
  21169. * @returns the total number of indices
  21170. */
  21171. getTotalIndices(): number;
  21172. /**
  21173. * Gets the index buffer array
  21174. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21175. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21176. * @returns the index buffer array
  21177. */
  21178. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21179. /**
  21180. * Gets the index buffer
  21181. * @return the index buffer
  21182. */
  21183. getIndexBuffer(): Nullable<WebGLBuffer>;
  21184. /** @hidden */
  21185. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21186. /**
  21187. * Release the associated resources for a specific mesh
  21188. * @param mesh defines the source mesh
  21189. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21190. */
  21191. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21192. /**
  21193. * Apply current geometry to a given mesh
  21194. * @param mesh defines the mesh to apply geometry to
  21195. */
  21196. applyToMesh(mesh: Mesh): void;
  21197. private _updateExtend;
  21198. private _applyToMesh;
  21199. private notifyUpdate;
  21200. /**
  21201. * Load the geometry if it was flagged as delay loaded
  21202. * @param scene defines the hosting scene
  21203. * @param onLoaded defines a callback called when the geometry is loaded
  21204. */
  21205. load(scene: Scene, onLoaded?: () => void): void;
  21206. private _queueLoad;
  21207. /**
  21208. * Invert the geometry to move from a right handed system to a left handed one.
  21209. */
  21210. toLeftHanded(): void;
  21211. /** @hidden */
  21212. _resetPointsArrayCache(): void;
  21213. /** @hidden */
  21214. _generatePointsArray(): boolean;
  21215. /**
  21216. * Gets a value indicating if the geometry is disposed
  21217. * @returns true if the geometry was disposed
  21218. */
  21219. isDisposed(): boolean;
  21220. private _disposeVertexArrayObjects;
  21221. /**
  21222. * Free all associated resources
  21223. */
  21224. dispose(): void;
  21225. /**
  21226. * Clone the current geometry into a new geometry
  21227. * @param id defines the unique ID of the new geometry
  21228. * @returns a new geometry object
  21229. */
  21230. copy(id: string): Geometry;
  21231. /**
  21232. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21233. * @return a JSON representation of the current geometry data (without the vertices data)
  21234. */
  21235. serialize(): any;
  21236. private toNumberArray;
  21237. /**
  21238. * Serialize all vertices data into a JSON oject
  21239. * @returns a JSON representation of the current geometry data
  21240. */
  21241. serializeVerticeData(): any;
  21242. /**
  21243. * Extracts a clone of a mesh geometry
  21244. * @param mesh defines the source mesh
  21245. * @param id defines the unique ID of the new geometry object
  21246. * @returns the new geometry object
  21247. */
  21248. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21249. /**
  21250. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21251. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21252. * Be aware Math.random() could cause collisions, but:
  21253. * "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"
  21254. * @returns a string containing a new GUID
  21255. */
  21256. static RandomId(): string;
  21257. /** @hidden */
  21258. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21259. private static _CleanMatricesWeights;
  21260. /**
  21261. * Create a new geometry from persisted data (Using .babylon file format)
  21262. * @param parsedVertexData defines the persisted data
  21263. * @param scene defines the hosting scene
  21264. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21265. * @returns the new geometry object
  21266. */
  21267. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21268. }
  21269. }
  21270. declare module BABYLON {
  21271. /**
  21272. * Define an interface for all classes that will get and set the data on vertices
  21273. */
  21274. export interface IGetSetVerticesData {
  21275. /**
  21276. * Gets a boolean indicating if specific vertex data is present
  21277. * @param kind defines the vertex data kind to use
  21278. * @returns true is data kind is present
  21279. */
  21280. isVerticesDataPresent(kind: string): boolean;
  21281. /**
  21282. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21283. * @param kind defines the data kind (Position, normal, etc...)
  21284. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21285. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21286. * @returns a float array containing vertex data
  21287. */
  21288. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21289. /**
  21290. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21291. * @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.
  21292. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21293. * @returns the indices array or an empty array if the mesh has no geometry
  21294. */
  21295. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21296. /**
  21297. * Set specific vertex data
  21298. * @param kind defines the data kind (Position, normal, etc...)
  21299. * @param data defines the vertex data to use
  21300. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21301. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21302. */
  21303. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21304. /**
  21305. * Update a specific associated vertex buffer
  21306. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21307. * - VertexBuffer.PositionKind
  21308. * - VertexBuffer.UVKind
  21309. * - VertexBuffer.UV2Kind
  21310. * - VertexBuffer.UV3Kind
  21311. * - VertexBuffer.UV4Kind
  21312. * - VertexBuffer.UV5Kind
  21313. * - VertexBuffer.UV6Kind
  21314. * - VertexBuffer.ColorKind
  21315. * - VertexBuffer.MatricesIndicesKind
  21316. * - VertexBuffer.MatricesIndicesExtraKind
  21317. * - VertexBuffer.MatricesWeightsKind
  21318. * - VertexBuffer.MatricesWeightsExtraKind
  21319. * @param data defines the data source
  21320. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21321. * @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)
  21322. */
  21323. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21324. /**
  21325. * Creates a new index buffer
  21326. * @param indices defines the indices to store in the index buffer
  21327. * @param totalVertices defines the total number of vertices (could be null)
  21328. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21329. */
  21330. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21331. }
  21332. /**
  21333. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21334. */
  21335. export class VertexData {
  21336. /**
  21337. * Mesh side orientation : usually the external or front surface
  21338. */
  21339. static readonly FRONTSIDE: number;
  21340. /**
  21341. * Mesh side orientation : usually the internal or back surface
  21342. */
  21343. static readonly BACKSIDE: number;
  21344. /**
  21345. * Mesh side orientation : both internal and external or front and back surfaces
  21346. */
  21347. static readonly DOUBLESIDE: number;
  21348. /**
  21349. * Mesh side orientation : by default, `FRONTSIDE`
  21350. */
  21351. static readonly DEFAULTSIDE: number;
  21352. /**
  21353. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21354. */
  21355. positions: Nullable<FloatArray>;
  21356. /**
  21357. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21358. */
  21359. normals: Nullable<FloatArray>;
  21360. /**
  21361. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21362. */
  21363. tangents: Nullable<FloatArray>;
  21364. /**
  21365. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21366. */
  21367. uvs: Nullable<FloatArray>;
  21368. /**
  21369. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21370. */
  21371. uvs2: Nullable<FloatArray>;
  21372. /**
  21373. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21374. */
  21375. uvs3: Nullable<FloatArray>;
  21376. /**
  21377. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21378. */
  21379. uvs4: Nullable<FloatArray>;
  21380. /**
  21381. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21382. */
  21383. uvs5: Nullable<FloatArray>;
  21384. /**
  21385. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21386. */
  21387. uvs6: Nullable<FloatArray>;
  21388. /**
  21389. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21390. */
  21391. colors: Nullable<FloatArray>;
  21392. /**
  21393. * 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).
  21394. */
  21395. matricesIndices: Nullable<FloatArray>;
  21396. /**
  21397. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21398. */
  21399. matricesWeights: Nullable<FloatArray>;
  21400. /**
  21401. * An array extending the number of possible indices
  21402. */
  21403. matricesIndicesExtra: Nullable<FloatArray>;
  21404. /**
  21405. * An array extending the number of possible weights when the number of indices is extended
  21406. */
  21407. matricesWeightsExtra: Nullable<FloatArray>;
  21408. /**
  21409. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21410. */
  21411. indices: Nullable<IndicesArray>;
  21412. /**
  21413. * Uses the passed data array to set the set the values for the specified kind of data
  21414. * @param data a linear array of floating numbers
  21415. * @param kind the type of data that is being set, eg positions, colors etc
  21416. */
  21417. set(data: FloatArray, kind: string): void;
  21418. /**
  21419. * Associates the vertexData to the passed Mesh.
  21420. * Sets it as updatable or not (default `false`)
  21421. * @param mesh the mesh the vertexData is applied to
  21422. * @param updatable when used and having the value true allows new data to update the vertexData
  21423. * @returns the VertexData
  21424. */
  21425. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21426. /**
  21427. * Associates the vertexData to the passed Geometry.
  21428. * Sets it as updatable or not (default `false`)
  21429. * @param geometry the geometry the vertexData is applied to
  21430. * @param updatable when used and having the value true allows new data to update the vertexData
  21431. * @returns VertexData
  21432. */
  21433. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21434. /**
  21435. * Updates the associated mesh
  21436. * @param mesh the mesh to be updated
  21437. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21438. * @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
  21439. * @returns VertexData
  21440. */
  21441. updateMesh(mesh: Mesh): VertexData;
  21442. /**
  21443. * Updates the associated geometry
  21444. * @param geometry the geometry to be updated
  21445. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21446. * @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
  21447. * @returns VertexData.
  21448. */
  21449. updateGeometry(geometry: Geometry): VertexData;
  21450. private _applyTo;
  21451. private _update;
  21452. /**
  21453. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21454. * @param matrix the transforming matrix
  21455. * @returns the VertexData
  21456. */
  21457. transform(matrix: Matrix): VertexData;
  21458. /**
  21459. * Merges the passed VertexData into the current one
  21460. * @param other the VertexData to be merged into the current one
  21461. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21462. * @returns the modified VertexData
  21463. */
  21464. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21465. private _mergeElement;
  21466. private _validate;
  21467. /**
  21468. * Serializes the VertexData
  21469. * @returns a serialized object
  21470. */
  21471. serialize(): any;
  21472. /**
  21473. * Extracts the vertexData from a mesh
  21474. * @param mesh the mesh from which to extract the VertexData
  21475. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21476. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21477. * @returns the object VertexData associated to the passed mesh
  21478. */
  21479. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21480. /**
  21481. * Extracts the vertexData from the geometry
  21482. * @param geometry the geometry from which to extract the VertexData
  21483. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21484. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21485. * @returns the object VertexData associated to the passed mesh
  21486. */
  21487. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21488. private static _ExtractFrom;
  21489. /**
  21490. * Creates the VertexData for a Ribbon
  21491. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21492. * * pathArray array of paths, each of which an array of successive Vector3
  21493. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21494. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21495. * * 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
  21496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21497. * * 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)
  21498. * * 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)
  21499. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21500. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21501. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21502. * @returns the VertexData of the ribbon
  21503. */
  21504. static CreateRibbon(options: {
  21505. pathArray: Vector3[][];
  21506. closeArray?: boolean;
  21507. closePath?: boolean;
  21508. offset?: number;
  21509. sideOrientation?: number;
  21510. frontUVs?: Vector4;
  21511. backUVs?: Vector4;
  21512. invertUV?: boolean;
  21513. uvs?: Vector2[];
  21514. colors?: Color4[];
  21515. }): VertexData;
  21516. /**
  21517. * Creates the VertexData for a box
  21518. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21519. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21520. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21521. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21522. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21523. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21524. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21525. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21526. * * 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)
  21527. * * 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)
  21528. * @returns the VertexData of the box
  21529. */
  21530. static CreateBox(options: {
  21531. size?: number;
  21532. width?: number;
  21533. height?: number;
  21534. depth?: number;
  21535. faceUV?: Vector4[];
  21536. faceColors?: Color4[];
  21537. sideOrientation?: number;
  21538. frontUVs?: Vector4;
  21539. backUVs?: Vector4;
  21540. }): VertexData;
  21541. /**
  21542. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21543. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21544. * * segments sets the number of horizontal strips optional, default 32
  21545. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21546. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21547. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21548. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21549. * * 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
  21550. * * 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
  21551. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21552. * * 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)
  21553. * * 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)
  21554. * @returns the VertexData of the ellipsoid
  21555. */
  21556. static CreateSphere(options: {
  21557. segments?: number;
  21558. diameter?: number;
  21559. diameterX?: number;
  21560. diameterY?: number;
  21561. diameterZ?: number;
  21562. arc?: number;
  21563. slice?: number;
  21564. sideOrientation?: number;
  21565. frontUVs?: Vector4;
  21566. backUVs?: Vector4;
  21567. }): VertexData;
  21568. /**
  21569. * Creates the VertexData for a cylinder, cone or prism
  21570. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21571. * * height sets the height (y direction) of the cylinder, optional, default 2
  21572. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21573. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21574. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21575. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21576. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21577. * * 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
  21578. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21579. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21580. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21581. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21582. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21583. * * 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)
  21584. * * 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)
  21585. * @returns the VertexData of the cylinder, cone or prism
  21586. */
  21587. static CreateCylinder(options: {
  21588. height?: number;
  21589. diameterTop?: number;
  21590. diameterBottom?: number;
  21591. diameter?: number;
  21592. tessellation?: number;
  21593. subdivisions?: number;
  21594. arc?: number;
  21595. faceColors?: Color4[];
  21596. faceUV?: Vector4[];
  21597. hasRings?: boolean;
  21598. enclose?: boolean;
  21599. sideOrientation?: number;
  21600. frontUVs?: Vector4;
  21601. backUVs?: Vector4;
  21602. }): VertexData;
  21603. /**
  21604. * Creates the VertexData for a torus
  21605. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21606. * * diameter the diameter of the torus, optional default 1
  21607. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21608. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21609. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21610. * * 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)
  21611. * * 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)
  21612. * @returns the VertexData of the torus
  21613. */
  21614. static CreateTorus(options: {
  21615. diameter?: number;
  21616. thickness?: number;
  21617. tessellation?: number;
  21618. sideOrientation?: number;
  21619. frontUVs?: Vector4;
  21620. backUVs?: Vector4;
  21621. }): VertexData;
  21622. /**
  21623. * Creates the VertexData of the LineSystem
  21624. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21625. * - lines an array of lines, each line being an array of successive Vector3
  21626. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21627. * @returns the VertexData of the LineSystem
  21628. */
  21629. static CreateLineSystem(options: {
  21630. lines: Vector3[][];
  21631. colors?: Nullable<Color4[][]>;
  21632. }): VertexData;
  21633. /**
  21634. * Create the VertexData for a DashedLines
  21635. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21636. * - points an array successive Vector3
  21637. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21638. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21639. * - dashNb the intended total number of dashes, optional, default 200
  21640. * @returns the VertexData for the DashedLines
  21641. */
  21642. static CreateDashedLines(options: {
  21643. points: Vector3[];
  21644. dashSize?: number;
  21645. gapSize?: number;
  21646. dashNb?: number;
  21647. }): VertexData;
  21648. /**
  21649. * Creates the VertexData for a Ground
  21650. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21651. * - width the width (x direction) of the ground, optional, default 1
  21652. * - height the height (z direction) of the ground, optional, default 1
  21653. * - subdivisions the number of subdivisions per side, optional, default 1
  21654. * @returns the VertexData of the Ground
  21655. */
  21656. static CreateGround(options: {
  21657. width?: number;
  21658. height?: number;
  21659. subdivisions?: number;
  21660. subdivisionsX?: number;
  21661. subdivisionsY?: number;
  21662. }): VertexData;
  21663. /**
  21664. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21665. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21666. * * xmin the ground minimum X coordinate, optional, default -1
  21667. * * zmin the ground minimum Z coordinate, optional, default -1
  21668. * * xmax the ground maximum X coordinate, optional, default 1
  21669. * * zmax the ground maximum Z coordinate, optional, default 1
  21670. * * 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}
  21671. * * 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}
  21672. * @returns the VertexData of the TiledGround
  21673. */
  21674. static CreateTiledGround(options: {
  21675. xmin: number;
  21676. zmin: number;
  21677. xmax: number;
  21678. zmax: number;
  21679. subdivisions?: {
  21680. w: number;
  21681. h: number;
  21682. };
  21683. precision?: {
  21684. w: number;
  21685. h: number;
  21686. };
  21687. }): VertexData;
  21688. /**
  21689. * Creates the VertexData of the Ground designed from a heightmap
  21690. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21691. * * width the width (x direction) of the ground
  21692. * * height the height (z direction) of the ground
  21693. * * subdivisions the number of subdivisions per side
  21694. * * minHeight the minimum altitude on the ground, optional, default 0
  21695. * * maxHeight the maximum altitude on the ground, optional default 1
  21696. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21697. * * buffer the array holding the image color data
  21698. * * bufferWidth the width of image
  21699. * * bufferHeight the height of image
  21700. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21701. * @returns the VertexData of the Ground designed from a heightmap
  21702. */
  21703. static CreateGroundFromHeightMap(options: {
  21704. width: number;
  21705. height: number;
  21706. subdivisions: number;
  21707. minHeight: number;
  21708. maxHeight: number;
  21709. colorFilter: Color3;
  21710. buffer: Uint8Array;
  21711. bufferWidth: number;
  21712. bufferHeight: number;
  21713. alphaFilter: number;
  21714. }): VertexData;
  21715. /**
  21716. * Creates the VertexData for a Plane
  21717. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21718. * * size sets the width and height of the plane to the value of size, optional default 1
  21719. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21720. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21721. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21722. * * 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)
  21723. * * 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)
  21724. * @returns the VertexData of the box
  21725. */
  21726. static CreatePlane(options: {
  21727. size?: number;
  21728. width?: number;
  21729. height?: number;
  21730. sideOrientation?: number;
  21731. frontUVs?: Vector4;
  21732. backUVs?: Vector4;
  21733. }): VertexData;
  21734. /**
  21735. * Creates the VertexData of the Disc or regular Polygon
  21736. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21737. * * radius the radius of the disc, optional default 0.5
  21738. * * tessellation the number of polygon sides, optional, default 64
  21739. * * 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
  21740. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21741. * * 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)
  21742. * * 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)
  21743. * @returns the VertexData of the box
  21744. */
  21745. static CreateDisc(options: {
  21746. radius?: number;
  21747. tessellation?: number;
  21748. arc?: number;
  21749. sideOrientation?: number;
  21750. frontUVs?: Vector4;
  21751. backUVs?: Vector4;
  21752. }): VertexData;
  21753. /**
  21754. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21755. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21756. * @param polygon a mesh built from polygonTriangulation.build()
  21757. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21758. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21759. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21760. * @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)
  21761. * @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)
  21762. * @returns the VertexData of the Polygon
  21763. */
  21764. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21765. /**
  21766. * Creates the VertexData of the IcoSphere
  21767. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21768. * * radius the radius of the IcoSphere, optional default 1
  21769. * * radiusX allows stretching in the x direction, optional, default radius
  21770. * * radiusY allows stretching in the y direction, optional, default radius
  21771. * * radiusZ allows stretching in the z direction, optional, default radius
  21772. * * flat when true creates a flat shaded mesh, optional, default true
  21773. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21774. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21775. * * 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)
  21776. * * 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)
  21777. * @returns the VertexData of the IcoSphere
  21778. */
  21779. static CreateIcoSphere(options: {
  21780. radius?: number;
  21781. radiusX?: number;
  21782. radiusY?: number;
  21783. radiusZ?: number;
  21784. flat?: boolean;
  21785. subdivisions?: number;
  21786. sideOrientation?: number;
  21787. frontUVs?: Vector4;
  21788. backUVs?: Vector4;
  21789. }): VertexData;
  21790. /**
  21791. * Creates the VertexData for a Polyhedron
  21792. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21793. * * type provided types are:
  21794. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21795. * * 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)
  21796. * * size the size of the IcoSphere, optional default 1
  21797. * * sizeX allows stretching in the x direction, optional, default size
  21798. * * sizeY allows stretching in the y direction, optional, default size
  21799. * * sizeZ allows stretching in the z direction, optional, default size
  21800. * * 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
  21801. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21802. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21803. * * flat when true creates a flat shaded mesh, optional, default true
  21804. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21805. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21806. * * 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)
  21807. * * 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)
  21808. * @returns the VertexData of the Polyhedron
  21809. */
  21810. static CreatePolyhedron(options: {
  21811. type?: number;
  21812. size?: number;
  21813. sizeX?: number;
  21814. sizeY?: number;
  21815. sizeZ?: number;
  21816. custom?: any;
  21817. faceUV?: Vector4[];
  21818. faceColors?: Color4[];
  21819. flat?: boolean;
  21820. sideOrientation?: number;
  21821. frontUVs?: Vector4;
  21822. backUVs?: Vector4;
  21823. }): VertexData;
  21824. /**
  21825. * Creates the VertexData for a TorusKnot
  21826. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21827. * * radius the radius of the torus knot, optional, default 2
  21828. * * tube the thickness of the tube, optional, default 0.5
  21829. * * radialSegments the number of sides on each tube segments, optional, default 32
  21830. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21831. * * p the number of windings around the z axis, optional, default 2
  21832. * * q the number of windings around the x axis, optional, default 3
  21833. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21834. * * 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)
  21835. * * 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)
  21836. * @returns the VertexData of the Torus Knot
  21837. */
  21838. static CreateTorusKnot(options: {
  21839. radius?: number;
  21840. tube?: number;
  21841. radialSegments?: number;
  21842. tubularSegments?: number;
  21843. p?: number;
  21844. q?: number;
  21845. sideOrientation?: number;
  21846. frontUVs?: Vector4;
  21847. backUVs?: Vector4;
  21848. }): VertexData;
  21849. /**
  21850. * Compute normals for given positions and indices
  21851. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21852. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21853. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21854. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21855. * * facetNormals : optional array of facet normals (vector3)
  21856. * * facetPositions : optional array of facet positions (vector3)
  21857. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21858. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21859. * * bInfo : optional bounding info, required for facetPartitioning computation
  21860. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21861. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21862. * * useRightHandedSystem: optional boolean to for right handed system computation
  21863. * * depthSort : optional boolean to enable the facet depth sort computation
  21864. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21865. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21866. */
  21867. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21868. facetNormals?: any;
  21869. facetPositions?: any;
  21870. facetPartitioning?: any;
  21871. ratio?: number;
  21872. bInfo?: any;
  21873. bbSize?: Vector3;
  21874. subDiv?: any;
  21875. useRightHandedSystem?: boolean;
  21876. depthSort?: boolean;
  21877. distanceTo?: Vector3;
  21878. depthSortedFacets?: any;
  21879. }): void;
  21880. /** @hidden */
  21881. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21882. /**
  21883. * Applies VertexData created from the imported parameters to the geometry
  21884. * @param parsedVertexData the parsed data from an imported file
  21885. * @param geometry the geometry to apply the VertexData to
  21886. */
  21887. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21888. }
  21889. }
  21890. declare module BABYLON {
  21891. /**
  21892. * Class containing static functions to help procedurally build meshes
  21893. */
  21894. export class DiscBuilder {
  21895. /**
  21896. * Creates a plane polygonal mesh. By default, this is a disc
  21897. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  21898. * * 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
  21899. * * 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
  21900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21901. * * 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
  21902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21903. * @param name defines the name of the mesh
  21904. * @param options defines the options used to create the mesh
  21905. * @param scene defines the hosting scene
  21906. * @returns the plane polygonal mesh
  21907. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  21908. */
  21909. static CreateDisc(name: string, options: {
  21910. radius?: number;
  21911. tessellation?: number;
  21912. arc?: number;
  21913. updatable?: boolean;
  21914. sideOrientation?: number;
  21915. frontUVs?: Vector4;
  21916. backUVs?: Vector4;
  21917. }, scene?: Nullable<Scene>): Mesh;
  21918. }
  21919. }
  21920. declare module BABYLON {
  21921. /**
  21922. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  21923. *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.
  21924. * The SPS is also a particle system. It provides some methods to manage the particles.
  21925. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  21926. *
  21927. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  21928. */
  21929. export class SolidParticleSystem implements IDisposable {
  21930. /**
  21931. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  21932. * Example : var p = SPS.particles[i];
  21933. */
  21934. particles: SolidParticle[];
  21935. /**
  21936. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  21937. */
  21938. nbParticles: number;
  21939. /**
  21940. * If the particles must ever face the camera (default false). Useful for planar particles.
  21941. */
  21942. billboard: boolean;
  21943. /**
  21944. * Recompute normals when adding a shape
  21945. */
  21946. recomputeNormals: boolean;
  21947. /**
  21948. * This a counter ofr your own usage. It's not set by any SPS functions.
  21949. */
  21950. counter: number;
  21951. /**
  21952. * The SPS name. This name is also given to the underlying mesh.
  21953. */
  21954. name: string;
  21955. /**
  21956. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  21957. */
  21958. mesh: Mesh;
  21959. /**
  21960. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  21961. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  21962. */
  21963. vars: any;
  21964. /**
  21965. * This array is populated when the SPS is set as 'pickable'.
  21966. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  21967. * Each element of this array is an object `{idx: int, faceId: int}`.
  21968. * `idx` is the picked particle index in the `SPS.particles` array
  21969. * `faceId` is the picked face index counted within this particle.
  21970. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  21971. */
  21972. pickedParticles: {
  21973. idx: number;
  21974. faceId: number;
  21975. }[];
  21976. /**
  21977. * This array is populated when `enableDepthSort` is set to true.
  21978. * Each element of this array is an instance of the class DepthSortedParticle.
  21979. */
  21980. depthSortedParticles: DepthSortedParticle[];
  21981. /**
  21982. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  21983. * @hidden
  21984. */
  21985. _bSphereOnly: boolean;
  21986. /**
  21987. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  21988. * @hidden
  21989. */
  21990. _bSphereRadiusFactor: number;
  21991. private _scene;
  21992. private _positions;
  21993. private _indices;
  21994. private _normals;
  21995. private _colors;
  21996. private _uvs;
  21997. private _indices32;
  21998. private _positions32;
  21999. private _normals32;
  22000. private _fixedNormal32;
  22001. private _colors32;
  22002. private _uvs32;
  22003. private _index;
  22004. private _updatable;
  22005. private _pickable;
  22006. private _isVisibilityBoxLocked;
  22007. private _alwaysVisible;
  22008. private _depthSort;
  22009. private _shapeCounter;
  22010. private _copy;
  22011. private _color;
  22012. private _computeParticleColor;
  22013. private _computeParticleTexture;
  22014. private _computeParticleRotation;
  22015. private _computeParticleVertex;
  22016. private _computeBoundingBox;
  22017. private _depthSortParticles;
  22018. private _camera;
  22019. private _mustUnrotateFixedNormals;
  22020. private _particlesIntersect;
  22021. private _needs32Bits;
  22022. /**
  22023. * Creates a SPS (Solid Particle System) object.
  22024. * @param name (String) is the SPS name, this will be the underlying mesh name.
  22025. * @param scene (Scene) is the scene in which the SPS is added.
  22026. * @param options defines the options of the sps e.g.
  22027. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  22028. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  22029. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  22030. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  22031. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  22032. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  22033. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  22034. */
  22035. constructor(name: string, scene: Scene, options?: {
  22036. updatable?: boolean;
  22037. isPickable?: boolean;
  22038. enableDepthSort?: boolean;
  22039. particleIntersection?: boolean;
  22040. boundingSphereOnly?: boolean;
  22041. bSphereRadiusFactor?: number;
  22042. });
  22043. /**
  22044. * Builds the SPS underlying mesh. Returns a standard Mesh.
  22045. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  22046. * @returns the created mesh
  22047. */
  22048. buildMesh(): Mesh;
  22049. /**
  22050. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  22051. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  22052. * Thus the particles generated from `digest()` have their property `position` set yet.
  22053. * @param mesh ( Mesh ) is the mesh to be digested
  22054. * @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
  22055. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  22056. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  22057. * @returns the current SPS
  22058. */
  22059. digest(mesh: Mesh, options?: {
  22060. facetNb?: number;
  22061. number?: number;
  22062. delta?: number;
  22063. }): SolidParticleSystem;
  22064. private _unrotateFixedNormals;
  22065. private _resetCopy;
  22066. private _meshBuilder;
  22067. private _posToShape;
  22068. private _uvsToShapeUV;
  22069. private _addParticle;
  22070. /**
  22071. * Adds some particles to the SPS from the model shape. Returns the shape id.
  22072. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  22073. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  22074. * @param nb (positive integer) the number of particles to be created from this model
  22075. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  22076. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  22077. * @returns the number of shapes in the system
  22078. */
  22079. addShape(mesh: Mesh, nb: number, options?: {
  22080. positionFunction?: any;
  22081. vertexFunction?: any;
  22082. }): number;
  22083. private _rebuildParticle;
  22084. /**
  22085. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  22086. * @returns the SPS.
  22087. */
  22088. rebuildMesh(): SolidParticleSystem;
  22089. /**
  22090. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  22091. * This method calls `updateParticle()` for each particle of the SPS.
  22092. * For an animated SPS, it is usually called within the render loop.
  22093. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  22094. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  22095. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  22096. * @returns the SPS.
  22097. */
  22098. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  22099. /**
  22100. * Disposes the SPS.
  22101. */
  22102. dispose(): void;
  22103. /**
  22104. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  22105. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22106. * @returns the SPS.
  22107. */
  22108. refreshVisibleSize(): SolidParticleSystem;
  22109. /**
  22110. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  22111. * @param size the size (float) of the visibility box
  22112. * note : this doesn't lock the SPS mesh bounding box.
  22113. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22114. */
  22115. setVisibilityBox(size: number): void;
  22116. /**
  22117. * Gets whether the SPS as always visible or not
  22118. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22119. */
  22120. /**
  22121. * Sets the SPS as always visible or not
  22122. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22123. */
  22124. isAlwaysVisible: boolean;
  22125. /**
  22126. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22127. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22128. */
  22129. /**
  22130. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22131. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22132. */
  22133. isVisibilityBoxLocked: boolean;
  22134. /**
  22135. * Tells to `setParticles()` to compute the particle rotations or not.
  22136. * Default value : true. The SPS is faster when it's set to false.
  22137. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22138. */
  22139. /**
  22140. * Gets if `setParticles()` computes the particle rotations or not.
  22141. * Default value : true. The SPS is faster when it's set to false.
  22142. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22143. */
  22144. computeParticleRotation: boolean;
  22145. /**
  22146. * Tells to `setParticles()` to compute the particle colors or not.
  22147. * Default value : true. The SPS is faster when it's set to false.
  22148. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22149. */
  22150. /**
  22151. * Gets if `setParticles()` computes the particle colors or not.
  22152. * Default value : true. The SPS is faster when it's set to false.
  22153. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22154. */
  22155. computeParticleColor: boolean;
  22156. /**
  22157. * Gets if `setParticles()` computes the particle textures or not.
  22158. * Default value : true. The SPS is faster when it's set to false.
  22159. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  22160. */
  22161. computeParticleTexture: boolean;
  22162. /**
  22163. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  22164. * Default value : false. The SPS is faster when it's set to false.
  22165. * Note : the particle custom vertex positions aren't stored values.
  22166. */
  22167. /**
  22168. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  22169. * Default value : false. The SPS is faster when it's set to false.
  22170. * Note : the particle custom vertex positions aren't stored values.
  22171. */
  22172. computeParticleVertex: boolean;
  22173. /**
  22174. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  22175. */
  22176. /**
  22177. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  22178. */
  22179. computeBoundingBox: boolean;
  22180. /**
  22181. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  22182. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22183. * Default : `true`
  22184. */
  22185. /**
  22186. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  22187. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22188. * Default : `true`
  22189. */
  22190. depthSortParticles: boolean;
  22191. /**
  22192. * This function does nothing. It may be overwritten to set all the particle first values.
  22193. * The SPS doesn't call this function, you may have to call it by your own.
  22194. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22195. */
  22196. initParticles(): void;
  22197. /**
  22198. * This function does nothing. It may be overwritten to recycle a particle.
  22199. * The SPS doesn't call this function, you may have to call it by your own.
  22200. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22201. * @param particle The particle to recycle
  22202. * @returns the recycled particle
  22203. */
  22204. recycleParticle(particle: SolidParticle): SolidParticle;
  22205. /**
  22206. * Updates a particle : this function should be overwritten by the user.
  22207. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  22208. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22209. * @example : just set a particle position or velocity and recycle conditions
  22210. * @param particle The particle to update
  22211. * @returns the updated particle
  22212. */
  22213. updateParticle(particle: SolidParticle): SolidParticle;
  22214. /**
  22215. * Updates a vertex of a particle : it can be overwritten by the user.
  22216. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  22217. * @param particle the current particle
  22218. * @param vertex the current index of the current particle
  22219. * @param pt the index of the current vertex in the particle shape
  22220. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  22221. * @example : just set a vertex particle position
  22222. * @returns the updated vertex
  22223. */
  22224. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  22225. /**
  22226. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  22227. * This does nothing and may be overwritten by the user.
  22228. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22229. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22230. * @param update the boolean update value actually passed to setParticles()
  22231. */
  22232. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22233. /**
  22234. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  22235. * This will be passed three parameters.
  22236. * This does nothing and may be overwritten by the user.
  22237. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22238. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22239. * @param update the boolean update value actually passed to setParticles()
  22240. */
  22241. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22242. }
  22243. }
  22244. declare module BABYLON {
  22245. /**
  22246. * Represents one particle of a solid particle system.
  22247. */
  22248. export class SolidParticle {
  22249. /**
  22250. * particle global index
  22251. */
  22252. idx: number;
  22253. /**
  22254. * The color of the particle
  22255. */
  22256. color: Nullable<Color4>;
  22257. /**
  22258. * The world space position of the particle.
  22259. */
  22260. position: Vector3;
  22261. /**
  22262. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  22263. */
  22264. rotation: Vector3;
  22265. /**
  22266. * The world space rotation quaternion of the particle.
  22267. */
  22268. rotationQuaternion: Nullable<Quaternion>;
  22269. /**
  22270. * The scaling of the particle.
  22271. */
  22272. scaling: Vector3;
  22273. /**
  22274. * The uvs of the particle.
  22275. */
  22276. uvs: Vector4;
  22277. /**
  22278. * The current speed of the particle.
  22279. */
  22280. velocity: Vector3;
  22281. /**
  22282. * The pivot point in the particle local space.
  22283. */
  22284. pivot: Vector3;
  22285. /**
  22286. * Must the particle be translated from its pivot point in its local space ?
  22287. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  22288. * Default : false
  22289. */
  22290. translateFromPivot: boolean;
  22291. /**
  22292. * Is the particle active or not ?
  22293. */
  22294. alive: boolean;
  22295. /**
  22296. * Is the particle visible or not ?
  22297. */
  22298. isVisible: boolean;
  22299. /**
  22300. * Index of this particle in the global "positions" array (Internal use)
  22301. * @hidden
  22302. */
  22303. _pos: number;
  22304. /**
  22305. * @hidden Index of this particle in the global "indices" array (Internal use)
  22306. */
  22307. _ind: number;
  22308. /**
  22309. * @hidden ModelShape of this particle (Internal use)
  22310. */
  22311. _model: ModelShape;
  22312. /**
  22313. * ModelShape id of this particle
  22314. */
  22315. shapeId: number;
  22316. /**
  22317. * Index of the particle in its shape id (Internal use)
  22318. */
  22319. idxInShape: number;
  22320. /**
  22321. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  22322. */
  22323. _modelBoundingInfo: BoundingInfo;
  22324. /**
  22325. * @hidden Particle BoundingInfo object (Internal use)
  22326. */
  22327. _boundingInfo: BoundingInfo;
  22328. /**
  22329. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  22330. */
  22331. _sps: SolidParticleSystem;
  22332. /**
  22333. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  22334. */
  22335. _stillInvisible: boolean;
  22336. /**
  22337. * @hidden Last computed particle rotation matrix
  22338. */
  22339. _rotationMatrix: number[];
  22340. /**
  22341. * Parent particle Id, if any.
  22342. * Default null.
  22343. */
  22344. parentId: Nullable<number>;
  22345. /**
  22346. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  22347. * The possible values are :
  22348. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  22349. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22350. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  22351. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  22352. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22353. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  22354. * */
  22355. cullingStrategy: number;
  22356. /**
  22357. * @hidden Internal global position in the SPS.
  22358. */
  22359. _globalPosition: Vector3;
  22360. /**
  22361. * Creates a Solid Particle object.
  22362. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  22363. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  22364. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  22365. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  22366. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  22367. * @param shapeId (integer) is the model shape identifier in the SPS.
  22368. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  22369. * @param sps defines the sps it is associated to
  22370. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  22371. */
  22372. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  22373. /**
  22374. * Legacy support, changed scale to scaling
  22375. */
  22376. /**
  22377. * Legacy support, changed scale to scaling
  22378. */
  22379. scale: Vector3;
  22380. /**
  22381. * Legacy support, changed quaternion to rotationQuaternion
  22382. */
  22383. /**
  22384. * Legacy support, changed quaternion to rotationQuaternion
  22385. */
  22386. quaternion: Nullable<Quaternion>;
  22387. /**
  22388. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  22389. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  22390. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  22391. * @returns true if it intersects
  22392. */
  22393. intersectsMesh(target: Mesh | SolidParticle): boolean;
  22394. /**
  22395. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  22396. * A particle is in the frustum if its bounding box intersects the frustum
  22397. * @param frustumPlanes defines the frustum to test
  22398. * @returns true if the particle is in the frustum planes
  22399. */
  22400. isInFrustum(frustumPlanes: Plane[]): boolean;
  22401. /**
  22402. * get the rotation matrix of the particle
  22403. * @hidden
  22404. */
  22405. getRotationMatrix(m: Matrix): void;
  22406. }
  22407. /**
  22408. * Represents the shape of the model used by one particle of a solid particle system.
  22409. * SPS internal tool, don't use it manually.
  22410. */
  22411. export class ModelShape {
  22412. /**
  22413. * The shape id
  22414. * @hidden
  22415. */
  22416. shapeID: number;
  22417. /**
  22418. * flat array of model positions (internal use)
  22419. * @hidden
  22420. */
  22421. _shape: Vector3[];
  22422. /**
  22423. * flat array of model UVs (internal use)
  22424. * @hidden
  22425. */
  22426. _shapeUV: number[];
  22427. /**
  22428. * length of the shape in the model indices array (internal use)
  22429. * @hidden
  22430. */
  22431. _indicesLength: number;
  22432. /**
  22433. * Custom position function (internal use)
  22434. * @hidden
  22435. */
  22436. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  22437. /**
  22438. * Custom vertex function (internal use)
  22439. * @hidden
  22440. */
  22441. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  22442. /**
  22443. * 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.
  22444. * SPS internal tool, don't use it manually.
  22445. * @hidden
  22446. */
  22447. 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>);
  22448. }
  22449. /**
  22450. * Represents a Depth Sorted Particle in the solid particle system.
  22451. */
  22452. export class DepthSortedParticle {
  22453. /**
  22454. * Index of the particle in the "indices" array
  22455. */
  22456. ind: number;
  22457. /**
  22458. * Length of the particle shape in the "indices" array
  22459. */
  22460. indicesLength: number;
  22461. /**
  22462. * Squared distance from the particle to the camera
  22463. */
  22464. sqDistance: number;
  22465. }
  22466. }
  22467. declare module BABYLON {
  22468. /**
  22469. * Class used to store all common mesh properties
  22470. */
  22471. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  22472. /** No occlusion */
  22473. static OCCLUSION_TYPE_NONE: number;
  22474. /** Occlusion set to optimisitic */
  22475. static OCCLUSION_TYPE_OPTIMISTIC: number;
  22476. /** Occlusion set to strict */
  22477. static OCCLUSION_TYPE_STRICT: number;
  22478. /** Use an accurante occlusion algorithm */
  22479. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  22480. /** Use a conservative occlusion algorithm */
  22481. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  22482. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  22483. * Test order :
  22484. * Is the bounding sphere outside the frustum ?
  22485. * If not, are the bounding box vertices outside the frustum ?
  22486. * It not, then the cullable object is in the frustum.
  22487. */
  22488. static readonly CULLINGSTRATEGY_STANDARD: number;
  22489. /** Culling strategy : Bounding Sphere Only.
  22490. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  22491. * It's also less accurate than the standard because some not visible objects can still be selected.
  22492. * Test : is the bounding sphere outside the frustum ?
  22493. * If not, then the cullable object is in the frustum.
  22494. */
  22495. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  22496. /** Culling strategy : Optimistic Inclusion.
  22497. * This in an inclusion test first, then the standard exclusion test.
  22498. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  22499. * 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.
  22500. * Anyway, it's as accurate as the standard strategy.
  22501. * Test :
  22502. * Is the cullable object bounding sphere center in the frustum ?
  22503. * If not, apply the default culling strategy.
  22504. */
  22505. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  22506. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  22507. * This in an inclusion test first, then the bounding sphere only exclusion test.
  22508. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  22509. * 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.
  22510. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  22511. * Test :
  22512. * Is the cullable object bounding sphere center in the frustum ?
  22513. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  22514. */
  22515. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  22516. /**
  22517. * No billboard
  22518. */
  22519. static readonly BILLBOARDMODE_NONE: number;
  22520. /** Billboard on X axis */
  22521. static readonly BILLBOARDMODE_X: number;
  22522. /** Billboard on Y axis */
  22523. static readonly BILLBOARDMODE_Y: number;
  22524. /** Billboard on Z axis */
  22525. static readonly BILLBOARDMODE_Z: number;
  22526. /** Billboard on all axes */
  22527. static readonly BILLBOARDMODE_ALL: number;
  22528. private _facetData;
  22529. /**
  22530. * The culling strategy to use to check whether the mesh must be rendered or not.
  22531. * This value can be changed at any time and will be used on the next render mesh selection.
  22532. * The possible values are :
  22533. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  22534. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22535. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  22536. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  22537. * Please read each static variable documentation to get details about the culling process.
  22538. * */
  22539. cullingStrategy: number;
  22540. /**
  22541. * Gets the number of facets in the mesh
  22542. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  22543. */
  22544. readonly facetNb: number;
  22545. /**
  22546. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  22547. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  22548. */
  22549. partitioningSubdivisions: number;
  22550. /**
  22551. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  22552. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  22553. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  22554. */
  22555. partitioningBBoxRatio: number;
  22556. /**
  22557. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  22558. * Works only for updatable meshes.
  22559. * Doesn't work with multi-materials
  22560. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  22561. */
  22562. mustDepthSortFacets: boolean;
  22563. /**
  22564. * The location (Vector3) where the facet depth sort must be computed from.
  22565. * By default, the active camera position.
  22566. * Used only when facet depth sort is enabled
  22567. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  22568. */
  22569. facetDepthSortFrom: Vector3;
  22570. /**
  22571. * gets a boolean indicating if facetData is enabled
  22572. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  22573. */
  22574. readonly isFacetDataEnabled: boolean;
  22575. /** @hidden */
  22576. _updateNonUniformScalingState(value: boolean): boolean;
  22577. /**
  22578. * An event triggered when this mesh collides with another one
  22579. */
  22580. onCollideObservable: Observable<AbstractMesh>;
  22581. private _onCollideObserver;
  22582. /** Set a function to call when this mesh collides with another one */
  22583. onCollide: () => void;
  22584. /**
  22585. * An event triggered when the collision's position changes
  22586. */
  22587. onCollisionPositionChangeObservable: Observable<Vector3>;
  22588. private _onCollisionPositionChangeObserver;
  22589. /** Set a function to call when the collision's position changes */
  22590. onCollisionPositionChange: () => void;
  22591. /**
  22592. * An event triggered when material is changed
  22593. */
  22594. onMaterialChangedObservable: Observable<AbstractMesh>;
  22595. /**
  22596. * Gets or sets the orientation for POV movement & rotation
  22597. */
  22598. definedFacingForward: boolean;
  22599. /** @hidden */
  22600. _occlusionQuery: Nullable<WebGLQuery>;
  22601. private _visibility;
  22602. /**
  22603. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  22604. */
  22605. /**
  22606. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  22607. */
  22608. visibility: number;
  22609. /** Gets or sets the alpha index used to sort transparent meshes
  22610. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  22611. */
  22612. alphaIndex: number;
  22613. /**
  22614. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  22615. */
  22616. isVisible: boolean;
  22617. /**
  22618. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  22619. */
  22620. isPickable: boolean;
  22621. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  22622. showSubMeshesBoundingBox: boolean;
  22623. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  22624. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  22625. */
  22626. isBlocker: boolean;
  22627. /**
  22628. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  22629. */
  22630. enablePointerMoveEvents: boolean;
  22631. /**
  22632. * Specifies the rendering group id for this mesh (0 by default)
  22633. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  22634. */
  22635. renderingGroupId: number;
  22636. private _material;
  22637. /** Gets or sets current material */
  22638. material: Nullable<Material>;
  22639. private _receiveShadows;
  22640. /**
  22641. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  22642. * @see http://doc.babylonjs.com/babylon101/shadows
  22643. */
  22644. receiveShadows: boolean;
  22645. /** Defines color to use when rendering outline */
  22646. outlineColor: Color3;
  22647. /** Define width to use when rendering outline */
  22648. outlineWidth: number;
  22649. /** Defines color to use when rendering overlay */
  22650. overlayColor: Color3;
  22651. /** Defines alpha to use when rendering overlay */
  22652. overlayAlpha: number;
  22653. private _hasVertexAlpha;
  22654. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  22655. hasVertexAlpha: boolean;
  22656. private _useVertexColors;
  22657. /** 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) */
  22658. useVertexColors: boolean;
  22659. private _computeBonesUsingShaders;
  22660. /**
  22661. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  22662. */
  22663. computeBonesUsingShaders: boolean;
  22664. private _numBoneInfluencers;
  22665. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  22666. numBoneInfluencers: number;
  22667. private _applyFog;
  22668. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  22669. applyFog: boolean;
  22670. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  22671. useOctreeForRenderingSelection: boolean;
  22672. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  22673. useOctreeForPicking: boolean;
  22674. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  22675. useOctreeForCollisions: boolean;
  22676. private _layerMask;
  22677. /**
  22678. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  22679. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  22680. */
  22681. layerMask: number;
  22682. /**
  22683. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  22684. */
  22685. alwaysSelectAsActiveMesh: boolean;
  22686. /**
  22687. * Gets or sets the current action manager
  22688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  22689. */
  22690. actionManager: Nullable<AbstractActionManager>;
  22691. private _checkCollisions;
  22692. private _collisionMask;
  22693. private _collisionGroup;
  22694. /**
  22695. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  22696. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22697. */
  22698. ellipsoid: Vector3;
  22699. /**
  22700. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  22701. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22702. */
  22703. ellipsoidOffset: Vector3;
  22704. private _collider;
  22705. private _oldPositionForCollisions;
  22706. private _diffPositionForCollisions;
  22707. /**
  22708. * Gets or sets a collision mask used to mask collisions (default is -1).
  22709. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  22710. */
  22711. collisionMask: number;
  22712. /**
  22713. * Gets or sets the current collision group mask (-1 by default).
  22714. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  22715. */
  22716. collisionGroup: number;
  22717. /**
  22718. * Defines edge width used when edgesRenderer is enabled
  22719. * @see https://www.babylonjs-playground.com/#10OJSG#13
  22720. */
  22721. edgesWidth: number;
  22722. /**
  22723. * Defines edge color used when edgesRenderer is enabled
  22724. * @see https://www.babylonjs-playground.com/#10OJSG#13
  22725. */
  22726. edgesColor: Color4;
  22727. /** @hidden */
  22728. _edgesRenderer: Nullable<IEdgesRenderer>;
  22729. /** @hidden */
  22730. _masterMesh: Nullable<AbstractMesh>;
  22731. /** @hidden */
  22732. _boundingInfo: Nullable<BoundingInfo>;
  22733. /** @hidden */
  22734. _renderId: number;
  22735. /**
  22736. * Gets or sets the list of subMeshes
  22737. * @see http://doc.babylonjs.com/how_to/multi_materials
  22738. */
  22739. subMeshes: SubMesh[];
  22740. /** @hidden */
  22741. _intersectionsInProgress: AbstractMesh[];
  22742. /** @hidden */
  22743. _unIndexed: boolean;
  22744. /** @hidden */
  22745. _lightSources: Light[];
  22746. /** @hidden */
  22747. readonly _positions: Nullable<Vector3[]>;
  22748. /** @hidden */
  22749. _waitingActions: any;
  22750. /** @hidden */
  22751. _waitingFreezeWorldMatrix: Nullable<boolean>;
  22752. private _skeleton;
  22753. /** @hidden */
  22754. _bonesTransformMatrices: Nullable<Float32Array>;
  22755. /**
  22756. * Gets or sets a skeleton to apply skining transformations
  22757. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  22758. */
  22759. skeleton: Nullable<Skeleton>;
  22760. /**
  22761. * An event triggered when the mesh is rebuilt.
  22762. */
  22763. onRebuildObservable: Observable<AbstractMesh>;
  22764. /**
  22765. * Creates a new AbstractMesh
  22766. * @param name defines the name of the mesh
  22767. * @param scene defines the hosting scene
  22768. */
  22769. constructor(name: string, scene?: Nullable<Scene>);
  22770. /**
  22771. * Returns the string "AbstractMesh"
  22772. * @returns "AbstractMesh"
  22773. */
  22774. getClassName(): string;
  22775. /**
  22776. * Gets a string representation of the current mesh
  22777. * @param fullDetails defines a boolean indicating if full details must be included
  22778. * @returns a string representation of the current mesh
  22779. */
  22780. toString(fullDetails?: boolean): string;
  22781. /** @hidden */
  22782. _rebuild(): void;
  22783. /** @hidden */
  22784. _resyncLightSources(): void;
  22785. /** @hidden */
  22786. _resyncLighSource(light: Light): void;
  22787. /** @hidden */
  22788. _unBindEffect(): void;
  22789. /** @hidden */
  22790. _removeLightSource(light: Light): void;
  22791. private _markSubMeshesAsDirty;
  22792. /** @hidden */
  22793. _markSubMeshesAsLightDirty(): void;
  22794. /** @hidden */
  22795. _markSubMeshesAsAttributesDirty(): void;
  22796. /** @hidden */
  22797. _markSubMeshesAsMiscDirty(): void;
  22798. /**
  22799. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  22800. */
  22801. scaling: Vector3;
  22802. /**
  22803. * Returns true if the mesh is blocked. Implemented by child classes
  22804. */
  22805. readonly isBlocked: boolean;
  22806. /**
  22807. * Returns the mesh itself by default. Implemented by child classes
  22808. * @param camera defines the camera to use to pick the right LOD level
  22809. * @returns the currentAbstractMesh
  22810. */
  22811. getLOD(camera: Camera): Nullable<AbstractMesh>;
  22812. /**
  22813. * Returns 0 by default. Implemented by child classes
  22814. * @returns an integer
  22815. */
  22816. getTotalVertices(): number;
  22817. /**
  22818. * Returns a positive integer : the total number of indices in this mesh geometry.
  22819. * @returns the numner of indices or zero if the mesh has no geometry.
  22820. */
  22821. getTotalIndices(): number;
  22822. /**
  22823. * Returns null by default. Implemented by child classes
  22824. * @returns null
  22825. */
  22826. getIndices(): Nullable<IndicesArray>;
  22827. /**
  22828. * Returns the array of the requested vertex data kind. Implemented by child classes
  22829. * @param kind defines the vertex data kind to use
  22830. * @returns null
  22831. */
  22832. getVerticesData(kind: string): Nullable<FloatArray>;
  22833. /**
  22834. * Sets the vertex data of the mesh geometry for the requested `kind`.
  22835. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  22836. * Note that a new underlying VertexBuffer object is created each call.
  22837. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  22838. * @param kind defines vertex data kind:
  22839. * * VertexBuffer.PositionKind
  22840. * * VertexBuffer.UVKind
  22841. * * VertexBuffer.UV2Kind
  22842. * * VertexBuffer.UV3Kind
  22843. * * VertexBuffer.UV4Kind
  22844. * * VertexBuffer.UV5Kind
  22845. * * VertexBuffer.UV6Kind
  22846. * * VertexBuffer.ColorKind
  22847. * * VertexBuffer.MatricesIndicesKind
  22848. * * VertexBuffer.MatricesIndicesExtraKind
  22849. * * VertexBuffer.MatricesWeightsKind
  22850. * * VertexBuffer.MatricesWeightsExtraKind
  22851. * @param data defines the data source
  22852. * @param updatable defines if the data must be flagged as updatable (or static)
  22853. * @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
  22854. * @returns the current mesh
  22855. */
  22856. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  22857. /**
  22858. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  22859. * If the mesh has no geometry, it is simply returned as it is.
  22860. * @param kind defines vertex data kind:
  22861. * * VertexBuffer.PositionKind
  22862. * * VertexBuffer.UVKind
  22863. * * VertexBuffer.UV2Kind
  22864. * * VertexBuffer.UV3Kind
  22865. * * VertexBuffer.UV4Kind
  22866. * * VertexBuffer.UV5Kind
  22867. * * VertexBuffer.UV6Kind
  22868. * * VertexBuffer.ColorKind
  22869. * * VertexBuffer.MatricesIndicesKind
  22870. * * VertexBuffer.MatricesIndicesExtraKind
  22871. * * VertexBuffer.MatricesWeightsKind
  22872. * * VertexBuffer.MatricesWeightsExtraKind
  22873. * @param data defines the data source
  22874. * @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
  22875. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  22876. * @returns the current mesh
  22877. */
  22878. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  22879. /**
  22880. * Sets the mesh indices,
  22881. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  22882. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  22883. * @param totalVertices Defines the total number of vertices
  22884. * @returns the current mesh
  22885. */
  22886. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  22887. /**
  22888. * Gets a boolean indicating if specific vertex data is present
  22889. * @param kind defines the vertex data kind to use
  22890. * @returns true is data kind is present
  22891. */
  22892. isVerticesDataPresent(kind: string): boolean;
  22893. /**
  22894. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  22895. * @returns a BoundingInfo
  22896. */
  22897. getBoundingInfo(): BoundingInfo;
  22898. /**
  22899. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  22900. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  22901. * @returns the current mesh
  22902. */
  22903. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  22904. /**
  22905. * Overwrite the current bounding info
  22906. * @param boundingInfo defines the new bounding info
  22907. * @returns the current mesh
  22908. */
  22909. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  22910. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  22911. readonly useBones: boolean;
  22912. /** @hidden */
  22913. _preActivate(): void;
  22914. /** @hidden */
  22915. _preActivateForIntermediateRendering(renderId: number): void;
  22916. /** @hidden */
  22917. _activate(renderId: number): void;
  22918. /**
  22919. * Gets the current world matrix
  22920. * @returns a Matrix
  22921. */
  22922. getWorldMatrix(): Matrix;
  22923. /** @hidden */
  22924. _getWorldMatrixDeterminant(): number;
  22925. /**
  22926. * Perform relative position change from the point of view of behind the front of the mesh.
  22927. * This is performed taking into account the meshes current rotation, so you do not have to care.
  22928. * Supports definition of mesh facing forward or backward
  22929. * @param amountRight defines the distance on the right axis
  22930. * @param amountUp defines the distance on the up axis
  22931. * @param amountForward defines the distance on the forward axis
  22932. * @returns the current mesh
  22933. */
  22934. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  22935. /**
  22936. * Calculate relative position change from the point of view of behind the front of the mesh.
  22937. * This is performed taking into account the meshes current rotation, so you do not have to care.
  22938. * Supports definition of mesh facing forward or backward
  22939. * @param amountRight defines the distance on the right axis
  22940. * @param amountUp defines the distance on the up axis
  22941. * @param amountForward defines the distance on the forward axis
  22942. * @returns the new displacement vector
  22943. */
  22944. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  22945. /**
  22946. * Perform relative rotation change from the point of view of behind the front of the mesh.
  22947. * Supports definition of mesh facing forward or backward
  22948. * @param flipBack defines the flip
  22949. * @param twirlClockwise defines the twirl
  22950. * @param tiltRight defines the tilt
  22951. * @returns the current mesh
  22952. */
  22953. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  22954. /**
  22955. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  22956. * Supports definition of mesh facing forward or backward.
  22957. * @param flipBack defines the flip
  22958. * @param twirlClockwise defines the twirl
  22959. * @param tiltRight defines the tilt
  22960. * @returns the new rotation vector
  22961. */
  22962. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  22963. /**
  22964. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  22965. * @param includeDescendants Include bounding info from descendants as well (true by default)
  22966. * @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
  22967. * @returns the new bounding vectors
  22968. */
  22969. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  22970. min: Vector3;
  22971. max: Vector3;
  22972. };
  22973. /**
  22974. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  22975. * This means the mesh underlying bounding box and sphere are recomputed.
  22976. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  22977. * @returns the current mesh
  22978. */
  22979. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  22980. /** @hidden */
  22981. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  22982. /** @hidden */
  22983. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  22984. /** @hidden */
  22985. _updateBoundingInfo(): AbstractMesh;
  22986. /** @hidden */
  22987. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  22988. /** @hidden */
  22989. protected _afterComputeWorldMatrix(): void;
  22990. /**
  22991. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  22992. * A mesh is in the frustum if its bounding box intersects the frustum
  22993. * @param frustumPlanes defines the frustum to test
  22994. * @returns true if the mesh is in the frustum planes
  22995. */
  22996. isInFrustum(frustumPlanes: Plane[]): boolean;
  22997. /**
  22998. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  22999. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  23000. * @param frustumPlanes defines the frustum to test
  23001. * @returns true if the mesh is completely in the frustum planes
  23002. */
  23003. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23004. /**
  23005. * True if the mesh intersects another mesh or a SolidParticle object
  23006. * @param mesh defines a target mesh or SolidParticle to test
  23007. * @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)
  23008. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  23009. * @returns true if there is an intersection
  23010. */
  23011. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  23012. /**
  23013. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  23014. * @param point defines the point to test
  23015. * @returns true if there is an intersection
  23016. */
  23017. intersectsPoint(point: Vector3): boolean;
  23018. /**
  23019. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  23020. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23021. */
  23022. checkCollisions: boolean;
  23023. /**
  23024. * Gets Collider object used to compute collisions (not physics)
  23025. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23026. */
  23027. readonly collider: Collider;
  23028. /**
  23029. * Move the mesh using collision engine
  23030. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23031. * @param displacement defines the requested displacement vector
  23032. * @returns the current mesh
  23033. */
  23034. moveWithCollisions(displacement: Vector3): AbstractMesh;
  23035. private _onCollisionPositionChange;
  23036. /** @hidden */
  23037. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  23038. /** @hidden */
  23039. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  23040. /** @hidden */
  23041. _checkCollision(collider: Collider): AbstractMesh;
  23042. /** @hidden */
  23043. _generatePointsArray(): boolean;
  23044. /**
  23045. * Checks if the passed Ray intersects with the mesh
  23046. * @param ray defines the ray to use
  23047. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  23048. * @returns the picking info
  23049. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  23050. */
  23051. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  23052. /**
  23053. * Clones the current mesh
  23054. * @param name defines the mesh name
  23055. * @param newParent defines the new mesh parent
  23056. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  23057. * @returns the new mesh
  23058. */
  23059. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  23060. /**
  23061. * Disposes all the submeshes of the current meshnp
  23062. * @returns the current mesh
  23063. */
  23064. releaseSubMeshes(): AbstractMesh;
  23065. /**
  23066. * Releases resources associated with this abstract mesh.
  23067. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23068. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23069. */
  23070. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23071. /**
  23072. * Adds the passed mesh as a child to the current mesh
  23073. * @param mesh defines the child mesh
  23074. * @returns the current mesh
  23075. */
  23076. addChild(mesh: AbstractMesh): AbstractMesh;
  23077. /**
  23078. * Removes the passed mesh from the current mesh children list
  23079. * @param mesh defines the child mesh
  23080. * @returns the current mesh
  23081. */
  23082. removeChild(mesh: AbstractMesh): AbstractMesh;
  23083. /** @hidden */
  23084. private _initFacetData;
  23085. /**
  23086. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  23087. * This method can be called within the render loop.
  23088. * 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
  23089. * @returns the current mesh
  23090. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23091. */
  23092. updateFacetData(): AbstractMesh;
  23093. /**
  23094. * Returns the facetLocalNormals array.
  23095. * The normals are expressed in the mesh local spac
  23096. * @returns an array of Vector3
  23097. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23098. */
  23099. getFacetLocalNormals(): Vector3[];
  23100. /**
  23101. * Returns the facetLocalPositions array.
  23102. * The facet positions are expressed in the mesh local space
  23103. * @returns an array of Vector3
  23104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23105. */
  23106. getFacetLocalPositions(): Vector3[];
  23107. /**
  23108. * Returns the facetLocalPartioning array
  23109. * @returns an array of array of numbers
  23110. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23111. */
  23112. getFacetLocalPartitioning(): number[][];
  23113. /**
  23114. * Returns the i-th facet position in the world system.
  23115. * This method allocates a new Vector3 per call
  23116. * @param i defines the facet index
  23117. * @returns a new Vector3
  23118. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23119. */
  23120. getFacetPosition(i: number): Vector3;
  23121. /**
  23122. * Sets the reference Vector3 with the i-th facet position in the world system
  23123. * @param i defines the facet index
  23124. * @param ref defines the target vector
  23125. * @returns the current mesh
  23126. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23127. */
  23128. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  23129. /**
  23130. * Returns the i-th facet normal in the world system.
  23131. * This method allocates a new Vector3 per call
  23132. * @param i defines the facet index
  23133. * @returns a new Vector3
  23134. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23135. */
  23136. getFacetNormal(i: number): Vector3;
  23137. /**
  23138. * Sets the reference Vector3 with the i-th facet normal in the world system
  23139. * @param i defines the facet index
  23140. * @param ref defines the target vector
  23141. * @returns the current mesh
  23142. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23143. */
  23144. getFacetNormalToRef(i: number, ref: Vector3): this;
  23145. /**
  23146. * 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)
  23147. * @param x defines x coordinate
  23148. * @param y defines y coordinate
  23149. * @param z defines z coordinate
  23150. * @returns the array of facet indexes
  23151. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23152. */
  23153. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  23154. /**
  23155. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  23156. * @param projected sets as the (x,y,z) world projection on the facet
  23157. * @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
  23158. * @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
  23159. * @param x defines x coordinate
  23160. * @param y defines y coordinate
  23161. * @param z defines z coordinate
  23162. * @returns the face index if found (or null instead)
  23163. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23164. */
  23165. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23166. /**
  23167. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  23168. * @param projected sets as the (x,y,z) local projection on the facet
  23169. * @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
  23170. * @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
  23171. * @param x defines x coordinate
  23172. * @param y defines y coordinate
  23173. * @param z defines z coordinate
  23174. * @returns the face index if found (or null instead)
  23175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23176. */
  23177. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23178. /**
  23179. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  23180. * @returns the parameters
  23181. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23182. */
  23183. getFacetDataParameters(): any;
  23184. /**
  23185. * Disables the feature FacetData and frees the related memory
  23186. * @returns the current mesh
  23187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23188. */
  23189. disableFacetData(): AbstractMesh;
  23190. /**
  23191. * Updates the AbstractMesh indices array
  23192. * @param indices defines the data source
  23193. * @returns the current mesh
  23194. */
  23195. updateIndices(indices: IndicesArray): AbstractMesh;
  23196. /**
  23197. * Creates new normals data for the mesh
  23198. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  23199. * @returns the current mesh
  23200. */
  23201. createNormals(updatable: boolean): AbstractMesh;
  23202. /**
  23203. * Align the mesh with a normal
  23204. * @param normal defines the normal to use
  23205. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  23206. * @returns the current mesh
  23207. */
  23208. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  23209. /** @hidden */
  23210. _checkOcclusionQuery(): boolean;
  23211. }
  23212. }
  23213. declare module BABYLON {
  23214. /**
  23215. * Class used to handle skinning animations
  23216. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23217. */
  23218. export class Skeleton implements IAnimatable {
  23219. /** defines the skeleton name */
  23220. name: string;
  23221. /** defines the skeleton Id */
  23222. id: string;
  23223. /**
  23224. * Defines the list of child bones
  23225. */
  23226. bones: Bone[];
  23227. /**
  23228. * Defines an estimate of the dimension of the skeleton at rest
  23229. */
  23230. dimensionsAtRest: Vector3;
  23231. /**
  23232. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  23233. */
  23234. needInitialSkinMatrix: boolean;
  23235. /**
  23236. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  23237. */
  23238. overrideMesh: Nullable<AbstractMesh>;
  23239. /**
  23240. * Gets the list of animations attached to this skeleton
  23241. */
  23242. animations: Array<Animation>;
  23243. private _scene;
  23244. private _isDirty;
  23245. private _transformMatrices;
  23246. private _transformMatrixTexture;
  23247. private _meshesWithPoseMatrix;
  23248. private _animatables;
  23249. private _identity;
  23250. private _synchronizedWithMesh;
  23251. private _ranges;
  23252. private _lastAbsoluteTransformsUpdateId;
  23253. private _canUseTextureForBones;
  23254. /** @hidden */
  23255. _numBonesWithLinkedTransformNode: number;
  23256. /**
  23257. * Specifies if the skeleton should be serialized
  23258. */
  23259. doNotSerialize: boolean;
  23260. /**
  23261. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  23262. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  23263. */
  23264. useTextureToStoreBoneMatrices: boolean;
  23265. private _animationPropertiesOverride;
  23266. /**
  23267. * Gets or sets the animation properties override
  23268. */
  23269. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23270. /**
  23271. * An observable triggered before computing the skeleton's matrices
  23272. */
  23273. onBeforeComputeObservable: Observable<Skeleton>;
  23274. /**
  23275. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  23276. */
  23277. readonly isUsingTextureForMatrices: boolean;
  23278. /**
  23279. * Creates a new skeleton
  23280. * @param name defines the skeleton name
  23281. * @param id defines the skeleton Id
  23282. * @param scene defines the hosting scene
  23283. */
  23284. constructor(
  23285. /** defines the skeleton name */
  23286. name: string,
  23287. /** defines the skeleton Id */
  23288. id: string, scene: Scene);
  23289. /**
  23290. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  23291. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  23292. * @returns a Float32Array containing matrices data
  23293. */
  23294. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  23295. /**
  23296. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  23297. * @returns a raw texture containing the data
  23298. */
  23299. getTransformMatrixTexture(): Nullable<RawTexture>;
  23300. /**
  23301. * Gets the current hosting scene
  23302. * @returns a scene object
  23303. */
  23304. getScene(): Scene;
  23305. /**
  23306. * Gets a string representing the current skeleton data
  23307. * @param fullDetails defines a boolean indicating if we want a verbose version
  23308. * @returns a string representing the current skeleton data
  23309. */
  23310. toString(fullDetails?: boolean): string;
  23311. /**
  23312. * Get bone's index searching by name
  23313. * @param name defines bone's name to search for
  23314. * @return the indice of the bone. Returns -1 if not found
  23315. */
  23316. getBoneIndexByName(name: string): number;
  23317. /**
  23318. * Creater a new animation range
  23319. * @param name defines the name of the range
  23320. * @param from defines the start key
  23321. * @param to defines the end key
  23322. */
  23323. createAnimationRange(name: string, from: number, to: number): void;
  23324. /**
  23325. * Delete a specific animation range
  23326. * @param name defines the name of the range
  23327. * @param deleteFrames defines if frames must be removed as well
  23328. */
  23329. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  23330. /**
  23331. * Gets a specific animation range
  23332. * @param name defines the name of the range to look for
  23333. * @returns the requested animation range or null if not found
  23334. */
  23335. getAnimationRange(name: string): Nullable<AnimationRange>;
  23336. /**
  23337. * Gets the list of all animation ranges defined on this skeleton
  23338. * @returns an array
  23339. */
  23340. getAnimationRanges(): Nullable<AnimationRange>[];
  23341. /**
  23342. * Copy animation range from a source skeleton.
  23343. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  23344. * @param source defines the source skeleton
  23345. * @param name defines the name of the range to copy
  23346. * @param rescaleAsRequired defines if rescaling must be applied if required
  23347. * @returns true if operation was successful
  23348. */
  23349. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  23350. /**
  23351. * Forces the skeleton to go to rest pose
  23352. */
  23353. returnToRest(): void;
  23354. private _getHighestAnimationFrame;
  23355. /**
  23356. * Begin a specific animation range
  23357. * @param name defines the name of the range to start
  23358. * @param loop defines if looping must be turned on (false by default)
  23359. * @param speedRatio defines the speed ratio to apply (1 by default)
  23360. * @param onAnimationEnd defines a callback which will be called when animation will end
  23361. * @returns a new animatable
  23362. */
  23363. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  23364. /** @hidden */
  23365. _markAsDirty(): void;
  23366. /** @hidden */
  23367. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  23368. /** @hidden */
  23369. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  23370. private _computeTransformMatrices;
  23371. /**
  23372. * Build all resources required to render a skeleton
  23373. */
  23374. prepare(): void;
  23375. /**
  23376. * Gets the list of animatables currently running for this skeleton
  23377. * @returns an array of animatables
  23378. */
  23379. getAnimatables(): IAnimatable[];
  23380. /**
  23381. * Clone the current skeleton
  23382. * @param name defines the name of the new skeleton
  23383. * @param id defines the id of the enw skeleton
  23384. * @returns the new skeleton
  23385. */
  23386. clone(name: string, id: string): Skeleton;
  23387. /**
  23388. * Enable animation blending for this skeleton
  23389. * @param blendingSpeed defines the blending speed to apply
  23390. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23391. */
  23392. enableBlending(blendingSpeed?: number): void;
  23393. /**
  23394. * Releases all resources associated with the current skeleton
  23395. */
  23396. dispose(): void;
  23397. /**
  23398. * Serialize the skeleton in a JSON object
  23399. * @returns a JSON object
  23400. */
  23401. serialize(): any;
  23402. /**
  23403. * Creates a new skeleton from serialized data
  23404. * @param parsedSkeleton defines the serialized data
  23405. * @param scene defines the hosting scene
  23406. * @returns a new skeleton
  23407. */
  23408. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  23409. /**
  23410. * Compute all node absolute transforms
  23411. * @param forceUpdate defines if computation must be done even if cache is up to date
  23412. */
  23413. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  23414. /**
  23415. * Gets the root pose matrix
  23416. * @returns a matrix
  23417. */
  23418. getPoseMatrix(): Nullable<Matrix>;
  23419. /**
  23420. * Sorts bones per internal index
  23421. */
  23422. sortBones(): void;
  23423. private _sortBones;
  23424. }
  23425. }
  23426. declare module BABYLON {
  23427. /**
  23428. * Class used to store bone information
  23429. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23430. */
  23431. export class Bone extends Node {
  23432. /**
  23433. * defines the bone name
  23434. */
  23435. name: string;
  23436. private static _tmpVecs;
  23437. private static _tmpQuat;
  23438. private static _tmpMats;
  23439. /**
  23440. * Gets the list of child bones
  23441. */
  23442. children: Bone[];
  23443. /** Gets the animations associated with this bone */
  23444. animations: Animation[];
  23445. /**
  23446. * Gets or sets bone length
  23447. */
  23448. length: number;
  23449. /**
  23450. * @hidden Internal only
  23451. * Set this value to map this bone to a different index in the transform matrices
  23452. * Set this value to -1 to exclude the bone from the transform matrices
  23453. */
  23454. _index: Nullable<number>;
  23455. private _skeleton;
  23456. private _localMatrix;
  23457. private _restPose;
  23458. private _baseMatrix;
  23459. private _absoluteTransform;
  23460. private _invertedAbsoluteTransform;
  23461. private _parent;
  23462. private _scalingDeterminant;
  23463. private _worldTransform;
  23464. private _localScaling;
  23465. private _localRotation;
  23466. private _localPosition;
  23467. private _needToDecompose;
  23468. private _needToCompose;
  23469. /** @hidden */
  23470. _linkedTransformNode: Nullable<TransformNode>;
  23471. /** @hidden */
  23472. /** @hidden */
  23473. _matrix: Matrix;
  23474. /**
  23475. * Create a new bone
  23476. * @param name defines the bone name
  23477. * @param skeleton defines the parent skeleton
  23478. * @param parentBone defines the parent (can be null if the bone is the root)
  23479. * @param localMatrix defines the local matrix
  23480. * @param restPose defines the rest pose matrix
  23481. * @param baseMatrix defines the base matrix
  23482. * @param index defines index of the bone in the hiearchy
  23483. */
  23484. constructor(
  23485. /**
  23486. * defines the bone name
  23487. */
  23488. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  23489. /**
  23490. * Gets the parent skeleton
  23491. * @returns a skeleton
  23492. */
  23493. getSkeleton(): Skeleton;
  23494. /**
  23495. * Gets parent bone
  23496. * @returns a bone or null if the bone is the root of the bone hierarchy
  23497. */
  23498. getParent(): Nullable<Bone>;
  23499. /**
  23500. * Sets the parent bone
  23501. * @param parent defines the parent (can be null if the bone is the root)
  23502. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  23503. */
  23504. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  23505. /**
  23506. * Gets the local matrix
  23507. * @returns a matrix
  23508. */
  23509. getLocalMatrix(): Matrix;
  23510. /**
  23511. * Gets the base matrix (initial matrix which remains unchanged)
  23512. * @returns a matrix
  23513. */
  23514. getBaseMatrix(): Matrix;
  23515. /**
  23516. * Gets the rest pose matrix
  23517. * @returns a matrix
  23518. */
  23519. getRestPose(): Matrix;
  23520. /**
  23521. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  23522. */
  23523. getWorldMatrix(): Matrix;
  23524. /**
  23525. * Sets the local matrix to rest pose matrix
  23526. */
  23527. returnToRest(): void;
  23528. /**
  23529. * Gets the inverse of the absolute transform matrix.
  23530. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  23531. * @returns a matrix
  23532. */
  23533. getInvertedAbsoluteTransform(): Matrix;
  23534. /**
  23535. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  23536. * @returns a matrix
  23537. */
  23538. getAbsoluteTransform(): Matrix;
  23539. /**
  23540. * Links with the given transform node.
  23541. * The local matrix of this bone is copied from the transform node every frame.
  23542. * @param transformNode defines the transform node to link to
  23543. */
  23544. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  23545. /** Gets or sets current position (in local space) */
  23546. position: Vector3;
  23547. /** Gets or sets current rotation (in local space) */
  23548. rotation: Vector3;
  23549. /** Gets or sets current rotation quaternion (in local space) */
  23550. rotationQuaternion: Quaternion;
  23551. /** Gets or sets current scaling (in local space) */
  23552. scaling: Vector3;
  23553. /**
  23554. * Gets the animation properties override
  23555. */
  23556. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23557. private _decompose;
  23558. private _compose;
  23559. /**
  23560. * Update the base and local matrices
  23561. * @param matrix defines the new base or local matrix
  23562. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  23563. * @param updateLocalMatrix defines if the local matrix should be updated
  23564. */
  23565. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  23566. /** @hidden */
  23567. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  23568. /**
  23569. * Flag the bone as dirty (Forcing it to update everything)
  23570. */
  23571. markAsDirty(): void;
  23572. private _markAsDirtyAndCompose;
  23573. private _markAsDirtyAndDecompose;
  23574. /**
  23575. * Translate the bone in local or world space
  23576. * @param vec The amount to translate the bone
  23577. * @param space The space that the translation is in
  23578. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23579. */
  23580. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  23581. /**
  23582. * Set the postion of the bone in local or world space
  23583. * @param position The position to set the bone
  23584. * @param space The space that the position is in
  23585. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23586. */
  23587. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  23588. /**
  23589. * Set the absolute position of the bone (world space)
  23590. * @param position The position to set the bone
  23591. * @param mesh The mesh that this bone is attached to
  23592. */
  23593. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  23594. /**
  23595. * Scale the bone on the x, y and z axes (in local space)
  23596. * @param x The amount to scale the bone on the x axis
  23597. * @param y The amount to scale the bone on the y axis
  23598. * @param z The amount to scale the bone on the z axis
  23599. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  23600. */
  23601. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  23602. /**
  23603. * Set the bone scaling in local space
  23604. * @param scale defines the scaling vector
  23605. */
  23606. setScale(scale: Vector3): void;
  23607. /**
  23608. * Gets the current scaling in local space
  23609. * @returns the current scaling vector
  23610. */
  23611. getScale(): Vector3;
  23612. /**
  23613. * Gets the current scaling in local space and stores it in a target vector
  23614. * @param result defines the target vector
  23615. */
  23616. getScaleToRef(result: Vector3): void;
  23617. /**
  23618. * Set the yaw, pitch, and roll of the bone in local or world space
  23619. * @param yaw The rotation of the bone on the y axis
  23620. * @param pitch The rotation of the bone on the x axis
  23621. * @param roll The rotation of the bone on the z axis
  23622. * @param space The space that the axes of rotation are in
  23623. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23624. */
  23625. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  23626. /**
  23627. * Add a rotation to the bone on an axis in local or world space
  23628. * @param axis The axis to rotate the bone on
  23629. * @param amount The amount to rotate the bone
  23630. * @param space The space that the axis is in
  23631. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23632. */
  23633. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  23634. /**
  23635. * Set the rotation of the bone to a particular axis angle in local or world space
  23636. * @param axis The axis to rotate the bone on
  23637. * @param angle The angle that the bone should be rotated to
  23638. * @param space The space that the axis is in
  23639. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23640. */
  23641. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  23642. /**
  23643. * Set the euler rotation of the bone in local of world space
  23644. * @param rotation The euler rotation that the bone should be set to
  23645. * @param space The space that the rotation is in
  23646. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23647. */
  23648. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  23649. /**
  23650. * Set the quaternion rotation of the bone in local of world space
  23651. * @param quat The quaternion rotation that the bone should be set to
  23652. * @param space The space that the rotation is in
  23653. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23654. */
  23655. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  23656. /**
  23657. * Set the rotation matrix of the bone in local of world space
  23658. * @param rotMat The rotation matrix that the bone should be set to
  23659. * @param space The space that the rotation is in
  23660. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23661. */
  23662. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  23663. private _rotateWithMatrix;
  23664. private _getNegativeRotationToRef;
  23665. /**
  23666. * Get the position of the bone in local or world space
  23667. * @param space The space that the returned position is in
  23668. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23669. * @returns The position of the bone
  23670. */
  23671. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  23672. /**
  23673. * Copy the position of the bone to a vector3 in local or world space
  23674. * @param space The space that the returned position is in
  23675. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23676. * @param result The vector3 to copy the position to
  23677. */
  23678. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  23679. /**
  23680. * Get the absolute position of the bone (world space)
  23681. * @param mesh The mesh that this bone is attached to
  23682. * @returns The absolute position of the bone
  23683. */
  23684. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  23685. /**
  23686. * Copy the absolute position of the bone (world space) to the result param
  23687. * @param mesh The mesh that this bone is attached to
  23688. * @param result The vector3 to copy the absolute position to
  23689. */
  23690. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  23691. /**
  23692. * Compute the absolute transforms of this bone and its children
  23693. */
  23694. computeAbsoluteTransforms(): void;
  23695. /**
  23696. * Get the world direction from an axis that is in the local space of the bone
  23697. * @param localAxis The local direction that is used to compute the world direction
  23698. * @param mesh The mesh that this bone is attached to
  23699. * @returns The world direction
  23700. */
  23701. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  23702. /**
  23703. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  23704. * @param localAxis The local direction that is used to compute the world direction
  23705. * @param mesh The mesh that this bone is attached to
  23706. * @param result The vector3 that the world direction will be copied to
  23707. */
  23708. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23709. /**
  23710. * Get the euler rotation of the bone in local or world space
  23711. * @param space The space that the rotation should be in
  23712. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23713. * @returns The euler rotation
  23714. */
  23715. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  23716. /**
  23717. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  23718. * @param space The space that the rotation should be in
  23719. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23720. * @param result The vector3 that the rotation should be copied to
  23721. */
  23722. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23723. /**
  23724. * Get the quaternion rotation of the bone in either local or world space
  23725. * @param space The space that the rotation should be in
  23726. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23727. * @returns The quaternion rotation
  23728. */
  23729. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  23730. /**
  23731. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  23732. * @param space The space that the rotation should be in
  23733. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23734. * @param result The quaternion that the rotation should be copied to
  23735. */
  23736. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  23737. /**
  23738. * Get the rotation matrix of the bone in local or world space
  23739. * @param space The space that the rotation should be in
  23740. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23741. * @returns The rotation matrix
  23742. */
  23743. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  23744. /**
  23745. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  23746. * @param space The space that the rotation should be in
  23747. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23748. * @param result The quaternion that the rotation should be copied to
  23749. */
  23750. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  23751. /**
  23752. * Get the world position of a point that is in the local space of the bone
  23753. * @param position The local position
  23754. * @param mesh The mesh that this bone is attached to
  23755. * @returns The world position
  23756. */
  23757. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  23758. /**
  23759. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  23760. * @param position The local position
  23761. * @param mesh The mesh that this bone is attached to
  23762. * @param result The vector3 that the world position should be copied to
  23763. */
  23764. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23765. /**
  23766. * Get the local position of a point that is in world space
  23767. * @param position The world position
  23768. * @param mesh The mesh that this bone is attached to
  23769. * @returns The local position
  23770. */
  23771. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  23772. /**
  23773. * Get the local position of a point that is in world space and copy it to the result param
  23774. * @param position The world position
  23775. * @param mesh The mesh that this bone is attached to
  23776. * @param result The vector3 that the local position should be copied to
  23777. */
  23778. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23779. }
  23780. }
  23781. declare module BABYLON {
  23782. /**
  23783. * Class used to store an actual running animation
  23784. */
  23785. export class Animatable {
  23786. /** defines the target object */
  23787. target: any;
  23788. /** defines the starting frame number (default is 0) */
  23789. fromFrame: number;
  23790. /** defines the ending frame number (default is 100) */
  23791. toFrame: number;
  23792. /** defines if the animation must loop (default is false) */
  23793. loopAnimation: boolean;
  23794. /** defines a callback to call when animation ends if it is not looping */
  23795. onAnimationEnd?: (() => void) | null | undefined;
  23796. /** defines a callback to call when animation loops */
  23797. onAnimationLoop?: (() => void) | null | undefined;
  23798. private _localDelayOffset;
  23799. private _pausedDelay;
  23800. private _runtimeAnimations;
  23801. private _paused;
  23802. private _scene;
  23803. private _speedRatio;
  23804. private _weight;
  23805. private _syncRoot;
  23806. /**
  23807. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  23808. * This will only apply for non looping animation (default is true)
  23809. */
  23810. disposeOnEnd: boolean;
  23811. /**
  23812. * Gets a boolean indicating if the animation has started
  23813. */
  23814. animationStarted: boolean;
  23815. /**
  23816. * Observer raised when the animation ends
  23817. */
  23818. onAnimationEndObservable: Observable<Animatable>;
  23819. /**
  23820. * Observer raised when the animation loops
  23821. */
  23822. onAnimationLoopObservable: Observable<Animatable>;
  23823. /**
  23824. * Gets the root Animatable used to synchronize and normalize animations
  23825. */
  23826. readonly syncRoot: Animatable;
  23827. /**
  23828. * Gets the current frame of the first RuntimeAnimation
  23829. * Used to synchronize Animatables
  23830. */
  23831. readonly masterFrame: number;
  23832. /**
  23833. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  23834. */
  23835. weight: number;
  23836. /**
  23837. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  23838. */
  23839. speedRatio: number;
  23840. /**
  23841. * Creates a new Animatable
  23842. * @param scene defines the hosting scene
  23843. * @param target defines the target object
  23844. * @param fromFrame defines the starting frame number (default is 0)
  23845. * @param toFrame defines the ending frame number (default is 100)
  23846. * @param loopAnimation defines if the animation must loop (default is false)
  23847. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  23848. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  23849. * @param animations defines a group of animation to add to the new Animatable
  23850. * @param onAnimationLoop defines a callback to call when animation loops
  23851. */
  23852. constructor(scene: Scene,
  23853. /** defines the target object */
  23854. target: any,
  23855. /** defines the starting frame number (default is 0) */
  23856. fromFrame?: number,
  23857. /** defines the ending frame number (default is 100) */
  23858. toFrame?: number,
  23859. /** defines if the animation must loop (default is false) */
  23860. loopAnimation?: boolean, speedRatio?: number,
  23861. /** defines a callback to call when animation ends if it is not looping */
  23862. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  23863. /** defines a callback to call when animation loops */
  23864. onAnimationLoop?: (() => void) | null | undefined);
  23865. /**
  23866. * Synchronize and normalize current Animatable with a source Animatable
  23867. * This is useful when using animation weights and when animations are not of the same length
  23868. * @param root defines the root Animatable to synchronize with
  23869. * @returns the current Animatable
  23870. */
  23871. syncWith(root: Animatable): Animatable;
  23872. /**
  23873. * Gets the list of runtime animations
  23874. * @returns an array of RuntimeAnimation
  23875. */
  23876. getAnimations(): RuntimeAnimation[];
  23877. /**
  23878. * Adds more animations to the current animatable
  23879. * @param target defines the target of the animations
  23880. * @param animations defines the new animations to add
  23881. */
  23882. appendAnimations(target: any, animations: Animation[]): void;
  23883. /**
  23884. * Gets the source animation for a specific property
  23885. * @param property defines the propertyu to look for
  23886. * @returns null or the source animation for the given property
  23887. */
  23888. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  23889. /**
  23890. * Gets the runtime animation for a specific property
  23891. * @param property defines the propertyu to look for
  23892. * @returns null or the runtime animation for the given property
  23893. */
  23894. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  23895. /**
  23896. * Resets the animatable to its original state
  23897. */
  23898. reset(): void;
  23899. /**
  23900. * Allows the animatable to blend with current running animations
  23901. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23902. * @param blendingSpeed defines the blending speed to use
  23903. */
  23904. enableBlending(blendingSpeed: number): void;
  23905. /**
  23906. * Disable animation blending
  23907. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23908. */
  23909. disableBlending(): void;
  23910. /**
  23911. * Jump directly to a given frame
  23912. * @param frame defines the frame to jump to
  23913. */
  23914. goToFrame(frame: number): void;
  23915. /**
  23916. * Pause the animation
  23917. */
  23918. pause(): void;
  23919. /**
  23920. * Restart the animation
  23921. */
  23922. restart(): void;
  23923. private _raiseOnAnimationEnd;
  23924. /**
  23925. * Stop and delete the current animation
  23926. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  23927. * @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)
  23928. */
  23929. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  23930. /**
  23931. * Wait asynchronously for the animation to end
  23932. * @returns a promise which will be fullfilled when the animation ends
  23933. */
  23934. waitAsync(): Promise<Animatable>;
  23935. /** @hidden */
  23936. _animate(delay: number): boolean;
  23937. }
  23938. interface Scene {
  23939. /** @hidden */
  23940. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  23941. /** @hidden */
  23942. _processLateAnimationBindingsForMatrices(holder: {
  23943. totalWeight: number;
  23944. animations: RuntimeAnimation[];
  23945. originalValue: Matrix;
  23946. }): any;
  23947. /** @hidden */
  23948. _processLateAnimationBindingsForQuaternions(holder: {
  23949. totalWeight: number;
  23950. animations: RuntimeAnimation[];
  23951. originalValue: Quaternion;
  23952. }, refQuaternion: Quaternion): Quaternion;
  23953. /** @hidden */
  23954. _processLateAnimationBindings(): void;
  23955. /**
  23956. * Will start the animation sequence of a given target
  23957. * @param target defines the target
  23958. * @param from defines from which frame should animation start
  23959. * @param to defines until which frame should animation run.
  23960. * @param weight defines the weight to apply to the animation (1.0 by default)
  23961. * @param loop defines if the animation loops
  23962. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  23963. * @param onAnimationEnd defines the function to be executed when the animation ends
  23964. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  23965. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  23966. * @param onAnimationLoop defines the callback to call when an animation loops
  23967. * @returns the animatable object created for this animation
  23968. */
  23969. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  23970. /**
  23971. * Will start the animation sequence of a given target
  23972. * @param target defines the target
  23973. * @param from defines from which frame should animation start
  23974. * @param to defines until which frame should animation run.
  23975. * @param loop defines if the animation loops
  23976. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  23977. * @param onAnimationEnd defines the function to be executed when the animation ends
  23978. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  23979. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  23980. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  23981. * @param onAnimationLoop defines the callback to call when an animation loops
  23982. * @returns the animatable object created for this animation
  23983. */
  23984. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  23985. /**
  23986. * Will start the animation sequence of a given target and its hierarchy
  23987. * @param target defines the target
  23988. * @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.
  23989. * @param from defines from which frame should animation start
  23990. * @param to defines until which frame should animation run.
  23991. * @param loop defines if the animation loops
  23992. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  23993. * @param onAnimationEnd defines the function to be executed when the animation ends
  23994. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  23995. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  23996. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  23997. * @param onAnimationLoop defines the callback to call when an animation loops
  23998. * @returns the list of created animatables
  23999. */
  24000. 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[];
  24001. /**
  24002. * Begin a new animation on a given node
  24003. * @param target defines the target where the animation will take place
  24004. * @param animations defines the list of animations to start
  24005. * @param from defines the initial value
  24006. * @param to defines the final value
  24007. * @param loop defines if you want animation to loop (off by default)
  24008. * @param speedRatio defines the speed ratio to apply to all animations
  24009. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24010. * @param onAnimationLoop defines the callback to call when an animation loops
  24011. * @returns the list of created animatables
  24012. */
  24013. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  24014. /**
  24015. * Begin a new animation on a given node and its hierarchy
  24016. * @param target defines the root node where the animation will take place
  24017. * @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.
  24018. * @param animations defines the list of animations to start
  24019. * @param from defines the initial value
  24020. * @param to defines the final value
  24021. * @param loop defines if you want animation to loop (off by default)
  24022. * @param speedRatio defines the speed ratio to apply to all animations
  24023. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24024. * @param onAnimationLoop defines the callback to call when an animation loops
  24025. * @returns the list of animatables created for all nodes
  24026. */
  24027. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  24028. /**
  24029. * Gets the animatable associated with a specific target
  24030. * @param target defines the target of the animatable
  24031. * @returns the required animatable if found
  24032. */
  24033. getAnimatableByTarget(target: any): Nullable<Animatable>;
  24034. /**
  24035. * Gets all animatables associated with a given target
  24036. * @param target defines the target to look animatables for
  24037. * @returns an array of Animatables
  24038. */
  24039. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  24040. /**
  24041. * Will stop the animation of the given target
  24042. * @param target - the target
  24043. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  24044. * @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)
  24045. */
  24046. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  24047. /**
  24048. * Stops and removes all animations that have been applied to the scene
  24049. */
  24050. stopAllAnimations(): void;
  24051. }
  24052. interface Bone {
  24053. /**
  24054. * Copy an animation range from another bone
  24055. * @param source defines the source bone
  24056. * @param rangeName defines the range name to copy
  24057. * @param frameOffset defines the frame offset
  24058. * @param rescaleAsRequired defines if rescaling must be applied if required
  24059. * @param skelDimensionsRatio defines the scaling ratio
  24060. * @returns true if operation was successful
  24061. */
  24062. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  24063. }
  24064. }
  24065. declare module BABYLON {
  24066. /**
  24067. * Defines how a node can be built from a string name.
  24068. */
  24069. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24070. /**
  24071. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24072. */
  24073. export class Node implements IBehaviorAware<Node> {
  24074. /** @hidden */
  24075. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24076. private static _NodeConstructors;
  24077. /**
  24078. * Add a new node constructor
  24079. * @param type defines the type name of the node to construct
  24080. * @param constructorFunc defines the constructor function
  24081. */
  24082. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24083. /**
  24084. * Returns a node constructor based on type name
  24085. * @param type defines the type name
  24086. * @param name defines the new node name
  24087. * @param scene defines the hosting scene
  24088. * @param options defines optional options to transmit to constructors
  24089. * @returns the new constructor or null
  24090. */
  24091. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24092. /**
  24093. * Gets or sets the name of the node
  24094. */
  24095. name: string;
  24096. /**
  24097. * Gets or sets the id of the node
  24098. */
  24099. id: string;
  24100. /**
  24101. * Gets or sets the unique id of the node
  24102. */
  24103. uniqueId: number;
  24104. /**
  24105. * Gets or sets a string used to store user defined state for the node
  24106. */
  24107. state: string;
  24108. /**
  24109. * Gets or sets an object used to store user defined information for the node
  24110. */
  24111. metadata: any;
  24112. /**
  24113. * For internal use only. Please do not use.
  24114. */
  24115. reservedDataStore: any;
  24116. /**
  24117. * Gets or sets a boolean used to define if the node must be serialized
  24118. */
  24119. doNotSerialize: boolean;
  24120. /** @hidden */
  24121. _isDisposed: boolean;
  24122. /**
  24123. * Gets a list of Animations associated with the node
  24124. */
  24125. animations: Animation[];
  24126. protected _ranges: {
  24127. [name: string]: Nullable<AnimationRange>;
  24128. };
  24129. /**
  24130. * Callback raised when the node is ready to be used
  24131. */
  24132. onReady: (node: Node) => void;
  24133. private _isEnabled;
  24134. private _isParentEnabled;
  24135. private _isReady;
  24136. /** @hidden */
  24137. _currentRenderId: number;
  24138. private _parentRenderId;
  24139. protected _childRenderId: number;
  24140. /** @hidden */
  24141. _waitingParentId: Nullable<string>;
  24142. /** @hidden */
  24143. _scene: Scene;
  24144. /** @hidden */
  24145. _cache: any;
  24146. private _parentNode;
  24147. private _children;
  24148. /** @hidden */
  24149. _worldMatrix: Matrix;
  24150. /** @hidden */
  24151. _worldMatrixDeterminant: number;
  24152. /** @hidden */
  24153. private _sceneRootNodesIndex;
  24154. /**
  24155. * Gets a boolean indicating if the node has been disposed
  24156. * @returns true if the node was disposed
  24157. */
  24158. isDisposed(): boolean;
  24159. /**
  24160. * Gets or sets the parent of the node
  24161. */
  24162. parent: Nullable<Node>;
  24163. private addToSceneRootNodes;
  24164. private removeFromSceneRootNodes;
  24165. private _animationPropertiesOverride;
  24166. /**
  24167. * Gets or sets the animation properties override
  24168. */
  24169. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24170. /**
  24171. * Gets a string idenfifying the name of the class
  24172. * @returns "Node" string
  24173. */
  24174. getClassName(): string;
  24175. /** @hidden */
  24176. readonly _isNode: boolean;
  24177. /**
  24178. * An event triggered when the mesh is disposed
  24179. */
  24180. onDisposeObservable: Observable<Node>;
  24181. private _onDisposeObserver;
  24182. /**
  24183. * Sets a callback that will be raised when the node will be disposed
  24184. */
  24185. onDispose: () => void;
  24186. /**
  24187. * Creates a new Node
  24188. * @param name the name and id to be given to this node
  24189. * @param scene the scene this node will be added to
  24190. * @param addToRootNodes the node will be added to scene.rootNodes
  24191. */
  24192. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24193. /**
  24194. * Gets the scene of the node
  24195. * @returns a scene
  24196. */
  24197. getScene(): Scene;
  24198. /**
  24199. * Gets the engine of the node
  24200. * @returns a Engine
  24201. */
  24202. getEngine(): Engine;
  24203. private _behaviors;
  24204. /**
  24205. * Attach a behavior to the node
  24206. * @see http://doc.babylonjs.com/features/behaviour
  24207. * @param behavior defines the behavior to attach
  24208. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24209. * @returns the current Node
  24210. */
  24211. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24212. /**
  24213. * Remove an attached behavior
  24214. * @see http://doc.babylonjs.com/features/behaviour
  24215. * @param behavior defines the behavior to attach
  24216. * @returns the current Node
  24217. */
  24218. removeBehavior(behavior: Behavior<Node>): Node;
  24219. /**
  24220. * Gets the list of attached behaviors
  24221. * @see http://doc.babylonjs.com/features/behaviour
  24222. */
  24223. readonly behaviors: Behavior<Node>[];
  24224. /**
  24225. * Gets an attached behavior by name
  24226. * @param name defines the name of the behavior to look for
  24227. * @see http://doc.babylonjs.com/features/behaviour
  24228. * @returns null if behavior was not found else the requested behavior
  24229. */
  24230. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24231. /**
  24232. * Returns the latest update of the World matrix
  24233. * @returns a Matrix
  24234. */
  24235. getWorldMatrix(): Matrix;
  24236. /** @hidden */
  24237. _getWorldMatrixDeterminant(): number;
  24238. /**
  24239. * Returns directly the latest state of the mesh World matrix.
  24240. * A Matrix is returned.
  24241. */
  24242. readonly worldMatrixFromCache: Matrix;
  24243. /** @hidden */
  24244. _initCache(): void;
  24245. /** @hidden */
  24246. updateCache(force?: boolean): void;
  24247. /** @hidden */
  24248. _updateCache(ignoreParentClass?: boolean): void;
  24249. /** @hidden */
  24250. _isSynchronized(): boolean;
  24251. /** @hidden */
  24252. _markSyncedWithParent(): void;
  24253. /** @hidden */
  24254. isSynchronizedWithParent(): boolean;
  24255. /** @hidden */
  24256. isSynchronized(): boolean;
  24257. /**
  24258. * Is this node ready to be used/rendered
  24259. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24260. * @return true if the node is ready
  24261. */
  24262. isReady(completeCheck?: boolean): boolean;
  24263. /**
  24264. * Is this node enabled?
  24265. * 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
  24266. * @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
  24267. * @return whether this node (and its parent) is enabled
  24268. */
  24269. isEnabled(checkAncestors?: boolean): boolean;
  24270. /** @hidden */
  24271. protected _syncParentEnabledState(): void;
  24272. /**
  24273. * Set the enabled state of this node
  24274. * @param value defines the new enabled state
  24275. */
  24276. setEnabled(value: boolean): void;
  24277. /**
  24278. * Is this node a descendant of the given node?
  24279. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24280. * @param ancestor defines the parent node to inspect
  24281. * @returns a boolean indicating if this node is a descendant of the given node
  24282. */
  24283. isDescendantOf(ancestor: Node): boolean;
  24284. /** @hidden */
  24285. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24286. /**
  24287. * Will return all nodes that have this node as ascendant
  24288. * @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
  24289. * @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
  24290. * @return all children nodes of all types
  24291. */
  24292. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24293. /**
  24294. * Get all child-meshes of this node
  24295. * @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
  24296. * @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
  24297. * @returns an array of AbstractMesh
  24298. */
  24299. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24300. /**
  24301. * Get all direct children of this node
  24302. * @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
  24303. * @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)
  24304. * @returns an array of Node
  24305. */
  24306. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24307. /** @hidden */
  24308. _setReady(state: boolean): void;
  24309. /**
  24310. * Get an animation by name
  24311. * @param name defines the name of the animation to look for
  24312. * @returns null if not found else the requested animation
  24313. */
  24314. getAnimationByName(name: string): Nullable<Animation>;
  24315. /**
  24316. * Creates an animation range for this node
  24317. * @param name defines the name of the range
  24318. * @param from defines the starting key
  24319. * @param to defines the end key
  24320. */
  24321. createAnimationRange(name: string, from: number, to: number): void;
  24322. /**
  24323. * Delete a specific animation range
  24324. * @param name defines the name of the range to delete
  24325. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24326. */
  24327. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24328. /**
  24329. * Get an animation range by name
  24330. * @param name defines the name of the animation range to look for
  24331. * @returns null if not found else the requested animation range
  24332. */
  24333. getAnimationRange(name: string): Nullable<AnimationRange>;
  24334. /**
  24335. * Will start the animation sequence
  24336. * @param name defines the range frames for animation sequence
  24337. * @param loop defines if the animation should loop (false by default)
  24338. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24339. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24340. * @returns the object created for this animation. If range does not exist, it will return null
  24341. */
  24342. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24343. /**
  24344. * Serialize animation ranges into a JSON compatible object
  24345. * @returns serialization object
  24346. */
  24347. serializeAnimationRanges(): any;
  24348. /**
  24349. * Computes the world matrix of the node
  24350. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24351. * @returns the world matrix
  24352. */
  24353. computeWorldMatrix(force?: boolean): Matrix;
  24354. /**
  24355. * Releases resources associated with this node.
  24356. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24357. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24358. */
  24359. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24360. /**
  24361. * Parse animation range data from a serialization object and store them into a given node
  24362. * @param node defines where to store the animation ranges
  24363. * @param parsedNode defines the serialization object to read data from
  24364. * @param scene defines the hosting scene
  24365. */
  24366. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24367. }
  24368. }
  24369. declare module BABYLON {
  24370. /**
  24371. * Class used to store any kind of animation
  24372. */
  24373. export class Animation {
  24374. /**Name of the animation */
  24375. name: string;
  24376. /**Property to animate */
  24377. targetProperty: string;
  24378. /**The frames per second of the animation */
  24379. framePerSecond: number;
  24380. /**The data type of the animation */
  24381. dataType: number;
  24382. /**The loop mode of the animation */
  24383. loopMode?: number | undefined;
  24384. /**Specifies if blending should be enabled */
  24385. enableBlending?: boolean | undefined;
  24386. /**
  24387. * Use matrix interpolation instead of using direct key value when animating matrices
  24388. */
  24389. static AllowMatricesInterpolation: boolean;
  24390. /**
  24391. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  24392. */
  24393. static AllowMatrixDecomposeForInterpolation: boolean;
  24394. /**
  24395. * Stores the key frames of the animation
  24396. */
  24397. private _keys;
  24398. /**
  24399. * Stores the easing function of the animation
  24400. */
  24401. private _easingFunction;
  24402. /**
  24403. * @hidden Internal use only
  24404. */
  24405. _runtimeAnimations: RuntimeAnimation[];
  24406. /**
  24407. * The set of event that will be linked to this animation
  24408. */
  24409. private _events;
  24410. /**
  24411. * Stores an array of target property paths
  24412. */
  24413. targetPropertyPath: string[];
  24414. /**
  24415. * Stores the blending speed of the animation
  24416. */
  24417. blendingSpeed: number;
  24418. /**
  24419. * Stores the animation ranges for the animation
  24420. */
  24421. private _ranges;
  24422. /**
  24423. * @hidden Internal use
  24424. */
  24425. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  24426. /**
  24427. * Sets up an animation
  24428. * @param property The property to animate
  24429. * @param animationType The animation type to apply
  24430. * @param framePerSecond The frames per second of the animation
  24431. * @param easingFunction The easing function used in the animation
  24432. * @returns The created animation
  24433. */
  24434. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  24435. /**
  24436. * Create and start an animation on a node
  24437. * @param name defines the name of the global animation that will be run on all nodes
  24438. * @param node defines the root node where the animation will take place
  24439. * @param targetProperty defines property to animate
  24440. * @param framePerSecond defines the number of frame per second yo use
  24441. * @param totalFrame defines the number of frames in total
  24442. * @param from defines the initial value
  24443. * @param to defines the final value
  24444. * @param loopMode defines which loop mode you want to use (off by default)
  24445. * @param easingFunction defines the easing function to use (linear by default)
  24446. * @param onAnimationEnd defines the callback to call when animation end
  24447. * @returns the animatable created for this animation
  24448. */
  24449. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24450. /**
  24451. * Create and start an animation on a node and its descendants
  24452. * @param name defines the name of the global animation that will be run on all nodes
  24453. * @param node defines the root node where the animation will take place
  24454. * @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
  24455. * @param targetProperty defines property to animate
  24456. * @param framePerSecond defines the number of frame per second to use
  24457. * @param totalFrame defines the number of frames in total
  24458. * @param from defines the initial value
  24459. * @param to defines the final value
  24460. * @param loopMode defines which loop mode you want to use (off by default)
  24461. * @param easingFunction defines the easing function to use (linear by default)
  24462. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24463. * @returns the list of animatables created for all nodes
  24464. * @example https://www.babylonjs-playground.com/#MH0VLI
  24465. */
  24466. 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[]>;
  24467. /**
  24468. * Creates a new animation, merges it with the existing animations and starts it
  24469. * @param name Name of the animation
  24470. * @param node Node which contains the scene that begins the animations
  24471. * @param targetProperty Specifies which property to animate
  24472. * @param framePerSecond The frames per second of the animation
  24473. * @param totalFrame The total number of frames
  24474. * @param from The frame at the beginning of the animation
  24475. * @param to The frame at the end of the animation
  24476. * @param loopMode Specifies the loop mode of the animation
  24477. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  24478. * @param onAnimationEnd Callback to run once the animation is complete
  24479. * @returns Nullable animation
  24480. */
  24481. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24482. /**
  24483. * Transition property of an host to the target Value
  24484. * @param property The property to transition
  24485. * @param targetValue The target Value of the property
  24486. * @param host The object where the property to animate belongs
  24487. * @param scene Scene used to run the animation
  24488. * @param frameRate Framerate (in frame/s) to use
  24489. * @param transition The transition type we want to use
  24490. * @param duration The duration of the animation, in milliseconds
  24491. * @param onAnimationEnd Callback trigger at the end of the animation
  24492. * @returns Nullable animation
  24493. */
  24494. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  24495. /**
  24496. * Return the array of runtime animations currently using this animation
  24497. */
  24498. readonly runtimeAnimations: RuntimeAnimation[];
  24499. /**
  24500. * Specifies if any of the runtime animations are currently running
  24501. */
  24502. readonly hasRunningRuntimeAnimations: boolean;
  24503. /**
  24504. * Initializes the animation
  24505. * @param name Name of the animation
  24506. * @param targetProperty Property to animate
  24507. * @param framePerSecond The frames per second of the animation
  24508. * @param dataType The data type of the animation
  24509. * @param loopMode The loop mode of the animation
  24510. * @param enableBlending Specifies if blending should be enabled
  24511. */
  24512. constructor(
  24513. /**Name of the animation */
  24514. name: string,
  24515. /**Property to animate */
  24516. targetProperty: string,
  24517. /**The frames per second of the animation */
  24518. framePerSecond: number,
  24519. /**The data type of the animation */
  24520. dataType: number,
  24521. /**The loop mode of the animation */
  24522. loopMode?: number | undefined,
  24523. /**Specifies if blending should be enabled */
  24524. enableBlending?: boolean | undefined);
  24525. /**
  24526. * Converts the animation to a string
  24527. * @param fullDetails support for multiple levels of logging within scene loading
  24528. * @returns String form of the animation
  24529. */
  24530. toString(fullDetails?: boolean): string;
  24531. /**
  24532. * Add an event to this animation
  24533. * @param event Event to add
  24534. */
  24535. addEvent(event: AnimationEvent): void;
  24536. /**
  24537. * Remove all events found at the given frame
  24538. * @param frame The frame to remove events from
  24539. */
  24540. removeEvents(frame: number): void;
  24541. /**
  24542. * Retrieves all the events from the animation
  24543. * @returns Events from the animation
  24544. */
  24545. getEvents(): AnimationEvent[];
  24546. /**
  24547. * Creates an animation range
  24548. * @param name Name of the animation range
  24549. * @param from Starting frame of the animation range
  24550. * @param to Ending frame of the animation
  24551. */
  24552. createRange(name: string, from: number, to: number): void;
  24553. /**
  24554. * Deletes an animation range by name
  24555. * @param name Name of the animation range to delete
  24556. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  24557. */
  24558. deleteRange(name: string, deleteFrames?: boolean): void;
  24559. /**
  24560. * Gets the animation range by name, or null if not defined
  24561. * @param name Name of the animation range
  24562. * @returns Nullable animation range
  24563. */
  24564. getRange(name: string): Nullable<AnimationRange>;
  24565. /**
  24566. * Gets the key frames from the animation
  24567. * @returns The key frames of the animation
  24568. */
  24569. getKeys(): Array<IAnimationKey>;
  24570. /**
  24571. * Gets the highest frame rate of the animation
  24572. * @returns Highest frame rate of the animation
  24573. */
  24574. getHighestFrame(): number;
  24575. /**
  24576. * Gets the easing function of the animation
  24577. * @returns Easing function of the animation
  24578. */
  24579. getEasingFunction(): IEasingFunction;
  24580. /**
  24581. * Sets the easing function of the animation
  24582. * @param easingFunction A custom mathematical formula for animation
  24583. */
  24584. setEasingFunction(easingFunction: EasingFunction): void;
  24585. /**
  24586. * Interpolates a scalar linearly
  24587. * @param startValue Start value of the animation curve
  24588. * @param endValue End value of the animation curve
  24589. * @param gradient Scalar amount to interpolate
  24590. * @returns Interpolated scalar value
  24591. */
  24592. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  24593. /**
  24594. * Interpolates a scalar cubically
  24595. * @param startValue Start value of the animation curve
  24596. * @param outTangent End tangent of the animation
  24597. * @param endValue End value of the animation curve
  24598. * @param inTangent Start tangent of the animation curve
  24599. * @param gradient Scalar amount to interpolate
  24600. * @returns Interpolated scalar value
  24601. */
  24602. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  24603. /**
  24604. * Interpolates a quaternion using a spherical linear interpolation
  24605. * @param startValue Start value of the animation curve
  24606. * @param endValue End value of the animation curve
  24607. * @param gradient Scalar amount to interpolate
  24608. * @returns Interpolated quaternion value
  24609. */
  24610. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  24611. /**
  24612. * Interpolates a quaternion cubically
  24613. * @param startValue Start value of the animation curve
  24614. * @param outTangent End tangent of the animation curve
  24615. * @param endValue End value of the animation curve
  24616. * @param inTangent Start tangent of the animation curve
  24617. * @param gradient Scalar amount to interpolate
  24618. * @returns Interpolated quaternion value
  24619. */
  24620. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  24621. /**
  24622. * Interpolates a Vector3 linearl
  24623. * @param startValue Start value of the animation curve
  24624. * @param endValue End value of the animation curve
  24625. * @param gradient Scalar amount to interpolate
  24626. * @returns Interpolated scalar value
  24627. */
  24628. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  24629. /**
  24630. * Interpolates a Vector3 cubically
  24631. * @param startValue Start value of the animation curve
  24632. * @param outTangent End tangent of the animation
  24633. * @param endValue End value of the animation curve
  24634. * @param inTangent Start tangent of the animation curve
  24635. * @param gradient Scalar amount to interpolate
  24636. * @returns InterpolatedVector3 value
  24637. */
  24638. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  24639. /**
  24640. * Interpolates a Vector2 linearly
  24641. * @param startValue Start value of the animation curve
  24642. * @param endValue End value of the animation curve
  24643. * @param gradient Scalar amount to interpolate
  24644. * @returns Interpolated Vector2 value
  24645. */
  24646. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  24647. /**
  24648. * Interpolates a Vector2 cubically
  24649. * @param startValue Start value of the animation curve
  24650. * @param outTangent End tangent of the animation
  24651. * @param endValue End value of the animation curve
  24652. * @param inTangent Start tangent of the animation curve
  24653. * @param gradient Scalar amount to interpolate
  24654. * @returns Interpolated Vector2 value
  24655. */
  24656. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  24657. /**
  24658. * Interpolates a size linearly
  24659. * @param startValue Start value of the animation curve
  24660. * @param endValue End value of the animation curve
  24661. * @param gradient Scalar amount to interpolate
  24662. * @returns Interpolated Size value
  24663. */
  24664. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  24665. /**
  24666. * Interpolates a Color3 linearly
  24667. * @param startValue Start value of the animation curve
  24668. * @param endValue End value of the animation curve
  24669. * @param gradient Scalar amount to interpolate
  24670. * @returns Interpolated Color3 value
  24671. */
  24672. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  24673. /**
  24674. * @hidden Internal use only
  24675. */
  24676. _getKeyValue(value: any): any;
  24677. /**
  24678. * @hidden Internal use only
  24679. */
  24680. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  24681. /**
  24682. * Defines the function to use to interpolate matrices
  24683. * @param startValue defines the start matrix
  24684. * @param endValue defines the end matrix
  24685. * @param gradient defines the gradient between both matrices
  24686. * @param result defines an optional target matrix where to store the interpolation
  24687. * @returns the interpolated matrix
  24688. */
  24689. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  24690. /**
  24691. * Makes a copy of the animation
  24692. * @returns Cloned animation
  24693. */
  24694. clone(): Animation;
  24695. /**
  24696. * Sets the key frames of the animation
  24697. * @param values The animation key frames to set
  24698. */
  24699. setKeys(values: Array<IAnimationKey>): void;
  24700. /**
  24701. * Serializes the animation to an object
  24702. * @returns Serialized object
  24703. */
  24704. serialize(): any;
  24705. /**
  24706. * Float animation type
  24707. */
  24708. private static _ANIMATIONTYPE_FLOAT;
  24709. /**
  24710. * Vector3 animation type
  24711. */
  24712. private static _ANIMATIONTYPE_VECTOR3;
  24713. /**
  24714. * Quaternion animation type
  24715. */
  24716. private static _ANIMATIONTYPE_QUATERNION;
  24717. /**
  24718. * Matrix animation type
  24719. */
  24720. private static _ANIMATIONTYPE_MATRIX;
  24721. /**
  24722. * Color3 animation type
  24723. */
  24724. private static _ANIMATIONTYPE_COLOR3;
  24725. /**
  24726. * Vector2 animation type
  24727. */
  24728. private static _ANIMATIONTYPE_VECTOR2;
  24729. /**
  24730. * Size animation type
  24731. */
  24732. private static _ANIMATIONTYPE_SIZE;
  24733. /**
  24734. * Relative Loop Mode
  24735. */
  24736. private static _ANIMATIONLOOPMODE_RELATIVE;
  24737. /**
  24738. * Cycle Loop Mode
  24739. */
  24740. private static _ANIMATIONLOOPMODE_CYCLE;
  24741. /**
  24742. * Constant Loop Mode
  24743. */
  24744. private static _ANIMATIONLOOPMODE_CONSTANT;
  24745. /**
  24746. * Get the float animation type
  24747. */
  24748. static readonly ANIMATIONTYPE_FLOAT: number;
  24749. /**
  24750. * Get the Vector3 animation type
  24751. */
  24752. static readonly ANIMATIONTYPE_VECTOR3: number;
  24753. /**
  24754. * Get the Vector2 animation type
  24755. */
  24756. static readonly ANIMATIONTYPE_VECTOR2: number;
  24757. /**
  24758. * Get the Size animation type
  24759. */
  24760. static readonly ANIMATIONTYPE_SIZE: number;
  24761. /**
  24762. * Get the Quaternion animation type
  24763. */
  24764. static readonly ANIMATIONTYPE_QUATERNION: number;
  24765. /**
  24766. * Get the Matrix animation type
  24767. */
  24768. static readonly ANIMATIONTYPE_MATRIX: number;
  24769. /**
  24770. * Get the Color3 animation type
  24771. */
  24772. static readonly ANIMATIONTYPE_COLOR3: number;
  24773. /**
  24774. * Get the Relative Loop Mode
  24775. */
  24776. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  24777. /**
  24778. * Get the Cycle Loop Mode
  24779. */
  24780. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  24781. /**
  24782. * Get the Constant Loop Mode
  24783. */
  24784. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  24785. /** @hidden */
  24786. static _UniversalLerp(left: any, right: any, amount: number): any;
  24787. /**
  24788. * Parses an animation object and creates an animation
  24789. * @param parsedAnimation Parsed animation object
  24790. * @returns Animation object
  24791. */
  24792. static Parse(parsedAnimation: any): Animation;
  24793. /**
  24794. * Appends the serialized animations from the source animations
  24795. * @param source Source containing the animations
  24796. * @param destination Target to store the animations
  24797. */
  24798. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  24799. }
  24800. }
  24801. declare module BABYLON {
  24802. /**
  24803. * Base class of all the textures in babylon.
  24804. * It groups all the common properties the materials, post process, lights... might need
  24805. * in order to make a correct use of the texture.
  24806. */
  24807. export class BaseTexture implements IAnimatable {
  24808. /**
  24809. * Default anisotropic filtering level for the application.
  24810. * It is set to 4 as a good tradeoff between perf and quality.
  24811. */
  24812. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  24813. /**
  24814. * Gets or sets the unique id of the texture
  24815. */
  24816. uniqueId: number;
  24817. /**
  24818. * Define the name of the texture.
  24819. */
  24820. name: string;
  24821. /**
  24822. * Gets or sets an object used to store user defined information.
  24823. */
  24824. metadata: any;
  24825. /**
  24826. * For internal use only. Please do not use.
  24827. */
  24828. reservedDataStore: any;
  24829. private _hasAlpha;
  24830. /**
  24831. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  24832. */
  24833. hasAlpha: boolean;
  24834. /**
  24835. * Defines if the alpha value should be determined via the rgb values.
  24836. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  24837. */
  24838. getAlphaFromRGB: boolean;
  24839. /**
  24840. * Intensity or strength of the texture.
  24841. * It is commonly used by materials to fine tune the intensity of the texture
  24842. */
  24843. level: number;
  24844. /**
  24845. * Define the UV chanel to use starting from 0 and defaulting to 0.
  24846. * This is part of the texture as textures usually maps to one uv set.
  24847. */
  24848. coordinatesIndex: number;
  24849. private _coordinatesMode;
  24850. /**
  24851. * How a texture is mapped.
  24852. *
  24853. * | Value | Type | Description |
  24854. * | ----- | ----------------------------------- | ----------- |
  24855. * | 0 | EXPLICIT_MODE | |
  24856. * | 1 | SPHERICAL_MODE | |
  24857. * | 2 | PLANAR_MODE | |
  24858. * | 3 | CUBIC_MODE | |
  24859. * | 4 | PROJECTION_MODE | |
  24860. * | 5 | SKYBOX_MODE | |
  24861. * | 6 | INVCUBIC_MODE | |
  24862. * | 7 | EQUIRECTANGULAR_MODE | |
  24863. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  24864. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  24865. */
  24866. coordinatesMode: number;
  24867. /**
  24868. * | Value | Type | Description |
  24869. * | ----- | ------------------ | ----------- |
  24870. * | 0 | CLAMP_ADDRESSMODE | |
  24871. * | 1 | WRAP_ADDRESSMODE | |
  24872. * | 2 | MIRROR_ADDRESSMODE | |
  24873. */
  24874. wrapU: number;
  24875. /**
  24876. * | Value | Type | Description |
  24877. * | ----- | ------------------ | ----------- |
  24878. * | 0 | CLAMP_ADDRESSMODE | |
  24879. * | 1 | WRAP_ADDRESSMODE | |
  24880. * | 2 | MIRROR_ADDRESSMODE | |
  24881. */
  24882. wrapV: number;
  24883. /**
  24884. * | Value | Type | Description |
  24885. * | ----- | ------------------ | ----------- |
  24886. * | 0 | CLAMP_ADDRESSMODE | |
  24887. * | 1 | WRAP_ADDRESSMODE | |
  24888. * | 2 | MIRROR_ADDRESSMODE | |
  24889. */
  24890. wrapR: number;
  24891. /**
  24892. * With compliant hardware and browser (supporting anisotropic filtering)
  24893. * this defines the level of anisotropic filtering in the texture.
  24894. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  24895. */
  24896. anisotropicFilteringLevel: number;
  24897. /**
  24898. * Define if the texture is a cube texture or if false a 2d texture.
  24899. */
  24900. isCube: boolean;
  24901. /**
  24902. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  24903. */
  24904. is3D: boolean;
  24905. /**
  24906. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  24907. * HDR texture are usually stored in linear space.
  24908. * This only impacts the PBR and Background materials
  24909. */
  24910. gammaSpace: boolean;
  24911. /**
  24912. * Gets whether or not the texture contains RGBD data.
  24913. */
  24914. readonly isRGBD: boolean;
  24915. /**
  24916. * Is Z inverted in the texture (useful in a cube texture).
  24917. */
  24918. invertZ: boolean;
  24919. /**
  24920. * Are mip maps generated for this texture or not.
  24921. */
  24922. readonly noMipmap: boolean;
  24923. /**
  24924. * @hidden
  24925. */
  24926. lodLevelInAlpha: boolean;
  24927. /**
  24928. * With prefiltered texture, defined the offset used during the prefiltering steps.
  24929. */
  24930. lodGenerationOffset: number;
  24931. /**
  24932. * With prefiltered texture, defined the scale used during the prefiltering steps.
  24933. */
  24934. lodGenerationScale: number;
  24935. /**
  24936. * Define if the texture is a render target.
  24937. */
  24938. isRenderTarget: boolean;
  24939. /**
  24940. * Define the unique id of the texture in the scene.
  24941. */
  24942. readonly uid: string;
  24943. /**
  24944. * Return a string representation of the texture.
  24945. * @returns the texture as a string
  24946. */
  24947. toString(): string;
  24948. /**
  24949. * Get the class name of the texture.
  24950. * @returns "BaseTexture"
  24951. */
  24952. getClassName(): string;
  24953. /**
  24954. * Define the list of animation attached to the texture.
  24955. */
  24956. animations: Animation[];
  24957. /**
  24958. * An event triggered when the texture is disposed.
  24959. */
  24960. onDisposeObservable: Observable<BaseTexture>;
  24961. private _onDisposeObserver;
  24962. /**
  24963. * Callback triggered when the texture has been disposed.
  24964. * Kept for back compatibility, you can use the onDisposeObservable instead.
  24965. */
  24966. onDispose: () => void;
  24967. /**
  24968. * Define the current state of the loading sequence when in delayed load mode.
  24969. */
  24970. delayLoadState: number;
  24971. private _scene;
  24972. /** @hidden */
  24973. _texture: Nullable<InternalTexture>;
  24974. private _uid;
  24975. /**
  24976. * Define if the texture is preventinga material to render or not.
  24977. * If not and the texture is not ready, the engine will use a default black texture instead.
  24978. */
  24979. readonly isBlocking: boolean;
  24980. /**
  24981. * Instantiates a new BaseTexture.
  24982. * Base class of all the textures in babylon.
  24983. * It groups all the common properties the materials, post process, lights... might need
  24984. * in order to make a correct use of the texture.
  24985. * @param scene Define the scene the texture blongs to
  24986. */
  24987. constructor(scene: Nullable<Scene>);
  24988. /**
  24989. * Get the scene the texture belongs to.
  24990. * @returns the scene or null if undefined
  24991. */
  24992. getScene(): Nullable<Scene>;
  24993. /**
  24994. * Get the texture transform matrix used to offset tile the texture for istance.
  24995. * @returns the transformation matrix
  24996. */
  24997. getTextureMatrix(): Matrix;
  24998. /**
  24999. * Get the texture reflection matrix used to rotate/transform the reflection.
  25000. * @returns the reflection matrix
  25001. */
  25002. getReflectionTextureMatrix(): Matrix;
  25003. /**
  25004. * Get the underlying lower level texture from Babylon.
  25005. * @returns the insternal texture
  25006. */
  25007. getInternalTexture(): Nullable<InternalTexture>;
  25008. /**
  25009. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25010. * @returns true if ready or not blocking
  25011. */
  25012. isReadyOrNotBlocking(): boolean;
  25013. /**
  25014. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25015. * @returns true if fully ready
  25016. */
  25017. isReady(): boolean;
  25018. private _cachedSize;
  25019. /**
  25020. * Get the size of the texture.
  25021. * @returns the texture size.
  25022. */
  25023. getSize(): ISize;
  25024. /**
  25025. * Get the base size of the texture.
  25026. * It can be different from the size if the texture has been resized for POT for instance
  25027. * @returns the base size
  25028. */
  25029. getBaseSize(): ISize;
  25030. /**
  25031. * Update the sampling mode of the texture.
  25032. * Default is Trilinear mode.
  25033. *
  25034. * | Value | Type | Description |
  25035. * | ----- | ------------------ | ----------- |
  25036. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25037. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25038. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25039. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25040. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25041. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25042. * | 7 | NEAREST_LINEAR | |
  25043. * | 8 | NEAREST_NEAREST | |
  25044. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25045. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25046. * | 11 | LINEAR_LINEAR | |
  25047. * | 12 | LINEAR_NEAREST | |
  25048. *
  25049. * > _mag_: magnification filter (close to the viewer)
  25050. * > _min_: minification filter (far from the viewer)
  25051. * > _mip_: filter used between mip map levels
  25052. *@param samplingMode Define the new sampling mode of the texture
  25053. */
  25054. updateSamplingMode(samplingMode: number): void;
  25055. /**
  25056. * Scales the texture if is `canRescale()`
  25057. * @param ratio the resize factor we want to use to rescale
  25058. */
  25059. scale(ratio: number): void;
  25060. /**
  25061. * Get if the texture can rescale.
  25062. */
  25063. readonly canRescale: boolean;
  25064. /** @hidden */
  25065. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  25066. /** @hidden */
  25067. _rebuild(): void;
  25068. /**
  25069. * Triggers the load sequence in delayed load mode.
  25070. */
  25071. delayLoad(): void;
  25072. /**
  25073. * Clones the texture.
  25074. * @returns the cloned texture
  25075. */
  25076. clone(): Nullable<BaseTexture>;
  25077. /**
  25078. * Get the texture underlying type (INT, FLOAT...)
  25079. */
  25080. readonly textureType: number;
  25081. /**
  25082. * Get the texture underlying format (RGB, RGBA...)
  25083. */
  25084. readonly textureFormat: number;
  25085. /**
  25086. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25087. * This will returns an RGBA array buffer containing either in values (0-255) or
  25088. * float values (0-1) depending of the underlying buffer type.
  25089. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25090. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25091. * @param buffer defines a user defined buffer to fill with data (can be null)
  25092. * @returns The Array buffer containing the pixels data.
  25093. */
  25094. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25095. /**
  25096. * Release and destroy the underlying lower level texture aka internalTexture.
  25097. */
  25098. releaseInternalTexture(): void;
  25099. /**
  25100. * Get the polynomial representation of the texture data.
  25101. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25102. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25103. */
  25104. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25105. /** @hidden */
  25106. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25107. /** @hidden */
  25108. readonly _lodTextureMid: Nullable<BaseTexture>;
  25109. /** @hidden */
  25110. readonly _lodTextureLow: Nullable<BaseTexture>;
  25111. /**
  25112. * Dispose the texture and release its associated resources.
  25113. */
  25114. dispose(): void;
  25115. /**
  25116. * Serialize the texture into a JSON representation that can be parsed later on.
  25117. * @returns the JSON representation of the texture
  25118. */
  25119. serialize(): any;
  25120. /**
  25121. * Helper function to be called back once a list of texture contains only ready textures.
  25122. * @param textures Define the list of textures to wait for
  25123. * @param callback Define the callback triggered once the entire list will be ready
  25124. */
  25125. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25126. }
  25127. }
  25128. declare module BABYLON {
  25129. /**
  25130. * Uniform buffer objects.
  25131. *
  25132. * Handles blocks of uniform on the GPU.
  25133. *
  25134. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25135. *
  25136. * For more information, please refer to :
  25137. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25138. */
  25139. export class UniformBuffer {
  25140. private _engine;
  25141. private _buffer;
  25142. private _data;
  25143. private _bufferData;
  25144. private _dynamic?;
  25145. private _uniformLocations;
  25146. private _uniformSizes;
  25147. private _uniformLocationPointer;
  25148. private _needSync;
  25149. private _noUBO;
  25150. private _currentEffect;
  25151. private static _MAX_UNIFORM_SIZE;
  25152. private static _tempBuffer;
  25153. /**
  25154. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25155. * This is dynamic to allow compat with webgl 1 and 2.
  25156. * You will need to pass the name of the uniform as well as the value.
  25157. */
  25158. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25159. /**
  25160. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25161. * This is dynamic to allow compat with webgl 1 and 2.
  25162. * You will need to pass the name of the uniform as well as the value.
  25163. */
  25164. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25165. /**
  25166. * Lambda to Update a single float in a uniform buffer.
  25167. * This is dynamic to allow compat with webgl 1 and 2.
  25168. * You will need to pass the name of the uniform as well as the value.
  25169. */
  25170. updateFloat: (name: string, x: number) => void;
  25171. /**
  25172. * Lambda to Update a vec2 of float in a uniform buffer.
  25173. * This is dynamic to allow compat with webgl 1 and 2.
  25174. * You will need to pass the name of the uniform as well as the value.
  25175. */
  25176. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25177. /**
  25178. * Lambda to Update a vec3 of float in a uniform buffer.
  25179. * This is dynamic to allow compat with webgl 1 and 2.
  25180. * You will need to pass the name of the uniform as well as the value.
  25181. */
  25182. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25183. /**
  25184. * Lambda to Update a vec4 of float in a uniform buffer.
  25185. * This is dynamic to allow compat with webgl 1 and 2.
  25186. * You will need to pass the name of the uniform as well as the value.
  25187. */
  25188. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25189. /**
  25190. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25191. * This is dynamic to allow compat with webgl 1 and 2.
  25192. * You will need to pass the name of the uniform as well as the value.
  25193. */
  25194. updateMatrix: (name: string, mat: Matrix) => void;
  25195. /**
  25196. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25197. * This is dynamic to allow compat with webgl 1 and 2.
  25198. * You will need to pass the name of the uniform as well as the value.
  25199. */
  25200. updateVector3: (name: string, vector: Vector3) => void;
  25201. /**
  25202. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25203. * This is dynamic to allow compat with webgl 1 and 2.
  25204. * You will need to pass the name of the uniform as well as the value.
  25205. */
  25206. updateVector4: (name: string, vector: Vector4) => void;
  25207. /**
  25208. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25209. * This is dynamic to allow compat with webgl 1 and 2.
  25210. * You will need to pass the name of the uniform as well as the value.
  25211. */
  25212. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25213. /**
  25214. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25215. * This is dynamic to allow compat with webgl 1 and 2.
  25216. * You will need to pass the name of the uniform as well as the value.
  25217. */
  25218. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25219. /**
  25220. * Instantiates a new Uniform buffer objects.
  25221. *
  25222. * Handles blocks of uniform on the GPU.
  25223. *
  25224. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25225. *
  25226. * For more information, please refer to :
  25227. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25228. * @param engine Define the engine the buffer is associated with
  25229. * @param data Define the data contained in the buffer
  25230. * @param dynamic Define if the buffer is updatable
  25231. */
  25232. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25233. /**
  25234. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25235. * or just falling back on setUniformXXX calls.
  25236. */
  25237. readonly useUbo: boolean;
  25238. /**
  25239. * Indicates if the WebGL underlying uniform buffer is in sync
  25240. * with the javascript cache data.
  25241. */
  25242. readonly isSync: boolean;
  25243. /**
  25244. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25245. * Also, a dynamic UniformBuffer will disable cache verification and always
  25246. * update the underlying WebGL uniform buffer to the GPU.
  25247. * @returns if Dynamic, otherwise false
  25248. */
  25249. isDynamic(): boolean;
  25250. /**
  25251. * The data cache on JS side.
  25252. * @returns the underlying data as a float array
  25253. */
  25254. getData(): Float32Array;
  25255. /**
  25256. * The underlying WebGL Uniform buffer.
  25257. * @returns the webgl buffer
  25258. */
  25259. getBuffer(): Nullable<WebGLBuffer>;
  25260. /**
  25261. * std140 layout specifies how to align data within an UBO structure.
  25262. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25263. * for specs.
  25264. */
  25265. private _fillAlignment;
  25266. /**
  25267. * Adds an uniform in the buffer.
  25268. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25269. * for the layout to be correct !
  25270. * @param name Name of the uniform, as used in the uniform block in the shader.
  25271. * @param size Data size, or data directly.
  25272. */
  25273. addUniform(name: string, size: number | number[]): void;
  25274. /**
  25275. * Adds a Matrix 4x4 to the uniform buffer.
  25276. * @param name Name of the uniform, as used in the uniform block in the shader.
  25277. * @param mat A 4x4 matrix.
  25278. */
  25279. addMatrix(name: string, mat: Matrix): void;
  25280. /**
  25281. * Adds a vec2 to the uniform buffer.
  25282. * @param name Name of the uniform, as used in the uniform block in the shader.
  25283. * @param x Define the x component value of the vec2
  25284. * @param y Define the y component value of the vec2
  25285. */
  25286. addFloat2(name: string, x: number, y: number): void;
  25287. /**
  25288. * Adds a vec3 to the uniform buffer.
  25289. * @param name Name of the uniform, as used in the uniform block in the shader.
  25290. * @param x Define the x component value of the vec3
  25291. * @param y Define the y component value of the vec3
  25292. * @param z Define the z component value of the vec3
  25293. */
  25294. addFloat3(name: string, x: number, y: number, z: number): void;
  25295. /**
  25296. * Adds a vec3 to the uniform buffer.
  25297. * @param name Name of the uniform, as used in the uniform block in the shader.
  25298. * @param color Define the vec3 from a Color
  25299. */
  25300. addColor3(name: string, color: Color3): void;
  25301. /**
  25302. * Adds a vec4 to the uniform buffer.
  25303. * @param name Name of the uniform, as used in the uniform block in the shader.
  25304. * @param color Define the rgb components from a Color
  25305. * @param alpha Define the a component of the vec4
  25306. */
  25307. addColor4(name: string, color: Color3, alpha: number): void;
  25308. /**
  25309. * Adds a vec3 to the uniform buffer.
  25310. * @param name Name of the uniform, as used in the uniform block in the shader.
  25311. * @param vector Define the vec3 components from a Vector
  25312. */
  25313. addVector3(name: string, vector: Vector3): void;
  25314. /**
  25315. * Adds a Matrix 3x3 to the uniform buffer.
  25316. * @param name Name of the uniform, as used in the uniform block in the shader.
  25317. */
  25318. addMatrix3x3(name: string): void;
  25319. /**
  25320. * Adds a Matrix 2x2 to the uniform buffer.
  25321. * @param name Name of the uniform, as used in the uniform block in the shader.
  25322. */
  25323. addMatrix2x2(name: string): void;
  25324. /**
  25325. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25326. */
  25327. create(): void;
  25328. /** @hidden */
  25329. _rebuild(): void;
  25330. /**
  25331. * Updates the WebGL Uniform Buffer on the GPU.
  25332. * If the `dynamic` flag is set to true, no cache comparison is done.
  25333. * Otherwise, the buffer will be updated only if the cache differs.
  25334. */
  25335. update(): void;
  25336. /**
  25337. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25338. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25339. * @param data Define the flattened data
  25340. * @param size Define the size of the data.
  25341. */
  25342. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25343. private _updateMatrix3x3ForUniform;
  25344. private _updateMatrix3x3ForEffect;
  25345. private _updateMatrix2x2ForEffect;
  25346. private _updateMatrix2x2ForUniform;
  25347. private _updateFloatForEffect;
  25348. private _updateFloatForUniform;
  25349. private _updateFloat2ForEffect;
  25350. private _updateFloat2ForUniform;
  25351. private _updateFloat3ForEffect;
  25352. private _updateFloat3ForUniform;
  25353. private _updateFloat4ForEffect;
  25354. private _updateFloat4ForUniform;
  25355. private _updateMatrixForEffect;
  25356. private _updateMatrixForUniform;
  25357. private _updateVector3ForEffect;
  25358. private _updateVector3ForUniform;
  25359. private _updateVector4ForEffect;
  25360. private _updateVector4ForUniform;
  25361. private _updateColor3ForEffect;
  25362. private _updateColor3ForUniform;
  25363. private _updateColor4ForEffect;
  25364. private _updateColor4ForUniform;
  25365. /**
  25366. * Sets a sampler uniform on the effect.
  25367. * @param name Define the name of the sampler.
  25368. * @param texture Define the texture to set in the sampler
  25369. */
  25370. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  25371. /**
  25372. * Directly updates the value of the uniform in the cache AND on the GPU.
  25373. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25374. * @param data Define the flattened data
  25375. */
  25376. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  25377. /**
  25378. * Binds this uniform buffer to an effect.
  25379. * @param effect Define the effect to bind the buffer to
  25380. * @param name Name of the uniform block in the shader.
  25381. */
  25382. bindToEffect(effect: Effect, name: string): void;
  25383. /**
  25384. * Disposes the uniform buffer.
  25385. */
  25386. dispose(): void;
  25387. }
  25388. }
  25389. declare module BABYLON {
  25390. /**
  25391. * This represents the required contract to create a new type of texture loader.
  25392. */
  25393. export interface IInternalTextureLoader {
  25394. /**
  25395. * Defines wether the loader supports cascade loading the different faces.
  25396. */
  25397. supportCascades: boolean;
  25398. /**
  25399. * This returns if the loader support the current file information.
  25400. * @param extension defines the file extension of the file being loaded
  25401. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25402. * @param fallback defines the fallback internal texture if any
  25403. * @param isBase64 defines whether the texture is encoded as a base64
  25404. * @param isBuffer defines whether the texture data are stored as a buffer
  25405. * @returns true if the loader can load the specified file
  25406. */
  25407. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  25408. /**
  25409. * Transform the url before loading if required.
  25410. * @param rootUrl the url of the texture
  25411. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25412. * @returns the transformed texture
  25413. */
  25414. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  25415. /**
  25416. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  25417. * @param rootUrl the url of the texture
  25418. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25419. * @returns the fallback texture
  25420. */
  25421. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  25422. /**
  25423. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  25424. * @param data contains the texture data
  25425. * @param texture defines the BabylonJS internal texture
  25426. * @param createPolynomials will be true if polynomials have been requested
  25427. * @param onLoad defines the callback to trigger once the texture is ready
  25428. * @param onError defines the callback to trigger in case of error
  25429. */
  25430. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  25431. /**
  25432. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  25433. * @param data contains the texture data
  25434. * @param texture defines the BabylonJS internal texture
  25435. * @param callback defines the method to call once ready to upload
  25436. */
  25437. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  25438. }
  25439. }
  25440. declare module BABYLON {
  25441. /**
  25442. * Creation options of the multi render target texture.
  25443. */
  25444. export interface IMultiRenderTargetOptions {
  25445. /**
  25446. * Define if the texture needs to create mip maps after render.
  25447. */
  25448. generateMipMaps?: boolean;
  25449. /**
  25450. * Define the types of all the draw buffers we want to create
  25451. */
  25452. types?: number[];
  25453. /**
  25454. * Define the sampling modes of all the draw buffers we want to create
  25455. */
  25456. samplingModes?: number[];
  25457. /**
  25458. * Define if a depth buffer is required
  25459. */
  25460. generateDepthBuffer?: boolean;
  25461. /**
  25462. * Define if a stencil buffer is required
  25463. */
  25464. generateStencilBuffer?: boolean;
  25465. /**
  25466. * Define if a depth texture is required instead of a depth buffer
  25467. */
  25468. generateDepthTexture?: boolean;
  25469. /**
  25470. * Define the number of desired draw buffers
  25471. */
  25472. textureCount?: number;
  25473. /**
  25474. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25475. */
  25476. doNotChangeAspectRatio?: boolean;
  25477. /**
  25478. * Define the default type of the buffers we are creating
  25479. */
  25480. defaultType?: number;
  25481. }
  25482. /**
  25483. * A multi render target, like a render target provides the ability to render to a texture.
  25484. * Unlike the render target, it can render to several draw buffers in one draw.
  25485. * This is specially interesting in deferred rendering or for any effects requiring more than
  25486. * just one color from a single pass.
  25487. */
  25488. export class MultiRenderTarget extends RenderTargetTexture {
  25489. private _internalTextures;
  25490. private _textures;
  25491. private _multiRenderTargetOptions;
  25492. /**
  25493. * Get if draw buffers are currently supported by the used hardware and browser.
  25494. */
  25495. readonly isSupported: boolean;
  25496. /**
  25497. * Get the list of textures generated by the multi render target.
  25498. */
  25499. readonly textures: Texture[];
  25500. /**
  25501. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25502. */
  25503. readonly depthTexture: Texture;
  25504. /**
  25505. * Set the wrapping mode on U of all the textures we are rendering to.
  25506. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25507. */
  25508. wrapU: number;
  25509. /**
  25510. * Set the wrapping mode on V of all the textures we are rendering to.
  25511. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25512. */
  25513. wrapV: number;
  25514. /**
  25515. * Instantiate a new multi render target texture.
  25516. * A multi render target, like a render target provides the ability to render to a texture.
  25517. * Unlike the render target, it can render to several draw buffers in one draw.
  25518. * This is specially interesting in deferred rendering or for any effects requiring more than
  25519. * just one color from a single pass.
  25520. * @param name Define the name of the texture
  25521. * @param size Define the size of the buffers to render to
  25522. * @param count Define the number of target we are rendering into
  25523. * @param scene Define the scene the texture belongs to
  25524. * @param options Define the options used to create the multi render target
  25525. */
  25526. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25527. /** @hidden */
  25528. _rebuild(): void;
  25529. private _createInternalTextures;
  25530. private _createTextures;
  25531. /**
  25532. * Define the number of samples used if MSAA is enabled.
  25533. */
  25534. samples: number;
  25535. /**
  25536. * Resize all the textures in the multi render target.
  25537. * Be carrefull as it will recreate all the data in the new texture.
  25538. * @param size Define the new size
  25539. */
  25540. resize(size: any): void;
  25541. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25542. /**
  25543. * Dispose the render targets and their associated resources
  25544. */
  25545. dispose(): void;
  25546. /**
  25547. * Release all the underlying texture used as draw buffers.
  25548. */
  25549. releaseInternalTextures(): void;
  25550. }
  25551. }
  25552. declare module BABYLON {
  25553. /**
  25554. * Class used to work with sound analyzer using fast fourier transform (FFT)
  25555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25556. */
  25557. export class Analyser {
  25558. /**
  25559. * Gets or sets the smoothing
  25560. * @ignorenaming
  25561. */
  25562. SMOOTHING: number;
  25563. /**
  25564. * Gets or sets the FFT table size
  25565. * @ignorenaming
  25566. */
  25567. FFT_SIZE: number;
  25568. /**
  25569. * Gets or sets the bar graph amplitude
  25570. * @ignorenaming
  25571. */
  25572. BARGRAPHAMPLITUDE: number;
  25573. /**
  25574. * Gets or sets the position of the debug canvas
  25575. * @ignorenaming
  25576. */
  25577. DEBUGCANVASPOS: {
  25578. x: number;
  25579. y: number;
  25580. };
  25581. /**
  25582. * Gets or sets the debug canvas size
  25583. * @ignorenaming
  25584. */
  25585. DEBUGCANVASSIZE: {
  25586. width: number;
  25587. height: number;
  25588. };
  25589. private _byteFreqs;
  25590. private _byteTime;
  25591. private _floatFreqs;
  25592. private _webAudioAnalyser;
  25593. private _debugCanvas;
  25594. private _debugCanvasContext;
  25595. private _scene;
  25596. private _registerFunc;
  25597. private _audioEngine;
  25598. /**
  25599. * Creates a new analyser
  25600. * @param scene defines hosting scene
  25601. */
  25602. constructor(scene: Scene);
  25603. /**
  25604. * Get the number of data values you will have to play with for the visualization
  25605. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  25606. * @returns a number
  25607. */
  25608. getFrequencyBinCount(): number;
  25609. /**
  25610. * Gets the current frequency data as a byte array
  25611. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25612. * @returns a Uint8Array
  25613. */
  25614. getByteFrequencyData(): Uint8Array;
  25615. /**
  25616. * Gets the current waveform as a byte array
  25617. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  25618. * @returns a Uint8Array
  25619. */
  25620. getByteTimeDomainData(): Uint8Array;
  25621. /**
  25622. * Gets the current frequency data as a float array
  25623. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25624. * @returns a Float32Array
  25625. */
  25626. getFloatFrequencyData(): Float32Array;
  25627. /**
  25628. * Renders the debug canvas
  25629. */
  25630. drawDebugCanvas(): void;
  25631. /**
  25632. * Stops rendering the debug canvas and removes it
  25633. */
  25634. stopDebugCanvas(): void;
  25635. /**
  25636. * Connects two audio nodes
  25637. * @param inputAudioNode defines first node to connect
  25638. * @param outputAudioNode defines second node to connect
  25639. */
  25640. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  25641. /**
  25642. * Releases all associated resources
  25643. */
  25644. dispose(): void;
  25645. }
  25646. }
  25647. declare module BABYLON {
  25648. /**
  25649. * This represents an audio engine and it is responsible
  25650. * to play, synchronize and analyse sounds throughout the application.
  25651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25652. */
  25653. export interface IAudioEngine extends IDisposable {
  25654. /**
  25655. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25656. */
  25657. readonly canUseWebAudio: boolean;
  25658. /**
  25659. * Gets the current AudioContext if available.
  25660. */
  25661. readonly audioContext: Nullable<AudioContext>;
  25662. /**
  25663. * The master gain node defines the global audio volume of your audio engine.
  25664. */
  25665. readonly masterGain: GainNode;
  25666. /**
  25667. * Gets whether or not mp3 are supported by your browser.
  25668. */
  25669. readonly isMP3supported: boolean;
  25670. /**
  25671. * Gets whether or not ogg are supported by your browser.
  25672. */
  25673. readonly isOGGsupported: boolean;
  25674. /**
  25675. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25676. * @ignoreNaming
  25677. */
  25678. WarnedWebAudioUnsupported: boolean;
  25679. /**
  25680. * Defines if the audio engine relies on a custom unlocked button.
  25681. * In this case, the embedded button will not be displayed.
  25682. */
  25683. useCustomUnlockedButton: boolean;
  25684. /**
  25685. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  25686. */
  25687. readonly unlocked: boolean;
  25688. /**
  25689. * Event raised when audio has been unlocked on the browser.
  25690. */
  25691. onAudioUnlockedObservable: Observable<AudioEngine>;
  25692. /**
  25693. * Event raised when audio has been locked on the browser.
  25694. */
  25695. onAudioLockedObservable: Observable<AudioEngine>;
  25696. /**
  25697. * Flags the audio engine in Locked state.
  25698. * This happens due to new browser policies preventing audio to autoplay.
  25699. */
  25700. lock(): void;
  25701. /**
  25702. * Unlocks the audio engine once a user action has been done on the dom.
  25703. * This is helpful to resume play once browser policies have been satisfied.
  25704. */
  25705. unlock(): void;
  25706. }
  25707. /**
  25708. * This represents the default audio engine used in babylon.
  25709. * It is responsible to play, synchronize and analyse sounds throughout the application.
  25710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25711. */
  25712. export class AudioEngine implements IAudioEngine {
  25713. private _audioContext;
  25714. private _audioContextInitialized;
  25715. private _muteButton;
  25716. private _hostElement;
  25717. /**
  25718. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25719. */
  25720. canUseWebAudio: boolean;
  25721. /**
  25722. * The master gain node defines the global audio volume of your audio engine.
  25723. */
  25724. masterGain: GainNode;
  25725. /**
  25726. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25727. * @ignoreNaming
  25728. */
  25729. WarnedWebAudioUnsupported: boolean;
  25730. /**
  25731. * Gets whether or not mp3 are supported by your browser.
  25732. */
  25733. isMP3supported: boolean;
  25734. /**
  25735. * Gets whether or not ogg are supported by your browser.
  25736. */
  25737. isOGGsupported: boolean;
  25738. /**
  25739. * Gets whether audio has been unlocked on the device.
  25740. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  25741. * a user interaction has happened.
  25742. */
  25743. unlocked: boolean;
  25744. /**
  25745. * Defines if the audio engine relies on a custom unlocked button.
  25746. * In this case, the embedded button will not be displayed.
  25747. */
  25748. useCustomUnlockedButton: boolean;
  25749. /**
  25750. * Event raised when audio has been unlocked on the browser.
  25751. */
  25752. onAudioUnlockedObservable: Observable<AudioEngine>;
  25753. /**
  25754. * Event raised when audio has been locked on the browser.
  25755. */
  25756. onAudioLockedObservable: Observable<AudioEngine>;
  25757. /**
  25758. * Gets the current AudioContext if available.
  25759. */
  25760. readonly audioContext: Nullable<AudioContext>;
  25761. private _connectedAnalyser;
  25762. /**
  25763. * Instantiates a new audio engine.
  25764. *
  25765. * There should be only one per page as some browsers restrict the number
  25766. * of audio contexts you can create.
  25767. * @param hostElement defines the host element where to display the mute icon if necessary
  25768. */
  25769. constructor(hostElement?: Nullable<HTMLElement>);
  25770. /**
  25771. * Flags the audio engine in Locked state.
  25772. * This happens due to new browser policies preventing audio to autoplay.
  25773. */
  25774. lock(): void;
  25775. /**
  25776. * Unlocks the audio engine once a user action has been done on the dom.
  25777. * This is helpful to resume play once browser policies have been satisfied.
  25778. */
  25779. unlock(): void;
  25780. private _resumeAudioContext;
  25781. private _initializeAudioContext;
  25782. private _tryToRun;
  25783. private _triggerRunningState;
  25784. private _triggerSuspendedState;
  25785. private _displayMuteButton;
  25786. private _moveButtonToTopLeft;
  25787. private _onResize;
  25788. private _hideMuteButton;
  25789. /**
  25790. * Destroy and release the resources associated with the audio ccontext.
  25791. */
  25792. dispose(): void;
  25793. /**
  25794. * Gets the global volume sets on the master gain.
  25795. * @returns the global volume if set or -1 otherwise
  25796. */
  25797. getGlobalVolume(): number;
  25798. /**
  25799. * Sets the global volume of your experience (sets on the master gain).
  25800. * @param newVolume Defines the new global volume of the application
  25801. */
  25802. setGlobalVolume(newVolume: number): void;
  25803. /**
  25804. * Connect the audio engine to an audio analyser allowing some amazing
  25805. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  25806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  25807. * @param analyser The analyser to connect to the engine
  25808. */
  25809. connectToAnalyser(analyser: Analyser): void;
  25810. }
  25811. }
  25812. declare module BABYLON {
  25813. /**
  25814. * Interface used to present a loading screen while loading a scene
  25815. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25816. */
  25817. export interface ILoadingScreen {
  25818. /**
  25819. * Function called to display the loading screen
  25820. */
  25821. displayLoadingUI: () => void;
  25822. /**
  25823. * Function called to hide the loading screen
  25824. */
  25825. hideLoadingUI: () => void;
  25826. /**
  25827. * Gets or sets the color to use for the background
  25828. */
  25829. loadingUIBackgroundColor: string;
  25830. /**
  25831. * Gets or sets the text to display while loading
  25832. */
  25833. loadingUIText: string;
  25834. }
  25835. /**
  25836. * Class used for the default loading screen
  25837. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25838. */
  25839. export class DefaultLoadingScreen implements ILoadingScreen {
  25840. private _renderingCanvas;
  25841. private _loadingText;
  25842. private _loadingDivBackgroundColor;
  25843. private _loadingDiv;
  25844. private _loadingTextDiv;
  25845. /**
  25846. * Creates a new default loading screen
  25847. * @param _renderingCanvas defines the canvas used to render the scene
  25848. * @param _loadingText defines the default text to display
  25849. * @param _loadingDivBackgroundColor defines the default background color
  25850. */
  25851. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  25852. /**
  25853. * Function called to display the loading screen
  25854. */
  25855. displayLoadingUI(): void;
  25856. /**
  25857. * Function called to hide the loading screen
  25858. */
  25859. hideLoadingUI(): void;
  25860. /**
  25861. * Gets or sets the text to display while loading
  25862. */
  25863. loadingUIText: string;
  25864. /**
  25865. * Gets or sets the color to use for the background
  25866. */
  25867. loadingUIBackgroundColor: string;
  25868. private _resizeLoadingUI;
  25869. }
  25870. }
  25871. declare module BABYLON {
  25872. /**
  25873. * Settings for finer control over video usage
  25874. */
  25875. export interface VideoTextureSettings {
  25876. /**
  25877. * Applies `autoplay` to video, if specified
  25878. */
  25879. autoPlay?: boolean;
  25880. /**
  25881. * Applies `loop` to video, if specified
  25882. */
  25883. loop?: boolean;
  25884. /**
  25885. * Automatically updates internal texture from video at every frame in the render loop
  25886. */
  25887. autoUpdateTexture: boolean;
  25888. /**
  25889. * Image src displayed during the video loading or until the user interacts with the video.
  25890. */
  25891. poster?: string;
  25892. }
  25893. /**
  25894. * If you want to display a video in your scene, this is the special texture for that.
  25895. * This special texture works similar to other textures, with the exception of a few parameters.
  25896. * @see https://doc.babylonjs.com/how_to/video_texture
  25897. */
  25898. export class VideoTexture extends Texture {
  25899. /**
  25900. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  25901. */
  25902. readonly autoUpdateTexture: boolean;
  25903. /**
  25904. * The video instance used by the texture internally
  25905. */
  25906. readonly video: HTMLVideoElement;
  25907. private _onUserActionRequestedObservable;
  25908. /**
  25909. * Event triggerd when a dom action is required by the user to play the video.
  25910. * This happens due to recent changes in browser policies preventing video to auto start.
  25911. */
  25912. readonly onUserActionRequestedObservable: Observable<Texture>;
  25913. private _generateMipMaps;
  25914. private _engine;
  25915. private _stillImageCaptured;
  25916. private _displayingPosterTexture;
  25917. private _settings;
  25918. private _createInternalTextureOnEvent;
  25919. /**
  25920. * Creates a video texture.
  25921. * If you want to display a video in your scene, this is the special texture for that.
  25922. * This special texture works similar to other textures, with the exception of a few parameters.
  25923. * @see https://doc.babylonjs.com/how_to/video_texture
  25924. * @param name optional name, will detect from video source, if not defined
  25925. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  25926. * @param scene is obviously the current scene.
  25927. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  25928. * @param invertY is false by default but can be used to invert video on Y axis
  25929. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  25930. * @param settings allows finer control over video usage
  25931. */
  25932. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  25933. private _getName;
  25934. private _getVideo;
  25935. private _createInternalTexture;
  25936. private reset;
  25937. /**
  25938. * @hidden Internal method to initiate `update`.
  25939. */
  25940. _rebuild(): void;
  25941. /**
  25942. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  25943. */
  25944. update(): void;
  25945. /**
  25946. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  25947. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  25948. */
  25949. updateTexture(isVisible: boolean): void;
  25950. protected _updateInternalTexture: () => void;
  25951. /**
  25952. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  25953. * @param url New url.
  25954. */
  25955. updateURL(url: string): void;
  25956. /**
  25957. * Dispose the texture and release its associated resources.
  25958. */
  25959. dispose(): void;
  25960. /**
  25961. * Creates a video texture straight from your WebCam video feed.
  25962. * @param scene Define the scene the texture should be created in
  25963. * @param onReady Define a callback to triggered once the texture will be ready
  25964. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  25965. */
  25966. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  25967. minWidth: number;
  25968. maxWidth: number;
  25969. minHeight: number;
  25970. maxHeight: number;
  25971. deviceId: string;
  25972. }): void;
  25973. }
  25974. }
  25975. declare module BABYLON {
  25976. /**
  25977. * Interface for attribute information associated with buffer instanciation
  25978. */
  25979. export class InstancingAttributeInfo {
  25980. /**
  25981. * Index/offset of the attribute in the vertex shader
  25982. */
  25983. index: number;
  25984. /**
  25985. * size of the attribute, 1, 2, 3 or 4
  25986. */
  25987. attributeSize: number;
  25988. /**
  25989. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  25990. * default is FLOAT
  25991. */
  25992. attribyteType: number;
  25993. /**
  25994. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  25995. */
  25996. normalized: boolean;
  25997. /**
  25998. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  25999. */
  26000. offset: number;
  26001. /**
  26002. * Name of the GLSL attribute, for debugging purpose only
  26003. */
  26004. attributeName: string;
  26005. }
  26006. /**
  26007. * Define options used to create a depth texture
  26008. */
  26009. export class DepthTextureCreationOptions {
  26010. /** Specifies whether or not a stencil should be allocated in the texture */
  26011. generateStencil?: boolean;
  26012. /** Specifies whether or not bilinear filtering is enable on the texture */
  26013. bilinearFiltering?: boolean;
  26014. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26015. comparisonFunction?: number;
  26016. /** Specifies if the created texture is a cube texture */
  26017. isCube?: boolean;
  26018. }
  26019. /**
  26020. * Class used to describe the capabilities of the engine relatively to the current browser
  26021. */
  26022. export class EngineCapabilities {
  26023. /** Maximum textures units per fragment shader */
  26024. maxTexturesImageUnits: number;
  26025. /** Maximum texture units per vertex shader */
  26026. maxVertexTextureImageUnits: number;
  26027. /** Maximum textures units in the entire pipeline */
  26028. maxCombinedTexturesImageUnits: number;
  26029. /** Maximum texture size */
  26030. maxTextureSize: number;
  26031. /** Maximum cube texture size */
  26032. maxCubemapTextureSize: number;
  26033. /** Maximum render texture size */
  26034. maxRenderTextureSize: number;
  26035. /** Maximum number of vertex attributes */
  26036. maxVertexAttribs: number;
  26037. /** Maximum number of varyings */
  26038. maxVaryingVectors: number;
  26039. /** Maximum number of uniforms per vertex shader */
  26040. maxVertexUniformVectors: number;
  26041. /** Maximum number of uniforms per fragment shader */
  26042. maxFragmentUniformVectors: number;
  26043. /** Defines if standard derivates (dx/dy) are supported */
  26044. standardDerivatives: boolean;
  26045. /** Defines if s3tc texture compression is supported */
  26046. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26047. /** Defines if pvrtc texture compression is supported */
  26048. pvrtc: any;
  26049. /** Defines if etc1 texture compression is supported */
  26050. etc1: any;
  26051. /** Defines if etc2 texture compression is supported */
  26052. etc2: any;
  26053. /** Defines if astc texture compression is supported */
  26054. astc: any;
  26055. /** Defines if float textures are supported */
  26056. textureFloat: boolean;
  26057. /** Defines if vertex array objects are supported */
  26058. vertexArrayObject: boolean;
  26059. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26060. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26061. /** Gets the maximum level of anisotropy supported */
  26062. maxAnisotropy: number;
  26063. /** Defines if instancing is supported */
  26064. instancedArrays: boolean;
  26065. /** Defines if 32 bits indices are supported */
  26066. uintIndices: boolean;
  26067. /** Defines if high precision shaders are supported */
  26068. highPrecisionShaderSupported: boolean;
  26069. /** Defines if depth reading in the fragment shader is supported */
  26070. fragmentDepthSupported: boolean;
  26071. /** Defines if float texture linear filtering is supported*/
  26072. textureFloatLinearFiltering: boolean;
  26073. /** Defines if rendering to float textures is supported */
  26074. textureFloatRender: boolean;
  26075. /** Defines if half float textures are supported*/
  26076. textureHalfFloat: boolean;
  26077. /** Defines if half float texture linear filtering is supported*/
  26078. textureHalfFloatLinearFiltering: boolean;
  26079. /** Defines if rendering to half float textures is supported */
  26080. textureHalfFloatRender: boolean;
  26081. /** Defines if textureLOD shader command is supported */
  26082. textureLOD: boolean;
  26083. /** Defines if draw buffers extension is supported */
  26084. drawBuffersExtension: boolean;
  26085. /** Defines if depth textures are supported */
  26086. depthTextureExtension: boolean;
  26087. /** Defines if float color buffer are supported */
  26088. colorBufferFloat: boolean;
  26089. /** Gets disjoint timer query extension (null if not supported) */
  26090. timerQuery: EXT_disjoint_timer_query;
  26091. /** Defines if timestamp can be used with timer query */
  26092. canUseTimestampForTimerQuery: boolean;
  26093. /** Function used to let the system compiles shaders in background */
  26094. parallelShaderCompile: {
  26095. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26096. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26097. COMPLETION_STATUS_KHR: number;
  26098. };
  26099. }
  26100. /** Interface defining initialization parameters for Engine class */
  26101. export interface EngineOptions extends WebGLContextAttributes {
  26102. /**
  26103. * Defines if the engine should no exceed a specified device ratio
  26104. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26105. */
  26106. limitDeviceRatio?: number;
  26107. /**
  26108. * Defines if webvr should be enabled automatically
  26109. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26110. */
  26111. autoEnableWebVR?: boolean;
  26112. /**
  26113. * Defines if webgl2 should be turned off even if supported
  26114. * @see http://doc.babylonjs.com/features/webgl2
  26115. */
  26116. disableWebGL2Support?: boolean;
  26117. /**
  26118. * Defines if webaudio should be initialized as well
  26119. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26120. */
  26121. audioEngine?: boolean;
  26122. /**
  26123. * Defines if animations should run using a deterministic lock step
  26124. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26125. */
  26126. deterministicLockstep?: boolean;
  26127. /** Defines the maximum steps to use with deterministic lock step mode */
  26128. lockstepMaxSteps?: number;
  26129. /**
  26130. * Defines that engine should ignore context lost events
  26131. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26132. */
  26133. doNotHandleContextLost?: boolean;
  26134. /**
  26135. * Defines that engine should ignore modifying touch action attribute and style
  26136. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26137. */
  26138. doNotHandleTouchAction?: boolean;
  26139. }
  26140. /**
  26141. * Defines the interface used by display changed events
  26142. */
  26143. export interface IDisplayChangedEventArgs {
  26144. /** Gets the vrDisplay object (if any) */
  26145. vrDisplay: Nullable<any>;
  26146. /** Gets a boolean indicating if webVR is supported */
  26147. vrSupported: boolean;
  26148. }
  26149. /**
  26150. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26151. */
  26152. export class Engine {
  26153. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26154. static ExceptionList: ({
  26155. key: string;
  26156. capture: string;
  26157. captureConstraint: number;
  26158. targets: string[];
  26159. } | {
  26160. key: string;
  26161. capture: null;
  26162. captureConstraint: null;
  26163. targets: string[];
  26164. })[];
  26165. /** Gets the list of created engines */
  26166. static readonly Instances: Engine[];
  26167. /**
  26168. * Gets the latest created engine
  26169. */
  26170. static readonly LastCreatedEngine: Nullable<Engine>;
  26171. /**
  26172. * Gets the latest created scene
  26173. */
  26174. static readonly LastCreatedScene: Nullable<Scene>;
  26175. /**
  26176. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26177. * @param flag defines which part of the materials must be marked as dirty
  26178. * @param predicate defines a predicate used to filter which materials should be affected
  26179. */
  26180. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26181. /**
  26182. * Hidden
  26183. */
  26184. static _TextureLoaders: IInternalTextureLoader[];
  26185. /** Defines that alpha blending is disabled */
  26186. static readonly ALPHA_DISABLE: number;
  26187. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26188. static readonly ALPHA_ADD: number;
  26189. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26190. static readonly ALPHA_COMBINE: number;
  26191. /** Defines that alpha blending to DEST - SRC * DEST */
  26192. static readonly ALPHA_SUBTRACT: number;
  26193. /** Defines that alpha blending to SRC * DEST */
  26194. static readonly ALPHA_MULTIPLY: number;
  26195. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26196. static readonly ALPHA_MAXIMIZED: number;
  26197. /** Defines that alpha blending to SRC + DEST */
  26198. static readonly ALPHA_ONEONE: number;
  26199. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26200. static readonly ALPHA_PREMULTIPLIED: number;
  26201. /**
  26202. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26203. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26204. */
  26205. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26206. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26207. static readonly ALPHA_INTERPOLATE: number;
  26208. /**
  26209. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26210. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26211. */
  26212. static readonly ALPHA_SCREENMODE: number;
  26213. /** Defines that the ressource is not delayed*/
  26214. static readonly DELAYLOADSTATE_NONE: number;
  26215. /** Defines that the ressource was successfully delay loaded */
  26216. static readonly DELAYLOADSTATE_LOADED: number;
  26217. /** Defines that the ressource is currently delay loading */
  26218. static readonly DELAYLOADSTATE_LOADING: number;
  26219. /** Defines that the ressource is delayed and has not started loading */
  26220. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26221. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26222. static readonly NEVER: number;
  26223. /** 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 */
  26224. static readonly ALWAYS: number;
  26225. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26226. static readonly LESS: number;
  26227. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26228. static readonly EQUAL: number;
  26229. /** 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 */
  26230. static readonly LEQUAL: number;
  26231. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26232. static readonly GREATER: number;
  26233. /** 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 */
  26234. static readonly GEQUAL: number;
  26235. /** 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 */
  26236. static readonly NOTEQUAL: number;
  26237. /** Passed to stencilOperation to specify that stencil value must be kept */
  26238. static readonly KEEP: number;
  26239. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26240. static readonly REPLACE: number;
  26241. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26242. static readonly INCR: number;
  26243. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26244. static readonly DECR: number;
  26245. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26246. static readonly INVERT: number;
  26247. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26248. static readonly INCR_WRAP: number;
  26249. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26250. static readonly DECR_WRAP: number;
  26251. /** Texture is not repeating outside of 0..1 UVs */
  26252. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26253. /** Texture is repeating outside of 0..1 UVs */
  26254. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26255. /** Texture is repeating and mirrored */
  26256. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26257. /** ALPHA */
  26258. static readonly TEXTUREFORMAT_ALPHA: number;
  26259. /** LUMINANCE */
  26260. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26261. /** LUMINANCE_ALPHA */
  26262. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26263. /** RGB */
  26264. static readonly TEXTUREFORMAT_RGB: number;
  26265. /** RGBA */
  26266. static readonly TEXTUREFORMAT_RGBA: number;
  26267. /** RED */
  26268. static readonly TEXTUREFORMAT_RED: number;
  26269. /** RED (2nd reference) */
  26270. static readonly TEXTUREFORMAT_R: number;
  26271. /** RG */
  26272. static readonly TEXTUREFORMAT_RG: number;
  26273. /** RED_INTEGER */
  26274. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26275. /** RED_INTEGER (2nd reference) */
  26276. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26277. /** RG_INTEGER */
  26278. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26279. /** RGB_INTEGER */
  26280. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26281. /** RGBA_INTEGER */
  26282. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26283. /** UNSIGNED_BYTE */
  26284. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26285. /** UNSIGNED_BYTE (2nd reference) */
  26286. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26287. /** FLOAT */
  26288. static readonly TEXTURETYPE_FLOAT: number;
  26289. /** HALF_FLOAT */
  26290. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26291. /** BYTE */
  26292. static readonly TEXTURETYPE_BYTE: number;
  26293. /** SHORT */
  26294. static readonly TEXTURETYPE_SHORT: number;
  26295. /** UNSIGNED_SHORT */
  26296. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26297. /** INT */
  26298. static readonly TEXTURETYPE_INT: number;
  26299. /** UNSIGNED_INT */
  26300. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26301. /** UNSIGNED_SHORT_4_4_4_4 */
  26302. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26303. /** UNSIGNED_SHORT_5_5_5_1 */
  26304. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26305. /** UNSIGNED_SHORT_5_6_5 */
  26306. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26307. /** UNSIGNED_INT_2_10_10_10_REV */
  26308. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26309. /** UNSIGNED_INT_24_8 */
  26310. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26311. /** UNSIGNED_INT_10F_11F_11F_REV */
  26312. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26313. /** UNSIGNED_INT_5_9_9_9_REV */
  26314. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26315. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26316. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26317. /** nearest is mag = nearest and min = nearest and mip = linear */
  26318. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26319. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26320. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26321. /** Trilinear is mag = linear and min = linear and mip = linear */
  26322. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26323. /** nearest is mag = nearest and min = nearest and mip = linear */
  26324. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26325. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26326. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26327. /** Trilinear is mag = linear and min = linear and mip = linear */
  26328. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26329. /** mag = nearest and min = nearest and mip = nearest */
  26330. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26331. /** mag = nearest and min = linear and mip = nearest */
  26332. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26333. /** mag = nearest and min = linear and mip = linear */
  26334. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26335. /** mag = nearest and min = linear and mip = none */
  26336. static readonly TEXTURE_NEAREST_LINEAR: number;
  26337. /** mag = nearest and min = nearest and mip = none */
  26338. static readonly TEXTURE_NEAREST_NEAREST: number;
  26339. /** mag = linear and min = nearest and mip = nearest */
  26340. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26341. /** mag = linear and min = nearest and mip = linear */
  26342. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26343. /** mag = linear and min = linear and mip = none */
  26344. static readonly TEXTURE_LINEAR_LINEAR: number;
  26345. /** mag = linear and min = nearest and mip = none */
  26346. static readonly TEXTURE_LINEAR_NEAREST: number;
  26347. /** Explicit coordinates mode */
  26348. static readonly TEXTURE_EXPLICIT_MODE: number;
  26349. /** Spherical coordinates mode */
  26350. static readonly TEXTURE_SPHERICAL_MODE: number;
  26351. /** Planar coordinates mode */
  26352. static readonly TEXTURE_PLANAR_MODE: number;
  26353. /** Cubic coordinates mode */
  26354. static readonly TEXTURE_CUBIC_MODE: number;
  26355. /** Projection coordinates mode */
  26356. static readonly TEXTURE_PROJECTION_MODE: number;
  26357. /** Skybox coordinates mode */
  26358. static readonly TEXTURE_SKYBOX_MODE: number;
  26359. /** Inverse Cubic coordinates mode */
  26360. static readonly TEXTURE_INVCUBIC_MODE: number;
  26361. /** Equirectangular coordinates mode */
  26362. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26363. /** Equirectangular Fixed coordinates mode */
  26364. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26365. /** Equirectangular Fixed Mirrored coordinates mode */
  26366. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26367. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26368. static readonly SCALEMODE_FLOOR: number;
  26369. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26370. static readonly SCALEMODE_NEAREST: number;
  26371. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26372. static readonly SCALEMODE_CEILING: number;
  26373. /**
  26374. * Returns the current version of the framework
  26375. */
  26376. static readonly Version: string;
  26377. /**
  26378. * Returns a string describing the current engine
  26379. */
  26380. readonly description: string;
  26381. /**
  26382. * Gets or sets the epsilon value used by collision engine
  26383. */
  26384. static CollisionsEpsilon: number;
  26385. /**
  26386. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26387. */
  26388. static ShadersRepository: string;
  26389. /**
  26390. * Method called to create the default loading screen.
  26391. * This can be overriden in your own app.
  26392. * @param canvas The rendering canvas element
  26393. * @returns The loading screen
  26394. */
  26395. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26396. /**
  26397. * Method called to create the default rescale post process on each engine.
  26398. */
  26399. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26400. /**
  26401. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26402. */
  26403. forcePOTTextures: boolean;
  26404. /**
  26405. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26406. */
  26407. isFullscreen: boolean;
  26408. /**
  26409. * Gets a boolean indicating if the pointer is currently locked
  26410. */
  26411. isPointerLock: boolean;
  26412. /**
  26413. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26414. */
  26415. cullBackFaces: boolean;
  26416. /**
  26417. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26418. */
  26419. renderEvenInBackground: boolean;
  26420. /**
  26421. * Gets or sets a boolean indicating that cache can be kept between frames
  26422. */
  26423. preventCacheWipeBetweenFrames: boolean;
  26424. /**
  26425. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26426. **/
  26427. enableOfflineSupport: boolean;
  26428. /**
  26429. * 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)
  26430. **/
  26431. disableManifestCheck: boolean;
  26432. /**
  26433. * Gets the list of created scenes
  26434. */
  26435. scenes: Scene[];
  26436. /**
  26437. * Event raised when a new scene is created
  26438. */
  26439. onNewSceneAddedObservable: Observable<Scene>;
  26440. /**
  26441. * Gets the list of created postprocesses
  26442. */
  26443. postProcesses: PostProcess[];
  26444. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26445. validateShaderPrograms: boolean;
  26446. /**
  26447. * Observable event triggered each time the rendering canvas is resized
  26448. */
  26449. onResizeObservable: Observable<Engine>;
  26450. /**
  26451. * Observable event triggered each time the canvas loses focus
  26452. */
  26453. onCanvasBlurObservable: Observable<Engine>;
  26454. /**
  26455. * Observable event triggered each time the canvas gains focus
  26456. */
  26457. onCanvasFocusObservable: Observable<Engine>;
  26458. /**
  26459. * Observable event triggered each time the canvas receives pointerout event
  26460. */
  26461. onCanvasPointerOutObservable: Observable<PointerEvent>;
  26462. /**
  26463. * Observable event triggered before each texture is initialized
  26464. */
  26465. onBeforeTextureInitObservable: Observable<Texture>;
  26466. private _vrDisplay;
  26467. private _vrSupported;
  26468. private _oldSize;
  26469. private _oldHardwareScaleFactor;
  26470. private _vrExclusivePointerMode;
  26471. private _webVRInitPromise;
  26472. /**
  26473. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26474. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26475. */
  26476. readonly isInVRExclusivePointerMode: boolean;
  26477. /**
  26478. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  26479. */
  26480. disableUniformBuffers: boolean;
  26481. /** @hidden */
  26482. _uniformBuffers: UniformBuffer[];
  26483. /**
  26484. * Gets a boolean indicating that the engine supports uniform buffers
  26485. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26486. */
  26487. readonly supportsUniformBuffers: boolean;
  26488. /**
  26489. * Observable raised when the engine begins a new frame
  26490. */
  26491. onBeginFrameObservable: Observable<Engine>;
  26492. /**
  26493. * If set, will be used to request the next animation frame for the render loop
  26494. */
  26495. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  26496. /**
  26497. * Observable raised when the engine ends the current frame
  26498. */
  26499. onEndFrameObservable: Observable<Engine>;
  26500. /**
  26501. * Observable raised when the engine is about to compile a shader
  26502. */
  26503. onBeforeShaderCompilationObservable: Observable<Engine>;
  26504. /**
  26505. * Observable raised when the engine has jsut compiled a shader
  26506. */
  26507. onAfterShaderCompilationObservable: Observable<Engine>;
  26508. /** @hidden */
  26509. _gl: WebGLRenderingContext;
  26510. private _renderingCanvas;
  26511. private _windowIsBackground;
  26512. private _webGLVersion;
  26513. /**
  26514. * Gets a boolean indicating that only power of 2 textures are supported
  26515. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  26516. */
  26517. readonly needPOTTextures: boolean;
  26518. /** @hidden */
  26519. _badOS: boolean;
  26520. /** @hidden */
  26521. _badDesktopOS: boolean;
  26522. /**
  26523. * Gets or sets a value indicating if we want to disable texture binding optimization.
  26524. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  26525. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  26526. */
  26527. disableTextureBindingOptimization: boolean;
  26528. /**
  26529. * Gets the audio engine
  26530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26531. * @ignorenaming
  26532. */
  26533. static audioEngine: IAudioEngine;
  26534. /**
  26535. * Default AudioEngine factory responsible of creating the Audio Engine.
  26536. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  26537. */
  26538. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  26539. /**
  26540. * Default offline support factory responsible of creating a tool used to store data locally.
  26541. * By default, this will create a Database object if the workload has been embedded.
  26542. */
  26543. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  26544. private _onFocus;
  26545. private _onBlur;
  26546. private _onCanvasPointerOut;
  26547. private _onCanvasBlur;
  26548. private _onCanvasFocus;
  26549. private _onFullscreenChange;
  26550. private _onPointerLockChange;
  26551. private _onVRDisplayPointerRestricted;
  26552. private _onVRDisplayPointerUnrestricted;
  26553. private _onVrDisplayConnect;
  26554. private _onVrDisplayDisconnect;
  26555. private _onVrDisplayPresentChange;
  26556. /**
  26557. * Observable signaled when VR display mode changes
  26558. */
  26559. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26560. /**
  26561. * Observable signaled when VR request present is complete
  26562. */
  26563. onVRRequestPresentComplete: Observable<boolean>;
  26564. /**
  26565. * Observable signaled when VR request present starts
  26566. */
  26567. onVRRequestPresentStart: Observable<Engine>;
  26568. private _hardwareScalingLevel;
  26569. /** @hidden */
  26570. protected _caps: EngineCapabilities;
  26571. private _pointerLockRequested;
  26572. private _isStencilEnable;
  26573. private _colorWrite;
  26574. private _loadingScreen;
  26575. /** @hidden */
  26576. _drawCalls: PerfCounter;
  26577. /** @hidden */
  26578. _textureCollisions: PerfCounter;
  26579. private _glVersion;
  26580. private _glRenderer;
  26581. private _glVendor;
  26582. private _videoTextureSupported;
  26583. private _renderingQueueLaunched;
  26584. private _activeRenderLoops;
  26585. private _deterministicLockstep;
  26586. private _lockstepMaxSteps;
  26587. /**
  26588. * Observable signaled when a context lost event is raised
  26589. */
  26590. onContextLostObservable: Observable<Engine>;
  26591. /**
  26592. * Observable signaled when a context restored event is raised
  26593. */
  26594. onContextRestoredObservable: Observable<Engine>;
  26595. private _onContextLost;
  26596. private _onContextRestored;
  26597. private _contextWasLost;
  26598. private _doNotHandleContextLost;
  26599. /**
  26600. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  26601. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  26602. */
  26603. doNotHandleContextLost: boolean;
  26604. private _performanceMonitor;
  26605. private _fps;
  26606. private _deltaTime;
  26607. /**
  26608. * Turn this value on if you want to pause FPS computation when in background
  26609. */
  26610. disablePerformanceMonitorInBackground: boolean;
  26611. /**
  26612. * Gets the performance monitor attached to this engine
  26613. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  26614. */
  26615. readonly performanceMonitor: PerformanceMonitor;
  26616. /** @hidden */
  26617. protected _depthCullingState: _DepthCullingState;
  26618. /** @hidden */
  26619. protected _stencilState: _StencilState;
  26620. /** @hidden */
  26621. protected _alphaState: _AlphaState;
  26622. /** @hidden */
  26623. protected _alphaMode: number;
  26624. protected _internalTexturesCache: InternalTexture[];
  26625. /** @hidden */
  26626. protected _activeChannel: number;
  26627. private _currentTextureChannel;
  26628. /** @hidden */
  26629. protected _boundTexturesCache: {
  26630. [key: string]: Nullable<InternalTexture>;
  26631. };
  26632. /** @hidden */
  26633. protected _currentEffect: Nullable<Effect>;
  26634. /** @hidden */
  26635. protected _currentProgram: Nullable<WebGLProgram>;
  26636. private _compiledEffects;
  26637. private _vertexAttribArraysEnabled;
  26638. /** @hidden */
  26639. protected _cachedViewport: Nullable<Viewport>;
  26640. private _cachedVertexArrayObject;
  26641. /** @hidden */
  26642. protected _cachedVertexBuffers: any;
  26643. /** @hidden */
  26644. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  26645. /** @hidden */
  26646. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  26647. /** @hidden */
  26648. protected _currentRenderTarget: Nullable<InternalTexture>;
  26649. private _uintIndicesCurrentlySet;
  26650. private _currentBoundBuffer;
  26651. /** @hidden */
  26652. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  26653. private _currentBufferPointers;
  26654. private _currentInstanceLocations;
  26655. private _currentInstanceBuffers;
  26656. private _textureUnits;
  26657. private _firstBoundInternalTextureTracker;
  26658. private _lastBoundInternalTextureTracker;
  26659. private _workingCanvas;
  26660. private _workingContext;
  26661. private _rescalePostProcess;
  26662. private _dummyFramebuffer;
  26663. private _externalData;
  26664. private _bindedRenderFunction;
  26665. private _vaoRecordInProgress;
  26666. private _mustWipeVertexAttributes;
  26667. private _emptyTexture;
  26668. private _emptyCubeTexture;
  26669. private _emptyTexture3D;
  26670. /** @hidden */
  26671. _frameHandler: number;
  26672. private _nextFreeTextureSlots;
  26673. private _maxSimultaneousTextures;
  26674. private _activeRequests;
  26675. private _texturesSupported;
  26676. private _textureFormatInUse;
  26677. /**
  26678. * Gets the list of texture formats supported
  26679. */
  26680. readonly texturesSupported: Array<string>;
  26681. /**
  26682. * Gets the list of texture formats in use
  26683. */
  26684. readonly textureFormatInUse: Nullable<string>;
  26685. /**
  26686. * Gets the current viewport
  26687. */
  26688. readonly currentViewport: Nullable<Viewport>;
  26689. /**
  26690. * Gets the default empty texture
  26691. */
  26692. readonly emptyTexture: InternalTexture;
  26693. /**
  26694. * Gets the default empty 3D texture
  26695. */
  26696. readonly emptyTexture3D: InternalTexture;
  26697. /**
  26698. * Gets the default empty cube texture
  26699. */
  26700. readonly emptyCubeTexture: InternalTexture;
  26701. /**
  26702. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  26703. */
  26704. readonly premultipliedAlpha: boolean;
  26705. /**
  26706. * Creates a new engine
  26707. * @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
  26708. * @param antialias defines enable antialiasing (default: false)
  26709. * @param options defines further options to be sent to the getContext() function
  26710. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  26711. */
  26712. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  26713. private _disableTouchAction;
  26714. private _rebuildInternalTextures;
  26715. private _rebuildEffects;
  26716. /**
  26717. * Gets a boolean indicating if all created effects are ready
  26718. * @returns true if all effects are ready
  26719. */
  26720. areAllEffectsReady(): boolean;
  26721. private _rebuildBuffers;
  26722. private _initGLContext;
  26723. /**
  26724. * Gets version of the current webGL context
  26725. */
  26726. readonly webGLVersion: number;
  26727. /**
  26728. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  26729. */
  26730. readonly isStencilEnable: boolean;
  26731. private _prepareWorkingCanvas;
  26732. /**
  26733. * Reset the texture cache to empty state
  26734. */
  26735. resetTextureCache(): void;
  26736. /**
  26737. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  26738. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26739. * @returns true if engine is in deterministic lock step mode
  26740. */
  26741. isDeterministicLockStep(): boolean;
  26742. /**
  26743. * Gets the max steps when engine is running in deterministic lock step
  26744. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26745. * @returns the max steps
  26746. */
  26747. getLockstepMaxSteps(): number;
  26748. /**
  26749. * Gets an object containing information about the current webGL context
  26750. * @returns an object containing the vender, the renderer and the version of the current webGL context
  26751. */
  26752. getGlInfo(): {
  26753. vendor: string;
  26754. renderer: string;
  26755. version: string;
  26756. };
  26757. /**
  26758. * Gets current aspect ratio
  26759. * @param camera defines the camera to use to get the aspect ratio
  26760. * @param useScreen defines if screen size must be used (or the current render target if any)
  26761. * @returns a number defining the aspect ratio
  26762. */
  26763. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  26764. /**
  26765. * Gets current screen aspect ratio
  26766. * @returns a number defining the aspect ratio
  26767. */
  26768. getScreenAspectRatio(): number;
  26769. /**
  26770. * Gets the current render width
  26771. * @param useScreen defines if screen size must be used (or the current render target if any)
  26772. * @returns a number defining the current render width
  26773. */
  26774. getRenderWidth(useScreen?: boolean): number;
  26775. /**
  26776. * Gets the current render height
  26777. * @param useScreen defines if screen size must be used (or the current render target if any)
  26778. * @returns a number defining the current render height
  26779. */
  26780. getRenderHeight(useScreen?: boolean): number;
  26781. /**
  26782. * Gets the HTML canvas attached with the current webGL context
  26783. * @returns a HTML canvas
  26784. */
  26785. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  26786. /**
  26787. * Gets the client rect of the HTML canvas attached with the current webGL context
  26788. * @returns a client rectanglee
  26789. */
  26790. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  26791. /**
  26792. * Defines the hardware scaling level.
  26793. * By default the hardware scaling level is computed from the window device ratio.
  26794. * 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.
  26795. * @param level defines the level to use
  26796. */
  26797. setHardwareScalingLevel(level: number): void;
  26798. /**
  26799. * Gets the current hardware scaling level.
  26800. * By default the hardware scaling level is computed from the window device ratio.
  26801. * 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.
  26802. * @returns a number indicating the current hardware scaling level
  26803. */
  26804. getHardwareScalingLevel(): number;
  26805. /**
  26806. * Gets the list of loaded textures
  26807. * @returns an array containing all loaded textures
  26808. */
  26809. getLoadedTexturesCache(): InternalTexture[];
  26810. /**
  26811. * Gets the object containing all engine capabilities
  26812. * @returns the EngineCapabilities object
  26813. */
  26814. getCaps(): EngineCapabilities;
  26815. /**
  26816. * Gets the current depth function
  26817. * @returns a number defining the depth function
  26818. */
  26819. getDepthFunction(): Nullable<number>;
  26820. /**
  26821. * Sets the current depth function
  26822. * @param depthFunc defines the function to use
  26823. */
  26824. setDepthFunction(depthFunc: number): void;
  26825. /**
  26826. * Sets the current depth function to GREATER
  26827. */
  26828. setDepthFunctionToGreater(): void;
  26829. /**
  26830. * Sets the current depth function to GEQUAL
  26831. */
  26832. setDepthFunctionToGreaterOrEqual(): void;
  26833. /**
  26834. * Sets the current depth function to LESS
  26835. */
  26836. setDepthFunctionToLess(): void;
  26837. /**
  26838. * Sets the current depth function to LEQUAL
  26839. */
  26840. setDepthFunctionToLessOrEqual(): void;
  26841. /**
  26842. * Gets a boolean indicating if stencil buffer is enabled
  26843. * @returns the current stencil buffer state
  26844. */
  26845. getStencilBuffer(): boolean;
  26846. /**
  26847. * Enable or disable the stencil buffer
  26848. * @param enable defines if the stencil buffer must be enabled or disabled
  26849. */
  26850. setStencilBuffer(enable: boolean): void;
  26851. /**
  26852. * Gets the current stencil mask
  26853. * @returns a number defining the new stencil mask to use
  26854. */
  26855. getStencilMask(): number;
  26856. /**
  26857. * Sets the current stencil mask
  26858. * @param mask defines the new stencil mask to use
  26859. */
  26860. setStencilMask(mask: number): void;
  26861. /**
  26862. * Gets the current stencil function
  26863. * @returns a number defining the stencil function to use
  26864. */
  26865. getStencilFunction(): number;
  26866. /**
  26867. * Gets the current stencil reference value
  26868. * @returns a number defining the stencil reference value to use
  26869. */
  26870. getStencilFunctionReference(): number;
  26871. /**
  26872. * Gets the current stencil mask
  26873. * @returns a number defining the stencil mask to use
  26874. */
  26875. getStencilFunctionMask(): number;
  26876. /**
  26877. * Sets the current stencil function
  26878. * @param stencilFunc defines the new stencil function to use
  26879. */
  26880. setStencilFunction(stencilFunc: number): void;
  26881. /**
  26882. * Sets the current stencil reference
  26883. * @param reference defines the new stencil reference to use
  26884. */
  26885. setStencilFunctionReference(reference: number): void;
  26886. /**
  26887. * Sets the current stencil mask
  26888. * @param mask defines the new stencil mask to use
  26889. */
  26890. setStencilFunctionMask(mask: number): void;
  26891. /**
  26892. * Gets the current stencil operation when stencil fails
  26893. * @returns a number defining stencil operation to use when stencil fails
  26894. */
  26895. getStencilOperationFail(): number;
  26896. /**
  26897. * Gets the current stencil operation when depth fails
  26898. * @returns a number defining stencil operation to use when depth fails
  26899. */
  26900. getStencilOperationDepthFail(): number;
  26901. /**
  26902. * Gets the current stencil operation when stencil passes
  26903. * @returns a number defining stencil operation to use when stencil passes
  26904. */
  26905. getStencilOperationPass(): number;
  26906. /**
  26907. * Sets the stencil operation to use when stencil fails
  26908. * @param operation defines the stencil operation to use when stencil fails
  26909. */
  26910. setStencilOperationFail(operation: number): void;
  26911. /**
  26912. * Sets the stencil operation to use when depth fails
  26913. * @param operation defines the stencil operation to use when depth fails
  26914. */
  26915. setStencilOperationDepthFail(operation: number): void;
  26916. /**
  26917. * Sets the stencil operation to use when stencil passes
  26918. * @param operation defines the stencil operation to use when stencil passes
  26919. */
  26920. setStencilOperationPass(operation: number): void;
  26921. /**
  26922. * Sets a boolean indicating if the dithering state is enabled or disabled
  26923. * @param value defines the dithering state
  26924. */
  26925. setDitheringState(value: boolean): void;
  26926. /**
  26927. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  26928. * @param value defines the rasterizer state
  26929. */
  26930. setRasterizerState(value: boolean): void;
  26931. /**
  26932. * stop executing a render loop function and remove it from the execution array
  26933. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  26934. */
  26935. stopRenderLoop(renderFunction?: () => void): void;
  26936. /** @hidden */
  26937. _renderLoop(): void;
  26938. /**
  26939. * Register and execute a render loop. The engine can have more than one render function
  26940. * @param renderFunction defines the function to continuously execute
  26941. */
  26942. runRenderLoop(renderFunction: () => void): void;
  26943. /**
  26944. * Toggle full screen mode
  26945. * @param requestPointerLock defines if a pointer lock should be requested from the user
  26946. */
  26947. switchFullscreen(requestPointerLock: boolean): void;
  26948. /**
  26949. * Enters full screen mode
  26950. * @param requestPointerLock defines if a pointer lock should be requested from the user
  26951. */
  26952. enterFullscreen(requestPointerLock: boolean): void;
  26953. /**
  26954. * Exits full screen mode
  26955. */
  26956. exitFullscreen(): void;
  26957. /**
  26958. * Clear the current render buffer or the current render target (if any is set up)
  26959. * @param color defines the color to use
  26960. * @param backBuffer defines if the back buffer must be cleared
  26961. * @param depth defines if the depth buffer must be cleared
  26962. * @param stencil defines if the stencil buffer must be cleared
  26963. */
  26964. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  26965. /**
  26966. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  26967. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  26968. * @param y defines the y-coordinate of the corner of the clear rectangle
  26969. * @param width defines the width of the clear rectangle
  26970. * @param height defines the height of the clear rectangle
  26971. * @param clearColor defines the clear color
  26972. */
  26973. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  26974. /**
  26975. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  26976. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  26977. * @param y defines the y-coordinate of the corner of the clear rectangle
  26978. * @param width defines the width of the clear rectangle
  26979. * @param height defines the height of the clear rectangle
  26980. */
  26981. enableScissor(x: number, y: number, width: number, height: number): void;
  26982. /**
  26983. * Disable previously set scissor test rectangle
  26984. */
  26985. disableScissor(): void;
  26986. private _viewportCached;
  26987. /** @hidden */
  26988. _viewport(x: number, y: number, width: number, height: number): void;
  26989. /**
  26990. * Set the WebGL's viewport
  26991. * @param viewport defines the viewport element to be used
  26992. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  26993. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  26994. */
  26995. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  26996. /**
  26997. * Directly set the WebGL Viewport
  26998. * @param x defines the x coordinate of the viewport (in screen space)
  26999. * @param y defines the y coordinate of the viewport (in screen space)
  27000. * @param width defines the width of the viewport (in screen space)
  27001. * @param height defines the height of the viewport (in screen space)
  27002. * @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
  27003. */
  27004. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27005. /**
  27006. * Begin a new frame
  27007. */
  27008. beginFrame(): void;
  27009. /**
  27010. * Enf the current frame
  27011. */
  27012. endFrame(): void;
  27013. /**
  27014. * Resize the view according to the canvas' size
  27015. */
  27016. resize(): void;
  27017. /**
  27018. * Force a specific size of the canvas
  27019. * @param width defines the new canvas' width
  27020. * @param height defines the new canvas' height
  27021. */
  27022. setSize(width: number, height: number): void;
  27023. /**
  27024. * Gets a boolean indicating if a webVR device was detected
  27025. * @returns true if a webVR device was detected
  27026. */
  27027. isVRDevicePresent(): boolean;
  27028. /**
  27029. * Gets the current webVR device
  27030. * @returns the current webVR device (or null)
  27031. */
  27032. getVRDevice(): any;
  27033. /**
  27034. * Initializes a webVR display and starts listening to display change events
  27035. * The onVRDisplayChangedObservable will be notified upon these changes
  27036. * @returns The onVRDisplayChangedObservable
  27037. */
  27038. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27039. /**
  27040. * Initializes a webVR display and starts listening to display change events
  27041. * The onVRDisplayChangedObservable will be notified upon these changes
  27042. * @returns A promise containing a VRDisplay and if vr is supported
  27043. */
  27044. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27045. /**
  27046. * Call this function to switch to webVR mode
  27047. * Will do nothing if webVR is not supported or if there is no webVR device
  27048. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27049. */
  27050. enableVR(): void;
  27051. /**
  27052. * Call this function to leave webVR mode
  27053. * Will do nothing if webVR is not supported or if there is no webVR device
  27054. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27055. */
  27056. disableVR(): void;
  27057. private _onVRFullScreenTriggered;
  27058. private _getVRDisplaysAsync;
  27059. /**
  27060. * Binds the frame buffer to the specified texture.
  27061. * @param texture The texture to render to or null for the default canvas
  27062. * @param faceIndex The face of the texture to render to in case of cube texture
  27063. * @param requiredWidth The width of the target to render to
  27064. * @param requiredHeight The height of the target to render to
  27065. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27066. * @param depthStencilTexture The depth stencil texture to use to render
  27067. * @param lodLevel defines le lod level to bind to the frame buffer
  27068. */
  27069. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27070. private bindUnboundFramebuffer;
  27071. /**
  27072. * Unbind the current render target texture from the webGL context
  27073. * @param texture defines the render target texture to unbind
  27074. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27075. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27076. */
  27077. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27078. /**
  27079. * Unbind a list of render target textures from the webGL context
  27080. * This is used only when drawBuffer extension or webGL2 are active
  27081. * @param textures defines the render target textures to unbind
  27082. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27083. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27084. */
  27085. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27086. /**
  27087. * Force the mipmap generation for the given render target texture
  27088. * @param texture defines the render target texture to use
  27089. */
  27090. generateMipMapsForCubemap(texture: InternalTexture): void;
  27091. /**
  27092. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27093. */
  27094. flushFramebuffer(): void;
  27095. /**
  27096. * Unbind the current render target and bind the default framebuffer
  27097. */
  27098. restoreDefaultFramebuffer(): void;
  27099. /**
  27100. * Create an uniform buffer
  27101. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27102. * @param elements defines the content of the uniform buffer
  27103. * @returns the webGL uniform buffer
  27104. */
  27105. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27106. /**
  27107. * Create a dynamic uniform buffer
  27108. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27109. * @param elements defines the content of the uniform buffer
  27110. * @returns the webGL uniform buffer
  27111. */
  27112. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27113. /**
  27114. * Update an existing uniform buffer
  27115. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27116. * @param uniformBuffer defines the target uniform buffer
  27117. * @param elements defines the content to update
  27118. * @param offset defines the offset in the uniform buffer where update should start
  27119. * @param count defines the size of the data to update
  27120. */
  27121. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27122. private _resetVertexBufferBinding;
  27123. /**
  27124. * Creates a vertex buffer
  27125. * @param data the data for the vertex buffer
  27126. * @returns the new WebGL static buffer
  27127. */
  27128. createVertexBuffer(data: DataArray): WebGLBuffer;
  27129. /**
  27130. * Creates a dynamic vertex buffer
  27131. * @param data the data for the dynamic vertex buffer
  27132. * @returns the new WebGL dynamic buffer
  27133. */
  27134. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27135. /**
  27136. * Update a dynamic index buffer
  27137. * @param indexBuffer defines the target index buffer
  27138. * @param indices defines the data to update
  27139. * @param offset defines the offset in the target index buffer where update should start
  27140. */
  27141. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27142. /**
  27143. * Updates a dynamic vertex buffer.
  27144. * @param vertexBuffer the vertex buffer to update
  27145. * @param data the data used to update the vertex buffer
  27146. * @param byteOffset the byte offset of the data
  27147. * @param byteLength the byte length of the data
  27148. */
  27149. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27150. private _resetIndexBufferBinding;
  27151. /**
  27152. * Creates a new index buffer
  27153. * @param indices defines the content of the index buffer
  27154. * @param updatable defines if the index buffer must be updatable
  27155. * @returns a new webGL buffer
  27156. */
  27157. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27158. /**
  27159. * Bind a webGL buffer to the webGL context
  27160. * @param buffer defines the buffer to bind
  27161. */
  27162. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27163. /**
  27164. * Bind an uniform buffer to the current webGL context
  27165. * @param buffer defines the buffer to bind
  27166. */
  27167. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27168. /**
  27169. * Bind a buffer to the current webGL context at a given location
  27170. * @param buffer defines the buffer to bind
  27171. * @param location defines the index where to bind the buffer
  27172. */
  27173. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27174. /**
  27175. * Bind a specific block at a given index in a specific shader program
  27176. * @param shaderProgram defines the shader program
  27177. * @param blockName defines the block name
  27178. * @param index defines the index where to bind the block
  27179. */
  27180. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27181. private bindIndexBuffer;
  27182. private bindBuffer;
  27183. /**
  27184. * update the bound buffer with the given data
  27185. * @param data defines the data to update
  27186. */
  27187. updateArrayBuffer(data: Float32Array): void;
  27188. private _vertexAttribPointer;
  27189. private _bindIndexBufferWithCache;
  27190. private _bindVertexBuffersAttributes;
  27191. /**
  27192. * Records a vertex array object
  27193. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27194. * @param vertexBuffers defines the list of vertex buffers to store
  27195. * @param indexBuffer defines the index buffer to store
  27196. * @param effect defines the effect to store
  27197. * @returns the new vertex array object
  27198. */
  27199. recordVertexArrayObject(vertexBuffers: {
  27200. [key: string]: VertexBuffer;
  27201. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27202. /**
  27203. * Bind a specific vertex array object
  27204. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27205. * @param vertexArrayObject defines the vertex array object to bind
  27206. * @param indexBuffer defines the index buffer to bind
  27207. */
  27208. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27209. /**
  27210. * Bind webGl buffers directly to the webGL context
  27211. * @param vertexBuffer defines the vertex buffer to bind
  27212. * @param indexBuffer defines the index buffer to bind
  27213. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27214. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27215. * @param effect defines the effect associated with the vertex buffer
  27216. */
  27217. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27218. private _unbindVertexArrayObject;
  27219. /**
  27220. * Bind a list of vertex buffers to the webGL context
  27221. * @param vertexBuffers defines the list of vertex buffers to bind
  27222. * @param indexBuffer defines the index buffer to bind
  27223. * @param effect defines the effect associated with the vertex buffers
  27224. */
  27225. bindBuffers(vertexBuffers: {
  27226. [key: string]: Nullable<VertexBuffer>;
  27227. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27228. /**
  27229. * Unbind all instance attributes
  27230. */
  27231. unbindInstanceAttributes(): void;
  27232. /**
  27233. * Release and free the memory of a vertex array object
  27234. * @param vao defines the vertex array object to delete
  27235. */
  27236. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27237. /** @hidden */
  27238. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27239. /**
  27240. * Creates a webGL buffer to use with instanciation
  27241. * @param capacity defines the size of the buffer
  27242. * @returns the webGL buffer
  27243. */
  27244. createInstancesBuffer(capacity: number): WebGLBuffer;
  27245. /**
  27246. * Delete a webGL buffer used with instanciation
  27247. * @param buffer defines the webGL buffer to delete
  27248. */
  27249. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27250. /**
  27251. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27252. * @param instancesBuffer defines the webGL buffer to update and bind
  27253. * @param data defines the data to store in the buffer
  27254. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27255. */
  27256. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27257. /**
  27258. * Apply all cached states (depth, culling, stencil and alpha)
  27259. */
  27260. applyStates(): void;
  27261. /**
  27262. * Send a draw order
  27263. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27264. * @param indexStart defines the starting index
  27265. * @param indexCount defines the number of index to draw
  27266. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27267. */
  27268. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27269. /**
  27270. * Draw a list of points
  27271. * @param verticesStart defines the index of first vertex to draw
  27272. * @param verticesCount defines the count of vertices to draw
  27273. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27274. */
  27275. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27276. /**
  27277. * Draw a list of unindexed primitives
  27278. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27279. * @param verticesStart defines the index of first vertex to draw
  27280. * @param verticesCount defines the count of vertices to draw
  27281. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27282. */
  27283. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27284. /**
  27285. * Draw a list of indexed primitives
  27286. * @param fillMode defines the primitive to use
  27287. * @param indexStart defines the starting index
  27288. * @param indexCount defines the number of index to draw
  27289. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27290. */
  27291. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27292. /**
  27293. * Draw a list of unindexed primitives
  27294. * @param fillMode defines the primitive to use
  27295. * @param verticesStart defines the index of first vertex to draw
  27296. * @param verticesCount defines the count of vertices to draw
  27297. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27298. */
  27299. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27300. private _drawMode;
  27301. /** @hidden */
  27302. _releaseEffect(effect: Effect): void;
  27303. /** @hidden */
  27304. _deleteProgram(program: WebGLProgram): void;
  27305. /**
  27306. * Create a new effect (used to store vertex/fragment shaders)
  27307. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27308. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27309. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27310. * @param samplers defines an array of string used to represent textures
  27311. * @param defines defines the string containing the defines to use to compile the shaders
  27312. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27313. * @param onCompiled defines a function to call when the effect creation is successful
  27314. * @param onError defines a function to call when the effect creation has failed
  27315. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27316. * @returns the new Effect
  27317. */
  27318. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  27319. private _compileShader;
  27320. private _compileRawShader;
  27321. /**
  27322. * Directly creates a webGL program
  27323. * @param vertexCode defines the vertex shader code to use
  27324. * @param fragmentCode defines the fragment shader code to use
  27325. * @param context defines the webGL context to use (if not set, the current one will be used)
  27326. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27327. * @returns the new webGL program
  27328. */
  27329. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27330. /**
  27331. * Creates a webGL program
  27332. * @param vertexCode defines the vertex shader code to use
  27333. * @param fragmentCode defines the fragment shader code to use
  27334. * @param defines defines the string containing the defines to use to compile the shaders
  27335. * @param context defines the webGL context to use (if not set, the current one will be used)
  27336. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27337. * @returns the new webGL program
  27338. */
  27339. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27340. private _createShaderProgram;
  27341. private _finalizeProgram;
  27342. /** @hidden */
  27343. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  27344. /** @hidden */
  27345. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  27346. /**
  27347. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27348. * @param shaderProgram defines the webGL program to use
  27349. * @param uniformsNames defines the list of uniform names
  27350. * @returns an array of webGL uniform locations
  27351. */
  27352. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27353. /**
  27354. * Gets the lsit of active attributes for a given webGL program
  27355. * @param shaderProgram defines the webGL program to use
  27356. * @param attributesNames defines the list of attribute names to get
  27357. * @returns an array of indices indicating the offset of each attribute
  27358. */
  27359. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  27360. /**
  27361. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27362. * @param effect defines the effect to activate
  27363. */
  27364. enableEffect(effect: Nullable<Effect>): void;
  27365. /**
  27366. * Set the value of an uniform to an array of int32
  27367. * @param uniform defines the webGL uniform location where to store the value
  27368. * @param array defines the array of int32 to store
  27369. */
  27370. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27371. /**
  27372. * Set the value of an uniform to an array of int32 (stored as vec2)
  27373. * @param uniform defines the webGL uniform location where to store the value
  27374. * @param array defines the array of int32 to store
  27375. */
  27376. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27377. /**
  27378. * Set the value of an uniform to an array of int32 (stored as vec3)
  27379. * @param uniform defines the webGL uniform location where to store the value
  27380. * @param array defines the array of int32 to store
  27381. */
  27382. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27383. /**
  27384. * Set the value of an uniform to an array of int32 (stored as vec4)
  27385. * @param uniform defines the webGL uniform location where to store the value
  27386. * @param array defines the array of int32 to store
  27387. */
  27388. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27389. /**
  27390. * Set the value of an uniform to an array of float32
  27391. * @param uniform defines the webGL uniform location where to store the value
  27392. * @param array defines the array of float32 to store
  27393. */
  27394. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27395. /**
  27396. * Set the value of an uniform to an array of float32 (stored as vec2)
  27397. * @param uniform defines the webGL uniform location where to store the value
  27398. * @param array defines the array of float32 to store
  27399. */
  27400. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27401. /**
  27402. * Set the value of an uniform to an array of float32 (stored as vec3)
  27403. * @param uniform defines the webGL uniform location where to store the value
  27404. * @param array defines the array of float32 to store
  27405. */
  27406. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27407. /**
  27408. * Set the value of an uniform to an array of float32 (stored as vec4)
  27409. * @param uniform defines the webGL uniform location where to store the value
  27410. * @param array defines the array of float32 to store
  27411. */
  27412. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27413. /**
  27414. * Set the value of an uniform to an array of number
  27415. * @param uniform defines the webGL uniform location where to store the value
  27416. * @param array defines the array of number to store
  27417. */
  27418. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27419. /**
  27420. * Set the value of an uniform to an array of number (stored as vec2)
  27421. * @param uniform defines the webGL uniform location where to store the value
  27422. * @param array defines the array of number to store
  27423. */
  27424. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27425. /**
  27426. * Set the value of an uniform to an array of number (stored as vec3)
  27427. * @param uniform defines the webGL uniform location where to store the value
  27428. * @param array defines the array of number to store
  27429. */
  27430. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27431. /**
  27432. * Set the value of an uniform to an array of number (stored as vec4)
  27433. * @param uniform defines the webGL uniform location where to store the value
  27434. * @param array defines the array of number to store
  27435. */
  27436. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27437. /**
  27438. * Set the value of an uniform to an array of float32 (stored as matrices)
  27439. * @param uniform defines the webGL uniform location where to store the value
  27440. * @param matrices defines the array of float32 to store
  27441. */
  27442. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27443. /**
  27444. * Set the value of an uniform to a matrix
  27445. * @param uniform defines the webGL uniform location where to store the value
  27446. * @param matrix defines the matrix to store
  27447. */
  27448. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27449. /**
  27450. * Set the value of an uniform to a matrix (3x3)
  27451. * @param uniform defines the webGL uniform location where to store the value
  27452. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27453. */
  27454. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27455. /**
  27456. * Set the value of an uniform to a matrix (2x2)
  27457. * @param uniform defines the webGL uniform location where to store the value
  27458. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27459. */
  27460. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27461. /**
  27462. * Set the value of an uniform to a number (int)
  27463. * @param uniform defines the webGL uniform location where to store the value
  27464. * @param value defines the int number to store
  27465. */
  27466. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27467. /**
  27468. * Set the value of an uniform to a number (float)
  27469. * @param uniform defines the webGL uniform location where to store the value
  27470. * @param value defines the float number to store
  27471. */
  27472. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27473. /**
  27474. * Set the value of an uniform to a vec2
  27475. * @param uniform defines the webGL uniform location where to store the value
  27476. * @param x defines the 1st component of the value
  27477. * @param y defines the 2nd component of the value
  27478. */
  27479. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27480. /**
  27481. * Set the value of an uniform to a vec3
  27482. * @param uniform defines the webGL uniform location where to store the value
  27483. * @param x defines the 1st component of the value
  27484. * @param y defines the 2nd component of the value
  27485. * @param z defines the 3rd component of the value
  27486. */
  27487. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27488. /**
  27489. * Set the value of an uniform to a boolean
  27490. * @param uniform defines the webGL uniform location where to store the value
  27491. * @param bool defines the boolean to store
  27492. */
  27493. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  27494. /**
  27495. * Set the value of an uniform to a vec4
  27496. * @param uniform defines the webGL uniform location where to store the value
  27497. * @param x defines the 1st component of the value
  27498. * @param y defines the 2nd component of the value
  27499. * @param z defines the 3rd component of the value
  27500. * @param w defines the 4th component of the value
  27501. */
  27502. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  27503. /**
  27504. * Set the value of an uniform to a Color3
  27505. * @param uniform defines the webGL uniform location where to store the value
  27506. * @param color3 defines the color to store
  27507. */
  27508. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  27509. /**
  27510. * Set the value of an uniform to a Color3 and an alpha value
  27511. * @param uniform defines the webGL uniform location where to store the value
  27512. * @param color3 defines the color to store
  27513. * @param alpha defines the alpha component to store
  27514. */
  27515. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  27516. /**
  27517. * Sets a Color4 on a uniform variable
  27518. * @param uniform defines the uniform location
  27519. * @param color4 defines the value to be set
  27520. */
  27521. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  27522. /**
  27523. * Set various states to the webGL context
  27524. * @param culling defines backface culling state
  27525. * @param zOffset defines the value to apply to zOffset (0 by default)
  27526. * @param force defines if states must be applied even if cache is up to date
  27527. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  27528. */
  27529. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  27530. /**
  27531. * Set the z offset to apply to current rendering
  27532. * @param value defines the offset to apply
  27533. */
  27534. setZOffset(value: number): void;
  27535. /**
  27536. * Gets the current value of the zOffset
  27537. * @returns the current zOffset state
  27538. */
  27539. getZOffset(): number;
  27540. /**
  27541. * Enable or disable depth buffering
  27542. * @param enable defines the state to set
  27543. */
  27544. setDepthBuffer(enable: boolean): void;
  27545. /**
  27546. * Gets a boolean indicating if depth writing is enabled
  27547. * @returns the current depth writing state
  27548. */
  27549. getDepthWrite(): boolean;
  27550. /**
  27551. * Enable or disable depth writing
  27552. * @param enable defines the state to set
  27553. */
  27554. setDepthWrite(enable: boolean): void;
  27555. /**
  27556. * Enable or disable color writing
  27557. * @param enable defines the state to set
  27558. */
  27559. setColorWrite(enable: boolean): void;
  27560. /**
  27561. * Gets a boolean indicating if color writing is enabled
  27562. * @returns the current color writing state
  27563. */
  27564. getColorWrite(): boolean;
  27565. /**
  27566. * Sets alpha constants used by some alpha blending modes
  27567. * @param r defines the red component
  27568. * @param g defines the green component
  27569. * @param b defines the blue component
  27570. * @param a defines the alpha component
  27571. */
  27572. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  27573. /**
  27574. * Sets the current alpha mode
  27575. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  27576. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  27577. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27578. */
  27579. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  27580. /**
  27581. * Gets the current alpha mode
  27582. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27583. * @returns the current alpha mode
  27584. */
  27585. getAlphaMode(): number;
  27586. /**
  27587. * Clears the list of texture accessible through engine.
  27588. * This can help preventing texture load conflict due to name collision.
  27589. */
  27590. clearInternalTexturesCache(): void;
  27591. /**
  27592. * Force the entire cache to be cleared
  27593. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  27594. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  27595. */
  27596. wipeCaches(bruteForce?: boolean): void;
  27597. /**
  27598. * Set the compressed texture format to use, based on the formats you have, and the formats
  27599. * supported by the hardware / browser.
  27600. *
  27601. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  27602. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  27603. * to API arguments needed to compressed textures. This puts the burden on the container
  27604. * generator to house the arcane code for determining these for current & future formats.
  27605. *
  27606. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27607. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27608. *
  27609. * Note: The result of this call is not taken into account when a texture is base64.
  27610. *
  27611. * @param formatsAvailable defines the list of those format families you have created
  27612. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  27613. *
  27614. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  27615. * @returns The extension selected.
  27616. */
  27617. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  27618. private _getSamplingParameters;
  27619. private _partialLoadImg;
  27620. private _cascadeLoadImgs;
  27621. /** @hidden */
  27622. _createTexture(): WebGLTexture;
  27623. /**
  27624. * Usually called from Texture.ts.
  27625. * Passed information to create a WebGLTexture
  27626. * @param urlArg defines a value which contains one of the following:
  27627. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  27628. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  27629. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  27630. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  27631. * @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)
  27632. * @param scene needed for loading to the correct scene
  27633. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  27634. * @param onLoad optional callback to be called upon successful completion
  27635. * @param onError optional callback to be called upon failure
  27636. * @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
  27637. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  27638. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  27639. * @param forcedExtension defines the extension to use to pick the right loader
  27640. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  27641. * @returns a InternalTexture for assignment back into BABYLON.Texture
  27642. */
  27643. 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;
  27644. private _rescaleTexture;
  27645. /**
  27646. * Update a raw texture
  27647. * @param texture defines the texture to update
  27648. * @param data defines the data to store in the texture
  27649. * @param format defines the format of the data
  27650. * @param invertY defines if data must be stored with Y axis inverted
  27651. * @param compression defines the compression used (null by default)
  27652. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27653. */
  27654. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  27655. /**
  27656. * Creates a raw texture
  27657. * @param data defines the data to store in the texture
  27658. * @param width defines the width of the texture
  27659. * @param height defines the height of the texture
  27660. * @param format defines the format of the data
  27661. * @param generateMipMaps defines if the engine should generate the mip levels
  27662. * @param invertY defines if data must be stored with Y axis inverted
  27663. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27664. * @param compression defines the compression used (null by default)
  27665. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27666. * @returns the raw texture inside an InternalTexture
  27667. */
  27668. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  27669. private _unpackFlipYCached;
  27670. /**
  27671. * In case you are sharing the context with other applications, it might
  27672. * be interested to not cache the unpack flip y state to ensure a consistent
  27673. * value would be set.
  27674. */
  27675. enableUnpackFlipYCached: boolean;
  27676. /** @hidden */
  27677. _unpackFlipY(value: boolean): void;
  27678. /** @hidden */
  27679. _getUnpackAlignement(): number;
  27680. /**
  27681. * Creates a dynamic texture
  27682. * @param width defines the width of the texture
  27683. * @param height defines the height of the texture
  27684. * @param generateMipMaps defines if the engine should generate the mip levels
  27685. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27686. * @returns the dynamic texture inside an InternalTexture
  27687. */
  27688. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  27689. /**
  27690. * Update the sampling mode of a given texture
  27691. * @param samplingMode defines the required sampling mode
  27692. * @param texture defines the texture to update
  27693. */
  27694. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  27695. /**
  27696. * Update the content of a dynamic texture
  27697. * @param texture defines the texture to update
  27698. * @param canvas defines the canvas containing the source
  27699. * @param invertY defines if data must be stored with Y axis inverted
  27700. * @param premulAlpha defines if alpha is stored as premultiplied
  27701. * @param format defines the format of the data
  27702. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  27703. */
  27704. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  27705. /**
  27706. * Update a video texture
  27707. * @param texture defines the texture to update
  27708. * @param video defines the video element to use
  27709. * @param invertY defines if data must be stored with Y axis inverted
  27710. */
  27711. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  27712. /**
  27713. * Updates a depth texture Comparison Mode and Function.
  27714. * If the comparison Function is equal to 0, the mode will be set to none.
  27715. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  27716. * @param texture The texture to set the comparison function for
  27717. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  27718. */
  27719. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  27720. private _setupDepthStencilTexture;
  27721. /**
  27722. * Creates a depth stencil texture.
  27723. * This is only available in WebGL 2 or with the depth texture extension available.
  27724. * @param size The size of face edge in the texture.
  27725. * @param options The options defining the texture.
  27726. * @returns The texture
  27727. */
  27728. createDepthStencilTexture(size: number | {
  27729. width: number;
  27730. height: number;
  27731. }, options: DepthTextureCreationOptions): InternalTexture;
  27732. /**
  27733. * Creates a depth stencil texture.
  27734. * This is only available in WebGL 2 or with the depth texture extension available.
  27735. * @param size The size of face edge in the texture.
  27736. * @param options The options defining the texture.
  27737. * @returns The texture
  27738. */
  27739. private _createDepthStencilTexture;
  27740. /**
  27741. * Creates a depth stencil cube texture.
  27742. * This is only available in WebGL 2.
  27743. * @param size The size of face edge in the cube texture.
  27744. * @param options The options defining the cube texture.
  27745. * @returns The cube texture
  27746. */
  27747. private _createDepthStencilCubeTexture;
  27748. /**
  27749. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  27750. * @param renderTarget The render target to set the frame buffer for
  27751. */
  27752. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  27753. /**
  27754. * Creates a new render target texture
  27755. * @param size defines the size of the texture
  27756. * @param options defines the options used to create the texture
  27757. * @returns a new render target texture stored in an InternalTexture
  27758. */
  27759. createRenderTargetTexture(size: number | {
  27760. width: number;
  27761. height: number;
  27762. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  27763. /**
  27764. * Create a multi render target texture
  27765. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  27766. * @param size defines the size of the texture
  27767. * @param options defines the creation options
  27768. * @returns the cube texture as an InternalTexture
  27769. */
  27770. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  27771. private _setupFramebufferDepthAttachments;
  27772. /**
  27773. * Updates the sample count of a render target texture
  27774. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  27775. * @param texture defines the texture to update
  27776. * @param samples defines the sample count to set
  27777. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  27778. */
  27779. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  27780. /**
  27781. * Update the sample count for a given multiple render target texture
  27782. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  27783. * @param textures defines the textures to update
  27784. * @param samples defines the sample count to set
  27785. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  27786. */
  27787. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  27788. /** @hidden */
  27789. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27790. /** @hidden */
  27791. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27792. /** @hidden */
  27793. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27794. /** @hidden */
  27795. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  27796. /**
  27797. * Creates a new render target cube texture
  27798. * @param size defines the size of the texture
  27799. * @param options defines the options used to create the texture
  27800. * @returns a new render target cube texture stored in an InternalTexture
  27801. */
  27802. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  27803. /**
  27804. * Creates a cube texture
  27805. * @param rootUrl defines the url where the files to load is located
  27806. * @param scene defines the current scene
  27807. * @param files defines the list of files to load (1 per face)
  27808. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  27809. * @param onLoad defines an optional callback raised when the texture is loaded
  27810. * @param onError defines an optional callback raised if there is an issue to load the texture
  27811. * @param format defines the format of the data
  27812. * @param forcedExtension defines the extension to use to pick the right loader
  27813. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  27814. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  27815. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  27816. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  27817. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  27818. * @returns the cube texture as an InternalTexture
  27819. */
  27820. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  27821. /**
  27822. * @hidden
  27823. */
  27824. _setCubeMapTextureParams(loadMipmap: boolean): void;
  27825. /**
  27826. * Update a raw cube texture
  27827. * @param texture defines the texture to udpdate
  27828. * @param data defines the data to store
  27829. * @param format defines the data format
  27830. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27831. * @param invertY defines if data must be stored with Y axis inverted
  27832. * @param compression defines the compression used (null by default)
  27833. * @param level defines which level of the texture to update
  27834. */
  27835. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  27836. /**
  27837. * Creates a new raw cube texture
  27838. * @param data defines the array of data to use to create each face
  27839. * @param size defines the size of the textures
  27840. * @param format defines the format of the data
  27841. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  27842. * @param generateMipMaps defines if the engine should generate the mip levels
  27843. * @param invertY defines if data must be stored with Y axis inverted
  27844. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27845. * @param compression defines the compression used (null by default)
  27846. * @returns the cube texture as an InternalTexture
  27847. */
  27848. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  27849. /**
  27850. * Creates a new raw cube texture from a specified url
  27851. * @param url defines the url where the data is located
  27852. * @param scene defines the current scene
  27853. * @param size defines the size of the textures
  27854. * @param format defines the format of the data
  27855. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  27856. * @param noMipmap defines if the engine should avoid generating the mip levels
  27857. * @param callback defines a callback used to extract texture data from loaded data
  27858. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  27859. * @param onLoad defines a callback called when texture is loaded
  27860. * @param onError defines a callback called if there is an error
  27861. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27862. * @param invertY defines if data must be stored with Y axis inverted
  27863. * @returns the cube texture as an InternalTexture
  27864. */
  27865. 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;
  27866. /**
  27867. * Update a raw 3D texture
  27868. * @param texture defines the texture to update
  27869. * @param data defines the data to store
  27870. * @param format defines the data format
  27871. * @param invertY defines if data must be stored with Y axis inverted
  27872. * @param compression defines the used compression (can be null)
  27873. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  27874. */
  27875. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  27876. /**
  27877. * Creates a new raw 3D texture
  27878. * @param data defines the data used to create the texture
  27879. * @param width defines the width of the texture
  27880. * @param height defines the height of the texture
  27881. * @param depth defines the depth of the texture
  27882. * @param format defines the format of the texture
  27883. * @param generateMipMaps defines if the engine must generate mip levels
  27884. * @param invertY defines if data must be stored with Y axis inverted
  27885. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27886. * @param compression defines the compressed used (can be null)
  27887. * @param textureType defines the compressed used (can be null)
  27888. * @returns a new raw 3D texture (stored in an InternalTexture)
  27889. */
  27890. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  27891. private _prepareWebGLTextureContinuation;
  27892. private _prepareWebGLTexture;
  27893. private _convertRGBtoRGBATextureData;
  27894. /** @hidden */
  27895. _releaseFramebufferObjects(texture: InternalTexture): void;
  27896. /** @hidden */
  27897. _releaseTexture(texture: InternalTexture): void;
  27898. private setProgram;
  27899. private _boundUniforms;
  27900. /**
  27901. * Binds an effect to the webGL context
  27902. * @param effect defines the effect to bind
  27903. */
  27904. bindSamplers(effect: Effect): void;
  27905. private _moveBoundTextureOnTop;
  27906. private _getCorrectTextureChannel;
  27907. private _linkTrackers;
  27908. private _removeDesignatedSlot;
  27909. private _activateCurrentTexture;
  27910. /** @hidden */
  27911. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  27912. /** @hidden */
  27913. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  27914. /**
  27915. * Sets a texture to the webGL context from a postprocess
  27916. * @param channel defines the channel to use
  27917. * @param postProcess defines the source postprocess
  27918. */
  27919. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  27920. /**
  27921. * Binds the output of the passed in post process to the texture channel specified
  27922. * @param channel The channel the texture should be bound to
  27923. * @param postProcess The post process which's output should be bound
  27924. */
  27925. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  27926. /**
  27927. * Unbind all textures from the webGL context
  27928. */
  27929. unbindAllTextures(): void;
  27930. /**
  27931. * Sets a texture to the according uniform.
  27932. * @param channel The texture channel
  27933. * @param uniform The uniform to set
  27934. * @param texture The texture to apply
  27935. */
  27936. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  27937. /**
  27938. * Sets a depth stencil texture from a render target to the according uniform.
  27939. * @param channel The texture channel
  27940. * @param uniform The uniform to set
  27941. * @param texture The render target texture containing the depth stencil texture to apply
  27942. */
  27943. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  27944. private _bindSamplerUniformToChannel;
  27945. private _getTextureWrapMode;
  27946. private _setTexture;
  27947. /**
  27948. * Sets an array of texture to the webGL context
  27949. * @param channel defines the channel where the texture array must be set
  27950. * @param uniform defines the associated uniform location
  27951. * @param textures defines the array of textures to bind
  27952. */
  27953. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  27954. /** @hidden */
  27955. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  27956. private _setTextureParameterFloat;
  27957. private _setTextureParameterInteger;
  27958. /**
  27959. * Reads pixels from the current frame buffer. Please note that this function can be slow
  27960. * @param x defines the x coordinate of the rectangle where pixels must be read
  27961. * @param y defines the y coordinate of the rectangle where pixels must be read
  27962. * @param width defines the width of the rectangle where pixels must be read
  27963. * @param height defines the height of the rectangle where pixels must be read
  27964. * @returns a Uint8Array containing RGBA colors
  27965. */
  27966. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  27967. /**
  27968. * Add an externaly attached data from its key.
  27969. * This method call will fail and return false, if such key already exists.
  27970. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  27971. * @param key the unique key that identifies the data
  27972. * @param data the data object to associate to the key for this Engine instance
  27973. * @return true if no such key were already present and the data was added successfully, false otherwise
  27974. */
  27975. addExternalData<T>(key: string, data: T): boolean;
  27976. /**
  27977. * Get an externaly attached data from its key
  27978. * @param key the unique key that identifies the data
  27979. * @return the associated data, if present (can be null), or undefined if not present
  27980. */
  27981. getExternalData<T>(key: string): T;
  27982. /**
  27983. * Get an externaly attached data from its key, create it using a factory if it's not already present
  27984. * @param key the unique key that identifies the data
  27985. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  27986. * @return the associated data, can be null if the factory returned null.
  27987. */
  27988. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  27989. /**
  27990. * Remove an externaly attached data from the Engine instance
  27991. * @param key the unique key that identifies the data
  27992. * @return true if the data was successfully removed, false if it doesn't exist
  27993. */
  27994. removeExternalData(key: string): boolean;
  27995. /**
  27996. * Unbind all vertex attributes from the webGL context
  27997. */
  27998. unbindAllAttributes(): void;
  27999. /**
  28000. * 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
  28001. */
  28002. releaseEffects(): void;
  28003. /**
  28004. * Dispose and release all associated resources
  28005. */
  28006. dispose(): void;
  28007. /**
  28008. * Display the loading screen
  28009. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28010. */
  28011. displayLoadingUI(): void;
  28012. /**
  28013. * Hide the loading screen
  28014. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28015. */
  28016. hideLoadingUI(): void;
  28017. /**
  28018. * Gets the current loading screen object
  28019. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28020. */
  28021. /**
  28022. * Sets the current loading screen object
  28023. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28024. */
  28025. loadingScreen: ILoadingScreen;
  28026. /**
  28027. * Sets the current loading screen text
  28028. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28029. */
  28030. loadingUIText: string;
  28031. /**
  28032. * Sets the current loading screen background color
  28033. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28034. */
  28035. loadingUIBackgroundColor: string;
  28036. /**
  28037. * Attach a new callback raised when context lost event is fired
  28038. * @param callback defines the callback to call
  28039. */
  28040. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28041. /**
  28042. * Attach a new callback raised when context restored event is fired
  28043. * @param callback defines the callback to call
  28044. */
  28045. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28046. /**
  28047. * Gets the source code of the vertex shader associated with a specific webGL program
  28048. * @param program defines the program to use
  28049. * @returns a string containing the source code of the vertex shader associated with the program
  28050. */
  28051. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28052. /**
  28053. * Gets the source code of the fragment shader associated with a specific webGL program
  28054. * @param program defines the program to use
  28055. * @returns a string containing the source code of the fragment shader associated with the program
  28056. */
  28057. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28058. /**
  28059. * Get the current error code of the webGL context
  28060. * @returns the error code
  28061. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28062. */
  28063. getError(): number;
  28064. /**
  28065. * Gets the current framerate
  28066. * @returns a number representing the framerate
  28067. */
  28068. getFps(): number;
  28069. /**
  28070. * Gets the time spent between current and previous frame
  28071. * @returns a number representing the delta time in ms
  28072. */
  28073. getDeltaTime(): number;
  28074. private _measureFps;
  28075. /** @hidden */
  28076. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28077. private _canRenderToFloatFramebuffer;
  28078. private _canRenderToHalfFloatFramebuffer;
  28079. private _canRenderToFramebuffer;
  28080. /** @hidden */
  28081. _getWebGLTextureType(type: number): number;
  28082. private _getInternalFormat;
  28083. /** @hidden */
  28084. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28085. /** @hidden */
  28086. _getRGBAMultiSampleBufferFormat(type: number): number;
  28087. /** @hidden */
  28088. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  28089. /** @hidden */
  28090. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28091. private _partialLoadFile;
  28092. private _cascadeLoadFiles;
  28093. /**
  28094. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28095. * @returns true if the engine can be created
  28096. * @ignorenaming
  28097. */
  28098. static isSupported(): boolean;
  28099. }
  28100. }
  28101. declare module BABYLON {
  28102. /**
  28103. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28104. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28105. */
  28106. export class EffectFallbacks {
  28107. private _defines;
  28108. private _currentRank;
  28109. private _maxRank;
  28110. private _mesh;
  28111. /**
  28112. * Removes the fallback from the bound mesh.
  28113. */
  28114. unBindMesh(): void;
  28115. /**
  28116. * Adds a fallback on the specified property.
  28117. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28118. * @param define The name of the define in the shader
  28119. */
  28120. addFallback(rank: number, define: string): void;
  28121. /**
  28122. * Sets the mesh to use CPU skinning when needing to fallback.
  28123. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28124. * @param mesh The mesh to use the fallbacks.
  28125. */
  28126. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28127. /**
  28128. * Checks to see if more fallbacks are still availible.
  28129. */
  28130. readonly isMoreFallbacks: boolean;
  28131. /**
  28132. * Removes the defines that shoould be removed when falling back.
  28133. * @param currentDefines defines the current define statements for the shader.
  28134. * @param effect defines the current effect we try to compile
  28135. * @returns The resulting defines with defines of the current rank removed.
  28136. */
  28137. reduce(currentDefines: string, effect: Effect): string;
  28138. }
  28139. /**
  28140. * Options to be used when creating an effect.
  28141. */
  28142. export class EffectCreationOptions {
  28143. /**
  28144. * Atrributes that will be used in the shader.
  28145. */
  28146. attributes: string[];
  28147. /**
  28148. * Uniform varible names that will be set in the shader.
  28149. */
  28150. uniformsNames: string[];
  28151. /**
  28152. * Uniform buffer varible names that will be set in the shader.
  28153. */
  28154. uniformBuffersNames: string[];
  28155. /**
  28156. * Sampler texture variable names that will be set in the shader.
  28157. */
  28158. samplers: string[];
  28159. /**
  28160. * Define statements that will be set in the shader.
  28161. */
  28162. defines: any;
  28163. /**
  28164. * Possible fallbacks for this effect to improve performance when needed.
  28165. */
  28166. fallbacks: Nullable<EffectFallbacks>;
  28167. /**
  28168. * Callback that will be called when the shader is compiled.
  28169. */
  28170. onCompiled: Nullable<(effect: Effect) => void>;
  28171. /**
  28172. * Callback that will be called if an error occurs during shader compilation.
  28173. */
  28174. onError: Nullable<(effect: Effect, errors: string) => void>;
  28175. /**
  28176. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28177. */
  28178. indexParameters: any;
  28179. /**
  28180. * Max number of lights that can be used in the shader.
  28181. */
  28182. maxSimultaneousLights: number;
  28183. /**
  28184. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28185. */
  28186. transformFeedbackVaryings: Nullable<string[]>;
  28187. }
  28188. /**
  28189. * Effect containing vertex and fragment shader that can be executed on an object.
  28190. */
  28191. export class Effect {
  28192. /**
  28193. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28194. */
  28195. static ShadersRepository: string;
  28196. /**
  28197. * Name of the effect.
  28198. */
  28199. name: any;
  28200. /**
  28201. * String container all the define statements that should be set on the shader.
  28202. */
  28203. defines: string;
  28204. /**
  28205. * Callback that will be called when the shader is compiled.
  28206. */
  28207. onCompiled: Nullable<(effect: Effect) => void>;
  28208. /**
  28209. * Callback that will be called if an error occurs during shader compilation.
  28210. */
  28211. onError: Nullable<(effect: Effect, errors: string) => void>;
  28212. /**
  28213. * Callback that will be called when effect is bound.
  28214. */
  28215. onBind: Nullable<(effect: Effect) => void>;
  28216. /**
  28217. * Unique ID of the effect.
  28218. */
  28219. uniqueId: number;
  28220. /**
  28221. * Observable that will be called when the shader is compiled.
  28222. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28223. */
  28224. onCompileObservable: Observable<Effect>;
  28225. /**
  28226. * Observable that will be called if an error occurs during shader compilation.
  28227. */
  28228. onErrorObservable: Observable<Effect>;
  28229. /** @hidden */
  28230. _onBindObservable: Nullable<Observable<Effect>>;
  28231. /**
  28232. * Observable that will be called when effect is bound.
  28233. */
  28234. readonly onBindObservable: Observable<Effect>;
  28235. /** @hidden */
  28236. _bonesComputationForcedToCPU: boolean;
  28237. private static _uniqueIdSeed;
  28238. private _engine;
  28239. private _uniformBuffersNames;
  28240. private _uniformsNames;
  28241. private _samplers;
  28242. private _isReady;
  28243. private _compilationError;
  28244. private _attributesNames;
  28245. private _attributes;
  28246. private _uniforms;
  28247. /**
  28248. * Key for the effect.
  28249. * @hidden
  28250. */
  28251. _key: string;
  28252. private _indexParameters;
  28253. private _fallbacks;
  28254. private _vertexSourceCode;
  28255. private _fragmentSourceCode;
  28256. private _vertexSourceCodeOverride;
  28257. private _fragmentSourceCodeOverride;
  28258. private _transformFeedbackVaryings;
  28259. /**
  28260. * Compiled shader to webGL program.
  28261. * @hidden
  28262. */
  28263. _program: WebGLProgram;
  28264. private _valueCache;
  28265. private static _baseCache;
  28266. /**
  28267. * Instantiates an effect.
  28268. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28269. * @param baseName Name of the effect.
  28270. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28271. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28272. * @param samplers List of sampler variables that will be passed to the shader.
  28273. * @param engine Engine to be used to render the effect
  28274. * @param defines Define statements to be added to the shader.
  28275. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28276. * @param onCompiled Callback that will be called when the shader is compiled.
  28277. * @param onError Callback that will be called if an error occurs during shader compilation.
  28278. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28279. */
  28280. 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);
  28281. /**
  28282. * Unique key for this effect
  28283. */
  28284. readonly key: string;
  28285. /**
  28286. * If the effect has been compiled and prepared.
  28287. * @returns if the effect is compiled and prepared.
  28288. */
  28289. isReady(): boolean;
  28290. /**
  28291. * The engine the effect was initialized with.
  28292. * @returns the engine.
  28293. */
  28294. getEngine(): Engine;
  28295. /**
  28296. * The compiled webGL program for the effect
  28297. * @returns the webGL program.
  28298. */
  28299. getProgram(): WebGLProgram;
  28300. /**
  28301. * The set of names of attribute variables for the shader.
  28302. * @returns An array of attribute names.
  28303. */
  28304. getAttributesNames(): string[];
  28305. /**
  28306. * Returns the attribute at the given index.
  28307. * @param index The index of the attribute.
  28308. * @returns The location of the attribute.
  28309. */
  28310. getAttributeLocation(index: number): number;
  28311. /**
  28312. * Returns the attribute based on the name of the variable.
  28313. * @param name of the attribute to look up.
  28314. * @returns the attribute location.
  28315. */
  28316. getAttributeLocationByName(name: string): number;
  28317. /**
  28318. * The number of attributes.
  28319. * @returns the numnber of attributes.
  28320. */
  28321. getAttributesCount(): number;
  28322. /**
  28323. * Gets the index of a uniform variable.
  28324. * @param uniformName of the uniform to look up.
  28325. * @returns the index.
  28326. */
  28327. getUniformIndex(uniformName: string): number;
  28328. /**
  28329. * Returns the attribute based on the name of the variable.
  28330. * @param uniformName of the uniform to look up.
  28331. * @returns the location of the uniform.
  28332. */
  28333. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28334. /**
  28335. * Returns an array of sampler variable names
  28336. * @returns The array of sampler variable neames.
  28337. */
  28338. getSamplers(): string[];
  28339. /**
  28340. * The error from the last compilation.
  28341. * @returns the error string.
  28342. */
  28343. getCompilationError(): string;
  28344. /**
  28345. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28346. * @param func The callback to be used.
  28347. */
  28348. executeWhenCompiled(func: (effect: Effect) => void): void;
  28349. private _checkIsReady;
  28350. /** @hidden */
  28351. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28352. /** @hidden */
  28353. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28354. /** @hidden */
  28355. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28356. private _processShaderConversion;
  28357. private _processIncludes;
  28358. private _processPrecision;
  28359. /**
  28360. * Recompiles the webGL program
  28361. * @param vertexSourceCode The source code for the vertex shader.
  28362. * @param fragmentSourceCode The source code for the fragment shader.
  28363. * @param onCompiled Callback called when completed.
  28364. * @param onError Callback called on error.
  28365. * @hidden
  28366. */
  28367. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  28368. /**
  28369. * Gets the uniform locations of the the specified variable names
  28370. * @param names THe names of the variables to lookup.
  28371. * @returns Array of locations in the same order as variable names.
  28372. */
  28373. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  28374. /**
  28375. * Prepares the effect
  28376. * @hidden
  28377. */
  28378. _prepareEffect(): void;
  28379. /**
  28380. * Checks if the effect is supported. (Must be called after compilation)
  28381. */
  28382. readonly isSupported: boolean;
  28383. /**
  28384. * Binds a texture to the engine to be used as output of the shader.
  28385. * @param channel Name of the output variable.
  28386. * @param texture Texture to bind.
  28387. * @hidden
  28388. */
  28389. _bindTexture(channel: string, texture: InternalTexture): void;
  28390. /**
  28391. * Sets a texture on the engine to be used in the shader.
  28392. * @param channel Name of the sampler variable.
  28393. * @param texture Texture to set.
  28394. */
  28395. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28396. /**
  28397. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28398. * @param channel Name of the sampler variable.
  28399. * @param texture Texture to set.
  28400. */
  28401. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28402. /**
  28403. * Sets an array of textures on the engine to be used in the shader.
  28404. * @param channel Name of the variable.
  28405. * @param textures Textures to set.
  28406. */
  28407. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28408. /**
  28409. * 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)
  28410. * @param channel Name of the sampler variable.
  28411. * @param postProcess Post process to get the input texture from.
  28412. */
  28413. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28414. /**
  28415. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28416. * 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)
  28417. * @param channel Name of the sampler variable.
  28418. * @param postProcess Post process to get the output texture from.
  28419. */
  28420. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28421. /** @hidden */
  28422. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28423. /** @hidden */
  28424. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28425. /** @hidden */
  28426. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28427. /** @hidden */
  28428. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28429. /**
  28430. * Binds a buffer to a uniform.
  28431. * @param buffer Buffer to bind.
  28432. * @param name Name of the uniform variable to bind to.
  28433. */
  28434. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  28435. /**
  28436. * Binds block to a uniform.
  28437. * @param blockName Name of the block to bind.
  28438. * @param index Index to bind.
  28439. */
  28440. bindUniformBlock(blockName: string, index: number): void;
  28441. /**
  28442. * Sets an interger value on a uniform variable.
  28443. * @param uniformName Name of the variable.
  28444. * @param value Value to be set.
  28445. * @returns this effect.
  28446. */
  28447. setInt(uniformName: string, value: number): Effect;
  28448. /**
  28449. * Sets an int array on a uniform variable.
  28450. * @param uniformName Name of the variable.
  28451. * @param array array to be set.
  28452. * @returns this effect.
  28453. */
  28454. setIntArray(uniformName: string, array: Int32Array): Effect;
  28455. /**
  28456. * 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)
  28457. * @param uniformName Name of the variable.
  28458. * @param array array to be set.
  28459. * @returns this effect.
  28460. */
  28461. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28462. /**
  28463. * 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)
  28464. * @param uniformName Name of the variable.
  28465. * @param array array to be set.
  28466. * @returns this effect.
  28467. */
  28468. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28469. /**
  28470. * 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)
  28471. * @param uniformName Name of the variable.
  28472. * @param array array to be set.
  28473. * @returns this effect.
  28474. */
  28475. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28476. /**
  28477. * Sets an float array on a uniform variable.
  28478. * @param uniformName Name of the variable.
  28479. * @param array array to be set.
  28480. * @returns this effect.
  28481. */
  28482. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28483. /**
  28484. * 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)
  28485. * @param uniformName Name of the variable.
  28486. * @param array array to be set.
  28487. * @returns this effect.
  28488. */
  28489. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28490. /**
  28491. * 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)
  28492. * @param uniformName Name of the variable.
  28493. * @param array array to be set.
  28494. * @returns this effect.
  28495. */
  28496. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28497. /**
  28498. * 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)
  28499. * @param uniformName Name of the variable.
  28500. * @param array array to be set.
  28501. * @returns this effect.
  28502. */
  28503. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28504. /**
  28505. * Sets an array on a uniform variable.
  28506. * @param uniformName Name of the variable.
  28507. * @param array array to be set.
  28508. * @returns this effect.
  28509. */
  28510. setArray(uniformName: string, array: number[]): Effect;
  28511. /**
  28512. * 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)
  28513. * @param uniformName Name of the variable.
  28514. * @param array array to be set.
  28515. * @returns this effect.
  28516. */
  28517. setArray2(uniformName: string, array: number[]): Effect;
  28518. /**
  28519. * 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)
  28520. * @param uniformName Name of the variable.
  28521. * @param array array to be set.
  28522. * @returns this effect.
  28523. */
  28524. setArray3(uniformName: string, array: number[]): Effect;
  28525. /**
  28526. * 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)
  28527. * @param uniformName Name of the variable.
  28528. * @param array array to be set.
  28529. * @returns this effect.
  28530. */
  28531. setArray4(uniformName: string, array: number[]): Effect;
  28532. /**
  28533. * Sets matrices on a uniform variable.
  28534. * @param uniformName Name of the variable.
  28535. * @param matrices matrices to be set.
  28536. * @returns this effect.
  28537. */
  28538. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28539. /**
  28540. * Sets matrix on a uniform variable.
  28541. * @param uniformName Name of the variable.
  28542. * @param matrix matrix to be set.
  28543. * @returns this effect.
  28544. */
  28545. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28546. /**
  28547. * 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)
  28548. * @param uniformName Name of the variable.
  28549. * @param matrix matrix to be set.
  28550. * @returns this effect.
  28551. */
  28552. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28553. /**
  28554. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28555. * @param uniformName Name of the variable.
  28556. * @param matrix matrix to be set.
  28557. * @returns this effect.
  28558. */
  28559. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28560. /**
  28561. * Sets a float on a uniform variable.
  28562. * @param uniformName Name of the variable.
  28563. * @param value value to be set.
  28564. * @returns this effect.
  28565. */
  28566. setFloat(uniformName: string, value: number): Effect;
  28567. /**
  28568. * Sets a boolean on a uniform variable.
  28569. * @param uniformName Name of the variable.
  28570. * @param bool value to be set.
  28571. * @returns this effect.
  28572. */
  28573. setBool(uniformName: string, bool: boolean): Effect;
  28574. /**
  28575. * Sets a Vector2 on a uniform variable.
  28576. * @param uniformName Name of the variable.
  28577. * @param vector2 vector2 to be set.
  28578. * @returns this effect.
  28579. */
  28580. setVector2(uniformName: string, vector2: Vector2): Effect;
  28581. /**
  28582. * Sets a float2 on a uniform variable.
  28583. * @param uniformName Name of the variable.
  28584. * @param x First float in float2.
  28585. * @param y Second float in float2.
  28586. * @returns this effect.
  28587. */
  28588. setFloat2(uniformName: string, x: number, y: number): Effect;
  28589. /**
  28590. * Sets a Vector3 on a uniform variable.
  28591. * @param uniformName Name of the variable.
  28592. * @param vector3 Value to be set.
  28593. * @returns this effect.
  28594. */
  28595. setVector3(uniformName: string, vector3: Vector3): Effect;
  28596. /**
  28597. * Sets a float3 on a uniform variable.
  28598. * @param uniformName Name of the variable.
  28599. * @param x First float in float3.
  28600. * @param y Second float in float3.
  28601. * @param z Third float in float3.
  28602. * @returns this effect.
  28603. */
  28604. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28605. /**
  28606. * Sets a Vector4 on a uniform variable.
  28607. * @param uniformName Name of the variable.
  28608. * @param vector4 Value to be set.
  28609. * @returns this effect.
  28610. */
  28611. setVector4(uniformName: string, vector4: Vector4): Effect;
  28612. /**
  28613. * Sets a float4 on a uniform variable.
  28614. * @param uniformName Name of the variable.
  28615. * @param x First float in float4.
  28616. * @param y Second float in float4.
  28617. * @param z Third float in float4.
  28618. * @param w Fourth float in float4.
  28619. * @returns this effect.
  28620. */
  28621. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28622. /**
  28623. * Sets a Color3 on a uniform variable.
  28624. * @param uniformName Name of the variable.
  28625. * @param color3 Value to be set.
  28626. * @returns this effect.
  28627. */
  28628. setColor3(uniformName: string, color3: Color3): Effect;
  28629. /**
  28630. * Sets a Color4 on a uniform variable.
  28631. * @param uniformName Name of the variable.
  28632. * @param color3 Value to be set.
  28633. * @param alpha Alpha value to be set.
  28634. * @returns this effect.
  28635. */
  28636. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28637. /**
  28638. * Sets a Color4 on a uniform variable
  28639. * @param uniformName defines the name of the variable
  28640. * @param color4 defines the value to be set
  28641. * @returns this effect.
  28642. */
  28643. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28644. /**
  28645. * This function will add a new shader to the shader store
  28646. * @param name the name of the shader
  28647. * @param pixelShader optional pixel shader content
  28648. * @param vertexShader optional vertex shader content
  28649. */
  28650. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28651. /**
  28652. * Store of each shader (The can be looked up using effect.key)
  28653. */
  28654. static ShadersStore: {
  28655. [key: string]: string;
  28656. };
  28657. /**
  28658. * Store of each included file for a shader (The can be looked up using effect.key)
  28659. */
  28660. static IncludesShadersStore: {
  28661. [key: string]: string;
  28662. };
  28663. /**
  28664. * Resets the cache of effects.
  28665. */
  28666. static ResetCache(): void;
  28667. }
  28668. }
  28669. declare module BABYLON {
  28670. /**
  28671. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28672. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28673. * 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;
  28674. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28675. */
  28676. export class ColorCurves {
  28677. private _dirty;
  28678. private _tempColor;
  28679. private _globalCurve;
  28680. private _highlightsCurve;
  28681. private _midtonesCurve;
  28682. private _shadowsCurve;
  28683. private _positiveCurve;
  28684. private _negativeCurve;
  28685. private _globalHue;
  28686. private _globalDensity;
  28687. private _globalSaturation;
  28688. private _globalExposure;
  28689. /**
  28690. * Gets the global Hue value.
  28691. * 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).
  28692. */
  28693. /**
  28694. * Sets the global Hue value.
  28695. * 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).
  28696. */
  28697. globalHue: number;
  28698. /**
  28699. * Gets the global Density value.
  28700. * 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.
  28701. * Values less than zero provide a filter of opposite hue.
  28702. */
  28703. /**
  28704. * Sets the global Density value.
  28705. * 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.
  28706. * Values less than zero provide a filter of opposite hue.
  28707. */
  28708. globalDensity: number;
  28709. /**
  28710. * Gets the global Saturation value.
  28711. * 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.
  28712. */
  28713. /**
  28714. * Sets the global Saturation value.
  28715. * 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.
  28716. */
  28717. globalSaturation: number;
  28718. /**
  28719. * Gets the global Exposure value.
  28720. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  28721. */
  28722. /**
  28723. * Sets the global Exposure value.
  28724. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  28725. */
  28726. globalExposure: number;
  28727. private _highlightsHue;
  28728. private _highlightsDensity;
  28729. private _highlightsSaturation;
  28730. private _highlightsExposure;
  28731. /**
  28732. * Gets the highlights Hue value.
  28733. * 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).
  28734. */
  28735. /**
  28736. * Sets the highlights Hue value.
  28737. * 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).
  28738. */
  28739. highlightsHue: number;
  28740. /**
  28741. * Gets the highlights Density value.
  28742. * 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.
  28743. * Values less than zero provide a filter of opposite hue.
  28744. */
  28745. /**
  28746. * Sets the highlights Density value.
  28747. * 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.
  28748. * Values less than zero provide a filter of opposite hue.
  28749. */
  28750. highlightsDensity: number;
  28751. /**
  28752. * Gets the highlights Saturation value.
  28753. * 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.
  28754. */
  28755. /**
  28756. * Sets the highlights Saturation value.
  28757. * 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.
  28758. */
  28759. highlightsSaturation: number;
  28760. /**
  28761. * Gets the highlights Exposure value.
  28762. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  28763. */
  28764. /**
  28765. * Sets the highlights Exposure value.
  28766. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  28767. */
  28768. highlightsExposure: number;
  28769. private _midtonesHue;
  28770. private _midtonesDensity;
  28771. private _midtonesSaturation;
  28772. private _midtonesExposure;
  28773. /**
  28774. * Gets the midtones Hue value.
  28775. * 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).
  28776. */
  28777. /**
  28778. * Sets the midtones Hue value.
  28779. * 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).
  28780. */
  28781. midtonesHue: number;
  28782. /**
  28783. * Gets the midtones Density value.
  28784. * 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.
  28785. * Values less than zero provide a filter of opposite hue.
  28786. */
  28787. /**
  28788. * Sets the midtones Density value.
  28789. * 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.
  28790. * Values less than zero provide a filter of opposite hue.
  28791. */
  28792. midtonesDensity: number;
  28793. /**
  28794. * Gets the midtones Saturation value.
  28795. * 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.
  28796. */
  28797. /**
  28798. * Sets the midtones Saturation value.
  28799. * 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.
  28800. */
  28801. midtonesSaturation: number;
  28802. /**
  28803. * Gets the midtones Exposure value.
  28804. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  28805. */
  28806. /**
  28807. * Sets the midtones Exposure value.
  28808. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  28809. */
  28810. midtonesExposure: number;
  28811. private _shadowsHue;
  28812. private _shadowsDensity;
  28813. private _shadowsSaturation;
  28814. private _shadowsExposure;
  28815. /**
  28816. * Gets the shadows Hue value.
  28817. * 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).
  28818. */
  28819. /**
  28820. * Sets the shadows Hue value.
  28821. * 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).
  28822. */
  28823. shadowsHue: number;
  28824. /**
  28825. * Gets the shadows Density value.
  28826. * 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.
  28827. * Values less than zero provide a filter of opposite hue.
  28828. */
  28829. /**
  28830. * Sets the shadows Density value.
  28831. * 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.
  28832. * Values less than zero provide a filter of opposite hue.
  28833. */
  28834. shadowsDensity: number;
  28835. /**
  28836. * Gets the shadows Saturation value.
  28837. * 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.
  28838. */
  28839. /**
  28840. * Sets the shadows Saturation value.
  28841. * 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.
  28842. */
  28843. shadowsSaturation: number;
  28844. /**
  28845. * Gets the shadows Exposure value.
  28846. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  28847. */
  28848. /**
  28849. * Sets the shadows Exposure value.
  28850. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  28851. */
  28852. shadowsExposure: number;
  28853. /**
  28854. * Returns the class name
  28855. * @returns The class name
  28856. */
  28857. getClassName(): string;
  28858. /**
  28859. * Binds the color curves to the shader.
  28860. * @param colorCurves The color curve to bind
  28861. * @param effect The effect to bind to
  28862. * @param positiveUniform The positive uniform shader parameter
  28863. * @param neutralUniform The neutral uniform shader parameter
  28864. * @param negativeUniform The negative uniform shader parameter
  28865. */
  28866. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  28867. /**
  28868. * Prepare the list of uniforms associated with the ColorCurves effects.
  28869. * @param uniformsList The list of uniforms used in the effect
  28870. */
  28871. static PrepareUniforms(uniformsList: string[]): void;
  28872. /**
  28873. * Returns color grading data based on a hue, density, saturation and exposure value.
  28874. * @param filterHue The hue of the color filter.
  28875. * @param filterDensity The density of the color filter.
  28876. * @param saturation The saturation.
  28877. * @param exposure The exposure.
  28878. * @param result The result data container.
  28879. */
  28880. private getColorGradingDataToRef;
  28881. /**
  28882. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  28883. * @param value The input slider value in range [-100,100].
  28884. * @returns Adjusted value.
  28885. */
  28886. private static applyColorGradingSliderNonlinear;
  28887. /**
  28888. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  28889. * @param hue The hue (H) input.
  28890. * @param saturation The saturation (S) input.
  28891. * @param brightness The brightness (B) input.
  28892. * @result An RGBA color represented as Vector4.
  28893. */
  28894. private static fromHSBToRef;
  28895. /**
  28896. * Returns a value clamped between min and max
  28897. * @param value The value to clamp
  28898. * @param min The minimum of value
  28899. * @param max The maximum of value
  28900. * @returns The clamped value.
  28901. */
  28902. private static clamp;
  28903. /**
  28904. * Clones the current color curve instance.
  28905. * @return The cloned curves
  28906. */
  28907. clone(): ColorCurves;
  28908. /**
  28909. * Serializes the current color curve instance to a json representation.
  28910. * @return a JSON representation
  28911. */
  28912. serialize(): any;
  28913. /**
  28914. * Parses the color curve from a json representation.
  28915. * @param source the JSON source to parse
  28916. * @return The parsed curves
  28917. */
  28918. static Parse(source: any): ColorCurves;
  28919. }
  28920. }
  28921. declare module BABYLON {
  28922. /**
  28923. * Interface to follow in your material defines to integrate easily the
  28924. * Image proccessing functions.
  28925. * @hidden
  28926. */
  28927. export interface IImageProcessingConfigurationDefines {
  28928. IMAGEPROCESSING: boolean;
  28929. VIGNETTE: boolean;
  28930. VIGNETTEBLENDMODEMULTIPLY: boolean;
  28931. VIGNETTEBLENDMODEOPAQUE: boolean;
  28932. TONEMAPPING: boolean;
  28933. TONEMAPPING_ACES: boolean;
  28934. CONTRAST: boolean;
  28935. EXPOSURE: boolean;
  28936. COLORCURVES: boolean;
  28937. COLORGRADING: boolean;
  28938. COLORGRADING3D: boolean;
  28939. SAMPLER3DGREENDEPTH: boolean;
  28940. SAMPLER3DBGRMAP: boolean;
  28941. IMAGEPROCESSINGPOSTPROCESS: boolean;
  28942. }
  28943. /**
  28944. * @hidden
  28945. */
  28946. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  28947. IMAGEPROCESSING: boolean;
  28948. VIGNETTE: boolean;
  28949. VIGNETTEBLENDMODEMULTIPLY: boolean;
  28950. VIGNETTEBLENDMODEOPAQUE: boolean;
  28951. TONEMAPPING: boolean;
  28952. TONEMAPPING_ACES: boolean;
  28953. CONTRAST: boolean;
  28954. COLORCURVES: boolean;
  28955. COLORGRADING: boolean;
  28956. COLORGRADING3D: boolean;
  28957. SAMPLER3DGREENDEPTH: boolean;
  28958. SAMPLER3DBGRMAP: boolean;
  28959. IMAGEPROCESSINGPOSTPROCESS: boolean;
  28960. EXPOSURE: boolean;
  28961. constructor();
  28962. }
  28963. /**
  28964. * This groups together the common properties used for image processing either in direct forward pass
  28965. * or through post processing effect depending on the use of the image processing pipeline in your scene
  28966. * or not.
  28967. */
  28968. export class ImageProcessingConfiguration {
  28969. /**
  28970. * Default tone mapping applied in BabylonJS.
  28971. */
  28972. static readonly TONEMAPPING_STANDARD: number;
  28973. /**
  28974. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  28975. * to other engines rendering to increase portability.
  28976. */
  28977. static readonly TONEMAPPING_ACES: number;
  28978. /**
  28979. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  28980. */
  28981. colorCurves: Nullable<ColorCurves>;
  28982. private _colorCurvesEnabled;
  28983. /**
  28984. * Gets wether the color curves effect is enabled.
  28985. */
  28986. /**
  28987. * Sets wether the color curves effect is enabled.
  28988. */
  28989. colorCurvesEnabled: boolean;
  28990. private _colorGradingTexture;
  28991. /**
  28992. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  28993. */
  28994. /**
  28995. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  28996. */
  28997. colorGradingTexture: Nullable<BaseTexture>;
  28998. private _colorGradingEnabled;
  28999. /**
  29000. * Gets wether the color grading effect is enabled.
  29001. */
  29002. /**
  29003. * Sets wether the color grading effect is enabled.
  29004. */
  29005. colorGradingEnabled: boolean;
  29006. private _colorGradingWithGreenDepth;
  29007. /**
  29008. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29009. */
  29010. /**
  29011. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29012. */
  29013. colorGradingWithGreenDepth: boolean;
  29014. private _colorGradingBGR;
  29015. /**
  29016. * Gets wether the color grading texture contains BGR values.
  29017. */
  29018. /**
  29019. * Sets wether the color grading texture contains BGR values.
  29020. */
  29021. colorGradingBGR: boolean;
  29022. /** @hidden */
  29023. _exposure: number;
  29024. /**
  29025. * Gets the Exposure used in the effect.
  29026. */
  29027. /**
  29028. * Sets the Exposure used in the effect.
  29029. */
  29030. exposure: number;
  29031. private _toneMappingEnabled;
  29032. /**
  29033. * Gets wether the tone mapping effect is enabled.
  29034. */
  29035. /**
  29036. * Sets wether the tone mapping effect is enabled.
  29037. */
  29038. toneMappingEnabled: boolean;
  29039. private _toneMappingType;
  29040. /**
  29041. * Gets the type of tone mapping effect.
  29042. */
  29043. /**
  29044. * Sets the type of tone mapping effect used in BabylonJS.
  29045. */
  29046. toneMappingType: number;
  29047. protected _contrast: number;
  29048. /**
  29049. * Gets the contrast used in the effect.
  29050. */
  29051. /**
  29052. * Sets the contrast used in the effect.
  29053. */
  29054. contrast: number;
  29055. /**
  29056. * Vignette stretch size.
  29057. */
  29058. vignetteStretch: number;
  29059. /**
  29060. * Vignette centre X Offset.
  29061. */
  29062. vignetteCentreX: number;
  29063. /**
  29064. * Vignette centre Y Offset.
  29065. */
  29066. vignetteCentreY: number;
  29067. /**
  29068. * Vignette weight or intensity of the vignette effect.
  29069. */
  29070. vignetteWeight: number;
  29071. /**
  29072. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29073. * if vignetteEnabled is set to true.
  29074. */
  29075. vignetteColor: Color4;
  29076. /**
  29077. * Camera field of view used by the Vignette effect.
  29078. */
  29079. vignetteCameraFov: number;
  29080. private _vignetteBlendMode;
  29081. /**
  29082. * Gets the vignette blend mode allowing different kind of effect.
  29083. */
  29084. /**
  29085. * Sets the vignette blend mode allowing different kind of effect.
  29086. */
  29087. vignetteBlendMode: number;
  29088. private _vignetteEnabled;
  29089. /**
  29090. * Gets wether the vignette effect is enabled.
  29091. */
  29092. /**
  29093. * Sets wether the vignette effect is enabled.
  29094. */
  29095. vignetteEnabled: boolean;
  29096. private _applyByPostProcess;
  29097. /**
  29098. * Gets wether the image processing is applied through a post process or not.
  29099. */
  29100. /**
  29101. * Sets wether the image processing is applied through a post process or not.
  29102. */
  29103. applyByPostProcess: boolean;
  29104. private _isEnabled;
  29105. /**
  29106. * Gets wether the image processing is enabled or not.
  29107. */
  29108. /**
  29109. * Sets wether the image processing is enabled or not.
  29110. */
  29111. isEnabled: boolean;
  29112. /**
  29113. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29114. */
  29115. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29116. /**
  29117. * Method called each time the image processing information changes requires to recompile the effect.
  29118. */
  29119. protected _updateParameters(): void;
  29120. /**
  29121. * Gets the current class name.
  29122. * @return "ImageProcessingConfiguration"
  29123. */
  29124. getClassName(): string;
  29125. /**
  29126. * Prepare the list of uniforms associated with the Image Processing effects.
  29127. * @param uniforms The list of uniforms used in the effect
  29128. * @param defines the list of defines currently in use
  29129. */
  29130. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29131. /**
  29132. * Prepare the list of samplers associated with the Image Processing effects.
  29133. * @param samplersList The list of uniforms used in the effect
  29134. * @param defines the list of defines currently in use
  29135. */
  29136. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29137. /**
  29138. * Prepare the list of defines associated to the shader.
  29139. * @param defines the list of defines to complete
  29140. * @param forPostProcess Define if we are currently in post process mode or not
  29141. */
  29142. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29143. /**
  29144. * Returns true if all the image processing information are ready.
  29145. * @returns True if ready, otherwise, false
  29146. */
  29147. isReady(): boolean;
  29148. /**
  29149. * Binds the image processing to the shader.
  29150. * @param effect The effect to bind to
  29151. * @param aspectRatio Define the current aspect ratio of the effect
  29152. */
  29153. bind(effect: Effect, aspectRatio?: number): void;
  29154. /**
  29155. * Clones the current image processing instance.
  29156. * @return The cloned image processing
  29157. */
  29158. clone(): ImageProcessingConfiguration;
  29159. /**
  29160. * Serializes the current image processing instance to a json representation.
  29161. * @return a JSON representation
  29162. */
  29163. serialize(): any;
  29164. /**
  29165. * Parses the image processing from a json representation.
  29166. * @param source the JSON source to parse
  29167. * @return The parsed image processing
  29168. */
  29169. static Parse(source: any): ImageProcessingConfiguration;
  29170. private static _VIGNETTEMODE_MULTIPLY;
  29171. private static _VIGNETTEMODE_OPAQUE;
  29172. /**
  29173. * Used to apply the vignette as a mix with the pixel color.
  29174. */
  29175. static readonly VIGNETTEMODE_MULTIPLY: number;
  29176. /**
  29177. * Used to apply the vignette as a replacement of the pixel color.
  29178. */
  29179. static readonly VIGNETTEMODE_OPAQUE: number;
  29180. }
  29181. }
  29182. declare module BABYLON {
  29183. /**
  29184. * This represents all the required information to add a fresnel effect on a material:
  29185. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29186. */
  29187. export class FresnelParameters {
  29188. private _isEnabled;
  29189. /**
  29190. * Define if the fresnel effect is enable or not.
  29191. */
  29192. isEnabled: boolean;
  29193. /**
  29194. * Define the color used on edges (grazing angle)
  29195. */
  29196. leftColor: Color3;
  29197. /**
  29198. * Define the color used on center
  29199. */
  29200. rightColor: Color3;
  29201. /**
  29202. * Define bias applied to computed fresnel term
  29203. */
  29204. bias: number;
  29205. /**
  29206. * Defined the power exponent applied to fresnel term
  29207. */
  29208. power: number;
  29209. /**
  29210. * Clones the current fresnel and its valuues
  29211. * @returns a clone fresnel configuration
  29212. */
  29213. clone(): FresnelParameters;
  29214. /**
  29215. * Serializes the current fresnel parameters to a JSON representation.
  29216. * @return the JSON serialization
  29217. */
  29218. serialize(): any;
  29219. /**
  29220. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29221. * @param parsedFresnelParameters Define the JSON representation
  29222. * @returns the parsed parameters
  29223. */
  29224. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29225. }
  29226. }
  29227. declare module BABYLON {
  29228. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29229. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29230. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29231. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29232. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29233. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29234. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29235. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29236. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29237. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29238. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29239. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29240. /**
  29241. * Decorator used to define property that can be serialized as reference to a camera
  29242. * @param sourceName defines the name of the property to decorate
  29243. */
  29244. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29245. /**
  29246. * Class used to help serialization objects
  29247. */
  29248. export class SerializationHelper {
  29249. /** hidden */
  29250. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29251. /** hidden */
  29252. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29253. /** hidden */
  29254. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29255. /** hidden */
  29256. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29257. /**
  29258. * Appends the serialized animations from the source animations
  29259. * @param source Source containing the animations
  29260. * @param destination Target to store the animations
  29261. */
  29262. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29263. /**
  29264. * Static function used to serialized a specific entity
  29265. * @param entity defines the entity to serialize
  29266. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29267. * @returns a JSON compatible object representing the serialization of the entity
  29268. */
  29269. static Serialize<T>(entity: T, serializationObject?: any): any;
  29270. /**
  29271. * Creates a new entity from a serialization data object
  29272. * @param creationFunction defines a function used to instanciated the new entity
  29273. * @param source defines the source serialization data
  29274. * @param scene defines the hosting scene
  29275. * @param rootUrl defines the root url for resources
  29276. * @returns a new entity
  29277. */
  29278. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29279. /**
  29280. * Clones an object
  29281. * @param creationFunction defines the function used to instanciate the new object
  29282. * @param source defines the source object
  29283. * @returns the cloned object
  29284. */
  29285. static Clone<T>(creationFunction: () => T, source: T): T;
  29286. /**
  29287. * Instanciates a new object based on a source one (some data will be shared between both object)
  29288. * @param creationFunction defines the function used to instanciate the new object
  29289. * @param source defines the source object
  29290. * @returns the new object
  29291. */
  29292. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29293. }
  29294. }
  29295. declare module BABYLON {
  29296. /**
  29297. * This is the base class of all the camera used in the application.
  29298. * @see http://doc.babylonjs.com/features/cameras
  29299. */
  29300. export class Camera extends Node {
  29301. /** @hidden */
  29302. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29303. /**
  29304. * This is the default projection mode used by the cameras.
  29305. * It helps recreating a feeling of perspective and better appreciate depth.
  29306. * This is the best way to simulate real life cameras.
  29307. */
  29308. static readonly PERSPECTIVE_CAMERA: number;
  29309. /**
  29310. * This helps creating camera with an orthographic mode.
  29311. * 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.
  29312. */
  29313. static readonly ORTHOGRAPHIC_CAMERA: number;
  29314. /**
  29315. * This is the default FOV mode for perspective cameras.
  29316. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29317. */
  29318. static readonly FOVMODE_VERTICAL_FIXED: number;
  29319. /**
  29320. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29321. */
  29322. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29323. /**
  29324. * This specifies ther is no need for a camera rig.
  29325. * Basically only one eye is rendered corresponding to the camera.
  29326. */
  29327. static readonly RIG_MODE_NONE: number;
  29328. /**
  29329. * Simulates a camera Rig with one blue eye and one red eye.
  29330. * This can be use with 3d blue and red glasses.
  29331. */
  29332. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29333. /**
  29334. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29335. */
  29336. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29337. /**
  29338. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29339. */
  29340. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29341. /**
  29342. * Defines that both eyes of the camera will be rendered over under each other.
  29343. */
  29344. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29345. /**
  29346. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29347. */
  29348. static readonly RIG_MODE_VR: number;
  29349. /**
  29350. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29351. */
  29352. static readonly RIG_MODE_WEBVR: number;
  29353. /**
  29354. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29355. */
  29356. static readonly RIG_MODE_CUSTOM: number;
  29357. /**
  29358. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29359. */
  29360. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29361. /**
  29362. * @hidden
  29363. * Might be removed once multiview will be a thing
  29364. */
  29365. static UseAlternateWebVRRendering: boolean;
  29366. /**
  29367. * Define the input manager associated with the camera.
  29368. */
  29369. inputs: CameraInputsManager<Camera>;
  29370. /**
  29371. * Define the current local position of the camera in the scene
  29372. */
  29373. position: Vector3;
  29374. /**
  29375. * The vector the camera should consider as up.
  29376. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29377. */
  29378. upVector: Vector3;
  29379. /**
  29380. * Define the current limit on the left side for an orthographic camera
  29381. * In scene unit
  29382. */
  29383. orthoLeft: Nullable<number>;
  29384. /**
  29385. * Define the current limit on the right side for an orthographic camera
  29386. * In scene unit
  29387. */
  29388. orthoRight: Nullable<number>;
  29389. /**
  29390. * Define the current limit on the bottom side for an orthographic camera
  29391. * In scene unit
  29392. */
  29393. orthoBottom: Nullable<number>;
  29394. /**
  29395. * Define the current limit on the top side for an orthographic camera
  29396. * In scene unit
  29397. */
  29398. orthoTop: Nullable<number>;
  29399. /**
  29400. * Field Of View is set in Radians. (default is 0.8)
  29401. */
  29402. fov: number;
  29403. /**
  29404. * Define the minimum distance the camera can see from.
  29405. * This is important to note that the depth buffer are not infinite and the closer it starts
  29406. * the more your scene might encounter depth fighting issue.
  29407. */
  29408. minZ: number;
  29409. /**
  29410. * Define the maximum distance the camera can see to.
  29411. * This is important to note that the depth buffer are not infinite and the further it end
  29412. * the more your scene might encounter depth fighting issue.
  29413. */
  29414. maxZ: number;
  29415. /**
  29416. * Define the default inertia of the camera.
  29417. * This helps giving a smooth feeling to the camera movement.
  29418. */
  29419. inertia: number;
  29420. /**
  29421. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29422. */
  29423. mode: number;
  29424. /**
  29425. * Define wether the camera is intermediate.
  29426. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29427. */
  29428. isIntermediate: boolean;
  29429. /**
  29430. * Define the viewport of the camera.
  29431. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29432. */
  29433. viewport: Viewport;
  29434. /**
  29435. * Restricts the camera to viewing objects with the same layerMask.
  29436. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29437. */
  29438. layerMask: number;
  29439. /**
  29440. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29441. */
  29442. fovMode: number;
  29443. /**
  29444. * Rig mode of the camera.
  29445. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29446. * This is normally controlled byt the camera themselves as internal use.
  29447. */
  29448. cameraRigMode: number;
  29449. /**
  29450. * Defines the distance between both "eyes" in case of a RIG
  29451. */
  29452. interaxialDistance: number;
  29453. /**
  29454. * Defines if stereoscopic rendering is done side by side or over under.
  29455. */
  29456. isStereoscopicSideBySide: boolean;
  29457. /**
  29458. * 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
  29459. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29460. * else in the scene.
  29461. */
  29462. customRenderTargets: RenderTargetTexture[];
  29463. /**
  29464. * When set, the camera will render to this render target instead of the default canvas
  29465. */
  29466. outputRenderTarget: Nullable<RenderTargetTexture>;
  29467. /**
  29468. * Observable triggered when the camera view matrix has changed.
  29469. */
  29470. onViewMatrixChangedObservable: Observable<Camera>;
  29471. /**
  29472. * Observable triggered when the camera Projection matrix has changed.
  29473. */
  29474. onProjectionMatrixChangedObservable: Observable<Camera>;
  29475. /**
  29476. * Observable triggered when the inputs have been processed.
  29477. */
  29478. onAfterCheckInputsObservable: Observable<Camera>;
  29479. /**
  29480. * Observable triggered when reset has been called and applied to the camera.
  29481. */
  29482. onRestoreStateObservable: Observable<Camera>;
  29483. /** @hidden */
  29484. _cameraRigParams: any;
  29485. /** @hidden */
  29486. _rigCameras: Camera[];
  29487. /** @hidden */
  29488. _rigPostProcess: Nullable<PostProcess>;
  29489. protected _webvrViewMatrix: Matrix;
  29490. /** @hidden */
  29491. _skipRendering: boolean;
  29492. /** @hidden */
  29493. _alternateCamera: Camera;
  29494. /** @hidden */
  29495. _projectionMatrix: Matrix;
  29496. /** @hidden */
  29497. _postProcesses: Nullable<PostProcess>[];
  29498. /** @hidden */
  29499. _activeMeshes: SmartArray<AbstractMesh>;
  29500. protected _globalPosition: Vector3;
  29501. /** hidden */
  29502. _computedViewMatrix: Matrix;
  29503. private _doNotComputeProjectionMatrix;
  29504. private _transformMatrix;
  29505. private _frustumPlanes;
  29506. private _refreshFrustumPlanes;
  29507. private _storedFov;
  29508. private _stateStored;
  29509. /**
  29510. * Instantiates a new camera object.
  29511. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29512. * @see http://doc.babylonjs.com/features/cameras
  29513. * @param name Defines the name of the camera in the scene
  29514. * @param position Defines the position of the camera
  29515. * @param scene Defines the scene the camera belongs too
  29516. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29517. */
  29518. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29519. /**
  29520. * Store current camera state (fov, position, etc..)
  29521. * @returns the camera
  29522. */
  29523. storeState(): Camera;
  29524. /**
  29525. * Restores the camera state values if it has been stored. You must call storeState() first
  29526. */
  29527. protected _restoreStateValues(): boolean;
  29528. /**
  29529. * Restored camera state. You must call storeState() first.
  29530. * @returns true if restored and false otherwise
  29531. */
  29532. restoreState(): boolean;
  29533. /**
  29534. * Gets the class name of the camera.
  29535. * @returns the class name
  29536. */
  29537. getClassName(): string;
  29538. /** @hidden */
  29539. readonly _isCamera: boolean;
  29540. /**
  29541. * Gets a string representation of the camera useful for debug purpose.
  29542. * @param fullDetails Defines that a more verboe level of logging is required
  29543. * @returns the string representation
  29544. */
  29545. toString(fullDetails?: boolean): string;
  29546. /**
  29547. * Gets the current world space position of the camera.
  29548. */
  29549. readonly globalPosition: Vector3;
  29550. /**
  29551. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29552. * @returns the active meshe list
  29553. */
  29554. getActiveMeshes(): SmartArray<AbstractMesh>;
  29555. /**
  29556. * Check wether a mesh is part of the current active mesh list of the camera
  29557. * @param mesh Defines the mesh to check
  29558. * @returns true if active, false otherwise
  29559. */
  29560. isActiveMesh(mesh: Mesh): boolean;
  29561. /**
  29562. * Is this camera ready to be used/rendered
  29563. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29564. * @return true if the camera is ready
  29565. */
  29566. isReady(completeCheck?: boolean): boolean;
  29567. /** @hidden */
  29568. _initCache(): void;
  29569. /** @hidden */
  29570. _updateCache(ignoreParentClass?: boolean): void;
  29571. /** @hidden */
  29572. _isSynchronized(): boolean;
  29573. /** @hidden */
  29574. _isSynchronizedViewMatrix(): boolean;
  29575. /** @hidden */
  29576. _isSynchronizedProjectionMatrix(): boolean;
  29577. /**
  29578. * Attach the input controls to a specific dom element to get the input from.
  29579. * @param element Defines the element the controls should be listened from
  29580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29581. */
  29582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29583. /**
  29584. * Detach the current controls from the specified dom element.
  29585. * @param element Defines the element to stop listening the inputs from
  29586. */
  29587. detachControl(element: HTMLElement): void;
  29588. /**
  29589. * Update the camera state according to the different inputs gathered during the frame.
  29590. */
  29591. update(): void;
  29592. /** @hidden */
  29593. _checkInputs(): void;
  29594. /** @hidden */
  29595. readonly rigCameras: Camera[];
  29596. /**
  29597. * Gets the post process used by the rig cameras
  29598. */
  29599. readonly rigPostProcess: Nullable<PostProcess>;
  29600. /**
  29601. * Internal, gets the first post proces.
  29602. * @returns the first post process to be run on this camera.
  29603. */
  29604. _getFirstPostProcess(): Nullable<PostProcess>;
  29605. private _cascadePostProcessesToRigCams;
  29606. /**
  29607. * Attach a post process to the camera.
  29608. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29609. * @param postProcess The post process to attach to the camera
  29610. * @param insertAt The position of the post process in case several of them are in use in the scene
  29611. * @returns the position the post process has been inserted at
  29612. */
  29613. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29614. /**
  29615. * Detach a post process to the camera.
  29616. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29617. * @param postProcess The post process to detach from the camera
  29618. */
  29619. detachPostProcess(postProcess: PostProcess): void;
  29620. /**
  29621. * Gets the current world matrix of the camera
  29622. */
  29623. getWorldMatrix(): Matrix;
  29624. /** @hidden */
  29625. _getViewMatrix(): Matrix;
  29626. /**
  29627. * Gets the current view matrix of the camera.
  29628. * @param force forces the camera to recompute the matrix without looking at the cached state
  29629. * @returns the view matrix
  29630. */
  29631. getViewMatrix(force?: boolean): Matrix;
  29632. /**
  29633. * Freeze the projection matrix.
  29634. * It will prevent the cache check of the camera projection compute and can speed up perf
  29635. * if no parameter of the camera are meant to change
  29636. * @param projection Defines manually a projection if necessary
  29637. */
  29638. freezeProjectionMatrix(projection?: Matrix): void;
  29639. /**
  29640. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29641. */
  29642. unfreezeProjectionMatrix(): void;
  29643. /**
  29644. * Gets the current projection matrix of the camera.
  29645. * @param force forces the camera to recompute the matrix without looking at the cached state
  29646. * @returns the projection matrix
  29647. */
  29648. getProjectionMatrix(force?: boolean): Matrix;
  29649. /**
  29650. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29651. * @returns a Matrix
  29652. */
  29653. getTransformationMatrix(): Matrix;
  29654. private _updateFrustumPlanes;
  29655. /**
  29656. * Checks if a cullable object (mesh...) is in the camera frustum
  29657. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29658. * @param target The object to check
  29659. * @returns true if the object is in frustum otherwise false
  29660. */
  29661. isInFrustum(target: ICullable): boolean;
  29662. /**
  29663. * Checks if a cullable object (mesh...) is in the camera frustum
  29664. * Unlike isInFrustum this cheks the full bounding box
  29665. * @param target The object to check
  29666. * @returns true if the object is in frustum otherwise false
  29667. */
  29668. isCompletelyInFrustum(target: ICullable): boolean;
  29669. /**
  29670. * Gets a ray in the forward direction from the camera.
  29671. * @param length Defines the length of the ray to create
  29672. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29673. * @param origin Defines the start point of the ray which defaults to the camera position
  29674. * @returns the forward ray
  29675. */
  29676. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29677. /**
  29678. * Releases resources associated with this node.
  29679. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29680. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29681. */
  29682. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29683. /**
  29684. * Gets the left camera of a rig setup in case of Rigged Camera
  29685. */
  29686. readonly leftCamera: Nullable<FreeCamera>;
  29687. /**
  29688. * Gets the right camera of a rig setup in case of Rigged Camera
  29689. */
  29690. readonly rightCamera: Nullable<FreeCamera>;
  29691. /**
  29692. * Gets the left camera target of a rig setup in case of Rigged Camera
  29693. * @returns the target position
  29694. */
  29695. getLeftTarget(): Nullable<Vector3>;
  29696. /**
  29697. * Gets the right camera target of a rig setup in case of Rigged Camera
  29698. * @returns the target position
  29699. */
  29700. getRightTarget(): Nullable<Vector3>;
  29701. /**
  29702. * @hidden
  29703. */
  29704. setCameraRigMode(mode: number, rigParams: any): void;
  29705. /** @hidden */
  29706. static _setStereoscopicRigMode(camera: Camera): void;
  29707. /** @hidden */
  29708. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29709. /** @hidden */
  29710. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29711. /** @hidden */
  29712. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29713. /** @hidden */
  29714. _getVRProjectionMatrix(): Matrix;
  29715. protected _updateCameraRotationMatrix(): void;
  29716. protected _updateWebVRCameraRotationMatrix(): void;
  29717. /**
  29718. * This function MUST be overwritten by the different WebVR cameras available.
  29719. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29720. * @hidden
  29721. */
  29722. _getWebVRProjectionMatrix(): Matrix;
  29723. /**
  29724. * This function MUST be overwritten by the different WebVR cameras available.
  29725. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29726. * @hidden
  29727. */
  29728. _getWebVRViewMatrix(): Matrix;
  29729. /** @hidden */
  29730. setCameraRigParameter(name: string, value: any): void;
  29731. /**
  29732. * needs to be overridden by children so sub has required properties to be copied
  29733. * @hidden
  29734. */
  29735. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29736. /**
  29737. * May need to be overridden by children
  29738. * @hidden
  29739. */
  29740. _updateRigCameras(): void;
  29741. /** @hidden */
  29742. _setupInputs(): void;
  29743. /**
  29744. * Serialiaze the camera setup to a json represention
  29745. * @returns the JSON representation
  29746. */
  29747. serialize(): any;
  29748. /**
  29749. * Clones the current camera.
  29750. * @param name The cloned camera name
  29751. * @returns the cloned camera
  29752. */
  29753. clone(name: string): Camera;
  29754. /**
  29755. * Gets the direction of the camera relative to a given local axis.
  29756. * @param localAxis Defines the reference axis to provide a relative direction.
  29757. * @return the direction
  29758. */
  29759. getDirection(localAxis: Vector3): Vector3;
  29760. /**
  29761. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29762. * @param localAxis Defines the reference axis to provide a relative direction.
  29763. * @param result Defines the vector to store the result in
  29764. */
  29765. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29766. /**
  29767. * Gets a camera constructor for a given camera type
  29768. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29769. * @param name The name of the camera the result will be able to instantiate
  29770. * @param scene The scene the result will construct the camera in
  29771. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29772. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29773. * @returns a factory method to construc the camera
  29774. */
  29775. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29776. /**
  29777. * Compute the world matrix of the camera.
  29778. * @returns the camera workd matrix
  29779. */
  29780. computeWorldMatrix(): Matrix;
  29781. /**
  29782. * Parse a JSON and creates the camera from the parsed information
  29783. * @param parsedCamera The JSON to parse
  29784. * @param scene The scene to instantiate the camera in
  29785. * @returns the newly constructed camera
  29786. */
  29787. static Parse(parsedCamera: any, scene: Scene): Camera;
  29788. }
  29789. }
  29790. declare module BABYLON {
  29791. /**
  29792. * Interface for any object that can request an animation frame
  29793. */
  29794. export interface ICustomAnimationFrameRequester {
  29795. /**
  29796. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29797. */
  29798. renderFunction?: Function;
  29799. /**
  29800. * Called to request the next frame to render to
  29801. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29802. */
  29803. requestAnimationFrame: Function;
  29804. /**
  29805. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29806. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29807. */
  29808. requestID?: number;
  29809. }
  29810. /**
  29811. * Interface containing an array of animations
  29812. */
  29813. export interface IAnimatable {
  29814. /**
  29815. * Array of animations
  29816. */
  29817. animations: Array<Animation>;
  29818. }
  29819. /** Interface used by value gradients (color, factor, ...) */
  29820. export interface IValueGradient {
  29821. /**
  29822. * Gets or sets the gradient value (between 0 and 1)
  29823. */
  29824. gradient: number;
  29825. }
  29826. /** Class used to store color4 gradient */
  29827. export class ColorGradient implements IValueGradient {
  29828. /**
  29829. * Gets or sets the gradient value (between 0 and 1)
  29830. */
  29831. gradient: number;
  29832. /**
  29833. * Gets or sets first associated color
  29834. */
  29835. color1: Color4;
  29836. /**
  29837. * Gets or sets second associated color
  29838. */
  29839. color2?: Color4;
  29840. /**
  29841. * Will get a color picked randomly between color1 and color2.
  29842. * If color2 is undefined then color1 will be used
  29843. * @param result defines the target Color4 to store the result in
  29844. */
  29845. getColorToRef(result: Color4): void;
  29846. }
  29847. /** Class used to store color 3 gradient */
  29848. export class Color3Gradient implements IValueGradient {
  29849. /**
  29850. * Gets or sets the gradient value (between 0 and 1)
  29851. */
  29852. gradient: number;
  29853. /**
  29854. * Gets or sets the associated color
  29855. */
  29856. color: Color3;
  29857. }
  29858. /** Class used to store factor gradient */
  29859. export class FactorGradient implements IValueGradient {
  29860. /**
  29861. * Gets or sets the gradient value (between 0 and 1)
  29862. */
  29863. gradient: number;
  29864. /**
  29865. * Gets or sets first associated factor
  29866. */
  29867. factor1: number;
  29868. /**
  29869. * Gets or sets second associated factor
  29870. */
  29871. factor2?: number;
  29872. /**
  29873. * Will get a number picked randomly between factor1 and factor2.
  29874. * If factor2 is undefined then factor1 will be used
  29875. * @returns the picked number
  29876. */
  29877. getFactor(): number;
  29878. }
  29879. /**
  29880. * @ignore
  29881. * Application error to support additional information when loading a file
  29882. */
  29883. export class LoadFileError extends Error {
  29884. /** defines the optional XHR request */
  29885. request?: XMLHttpRequest | undefined;
  29886. private static _setPrototypeOf;
  29887. /**
  29888. * Creates a new LoadFileError
  29889. * @param message defines the message of the error
  29890. * @param request defines the optional XHR request
  29891. */
  29892. constructor(message: string,
  29893. /** defines the optional XHR request */
  29894. request?: XMLHttpRequest | undefined);
  29895. }
  29896. /**
  29897. * Class used to define a retry strategy when error happens while loading assets
  29898. */
  29899. export class RetryStrategy {
  29900. /**
  29901. * Function used to defines an exponential back off strategy
  29902. * @param maxRetries defines the maximum number of retries (3 by default)
  29903. * @param baseInterval defines the interval between retries
  29904. * @returns the strategy function to use
  29905. */
  29906. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29907. }
  29908. /**
  29909. * File request interface
  29910. */
  29911. export interface IFileRequest {
  29912. /**
  29913. * Raised when the request is complete (success or error).
  29914. */
  29915. onCompleteObservable: Observable<IFileRequest>;
  29916. /**
  29917. * Aborts the request for a file.
  29918. */
  29919. abort: () => void;
  29920. }
  29921. /**
  29922. * Class containing a set of static utilities functions
  29923. */
  29924. export class Tools {
  29925. /**
  29926. * Gets or sets the base URL to use to load assets
  29927. */
  29928. static BaseUrl: string;
  29929. /**
  29930. * Enable/Disable Custom HTTP Request Headers globally.
  29931. * default = false
  29932. * @see CustomRequestHeaders
  29933. */
  29934. static UseCustomRequestHeaders: boolean;
  29935. /**
  29936. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  29937. * i.e. when loading files, where the server/service expects an Authorization header.
  29938. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  29939. */
  29940. static CustomRequestHeaders: {
  29941. [key: string]: string;
  29942. };
  29943. /**
  29944. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  29945. */
  29946. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29947. /**
  29948. * Default behaviour for cors in the application.
  29949. * It can be a string if the expected behavior is identical in the entire app.
  29950. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  29951. */
  29952. static CorsBehavior: string | ((url: string | string[]) => string);
  29953. /**
  29954. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  29955. * @ignorenaming
  29956. */
  29957. static UseFallbackTexture: boolean;
  29958. /**
  29959. * Use this object to register external classes like custom textures or material
  29960. * to allow the laoders to instantiate them
  29961. */
  29962. static RegisteredExternalClasses: {
  29963. [key: string]: Object;
  29964. };
  29965. /**
  29966. * Texture content used if a texture cannot loaded
  29967. * @ignorenaming
  29968. */
  29969. static fallbackTexture: string;
  29970. /**
  29971. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  29972. * @param u defines the coordinate on X axis
  29973. * @param v defines the coordinate on Y axis
  29974. * @param width defines the width of the source data
  29975. * @param height defines the height of the source data
  29976. * @param pixels defines the source byte array
  29977. * @param color defines the output color
  29978. */
  29979. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  29980. /**
  29981. * Interpolates between a and b via alpha
  29982. * @param a The lower value (returned when alpha = 0)
  29983. * @param b The upper value (returned when alpha = 1)
  29984. * @param alpha The interpolation-factor
  29985. * @return The mixed value
  29986. */
  29987. static Mix(a: number, b: number, alpha: number): number;
  29988. /**
  29989. * Tries to instantiate a new object from a given class name
  29990. * @param className defines the class name to instantiate
  29991. * @returns the new object or null if the system was not able to do the instantiation
  29992. */
  29993. static Instantiate(className: string): any;
  29994. /**
  29995. * Provides a slice function that will work even on IE
  29996. * @param data defines the array to slice
  29997. * @param start defines the start of the data (optional)
  29998. * @param end defines the end of the data (optional)
  29999. * @returns the new sliced array
  30000. */
  30001. static Slice<T>(data: T, start?: number, end?: number): T;
  30002. /**
  30003. * Polyfill for setImmediate
  30004. * @param action defines the action to execute after the current execution block
  30005. */
  30006. static SetImmediate(action: () => void): void;
  30007. /**
  30008. * Function indicating if a number is an exponent of 2
  30009. * @param value defines the value to test
  30010. * @returns true if the value is an exponent of 2
  30011. */
  30012. static IsExponentOfTwo(value: number): boolean;
  30013. private static _tmpFloatArray;
  30014. /**
  30015. * Returns the nearest 32-bit single precision float representation of a Number
  30016. * @param value A Number. If the parameter is of a different type, it will get converted
  30017. * to a number or to NaN if it cannot be converted
  30018. * @returns number
  30019. */
  30020. static FloatRound(value: number): number;
  30021. /**
  30022. * Find the next highest power of two.
  30023. * @param x Number to start search from.
  30024. * @return Next highest power of two.
  30025. */
  30026. static CeilingPOT(x: number): number;
  30027. /**
  30028. * Find the next lowest power of two.
  30029. * @param x Number to start search from.
  30030. * @return Next lowest power of two.
  30031. */
  30032. static FloorPOT(x: number): number;
  30033. /**
  30034. * Find the nearest power of two.
  30035. * @param x Number to start search from.
  30036. * @return Next nearest power of two.
  30037. */
  30038. static NearestPOT(x: number): number;
  30039. /**
  30040. * Get the closest exponent of two
  30041. * @param value defines the value to approximate
  30042. * @param max defines the maximum value to return
  30043. * @param mode defines how to define the closest value
  30044. * @returns closest exponent of two of the given value
  30045. */
  30046. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30047. /**
  30048. * Extracts the filename from a path
  30049. * @param path defines the path to use
  30050. * @returns the filename
  30051. */
  30052. static GetFilename(path: string): string;
  30053. /**
  30054. * Extracts the "folder" part of a path (everything before the filename).
  30055. * @param uri The URI to extract the info from
  30056. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30057. * @returns The "folder" part of the path
  30058. */
  30059. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30060. /**
  30061. * Extracts text content from a DOM element hierarchy
  30062. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30063. */
  30064. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30065. /**
  30066. * Convert an angle in radians to degrees
  30067. * @param angle defines the angle to convert
  30068. * @returns the angle in degrees
  30069. */
  30070. static ToDegrees(angle: number): number;
  30071. /**
  30072. * Convert an angle in degrees to radians
  30073. * @param angle defines the angle to convert
  30074. * @returns the angle in radians
  30075. */
  30076. static ToRadians(angle: number): number;
  30077. /**
  30078. * Encode a buffer to a base64 string
  30079. * @param buffer defines the buffer to encode
  30080. * @returns the encoded string
  30081. */
  30082. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30083. /**
  30084. * Extracts minimum and maximum values from a list of indexed positions
  30085. * @param positions defines the positions to use
  30086. * @param indices defines the indices to the positions
  30087. * @param indexStart defines the start index
  30088. * @param indexCount defines the end index
  30089. * @param bias defines bias value to add to the result
  30090. * @return minimum and maximum values
  30091. */
  30092. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30093. minimum: Vector3;
  30094. maximum: Vector3;
  30095. };
  30096. /**
  30097. * Extracts minimum and maximum values from a list of positions
  30098. * @param positions defines the positions to use
  30099. * @param start defines the start index in the positions array
  30100. * @param count defines the number of positions to handle
  30101. * @param bias defines bias value to add to the result
  30102. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30103. * @return minimum and maximum values
  30104. */
  30105. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30106. minimum: Vector3;
  30107. maximum: Vector3;
  30108. };
  30109. /**
  30110. * Returns an array if obj is not an array
  30111. * @param obj defines the object to evaluate as an array
  30112. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30113. * @returns either obj directly if obj is an array or a new array containing obj
  30114. */
  30115. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30116. /**
  30117. * Gets the pointer prefix to use
  30118. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30119. */
  30120. static GetPointerPrefix(): string;
  30121. /**
  30122. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30123. * @param func - the function to be called
  30124. * @param requester - the object that will request the next frame. Falls back to window.
  30125. * @returns frame number
  30126. */
  30127. static QueueNewFrame(func: () => void, requester?: any): number;
  30128. /**
  30129. * Ask the browser to promote the current element to fullscreen rendering mode
  30130. * @param element defines the DOM element to promote
  30131. */
  30132. static RequestFullscreen(element: HTMLElement): void;
  30133. /**
  30134. * Asks the browser to exit fullscreen mode
  30135. */
  30136. static ExitFullscreen(): void;
  30137. /**
  30138. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30139. * @param url define the url we are trying
  30140. * @param element define the dom element where to configure the cors policy
  30141. */
  30142. static SetCorsBehavior(url: string | string[], element: {
  30143. crossOrigin: string | null;
  30144. }): void;
  30145. /**
  30146. * Removes unwanted characters from an url
  30147. * @param url defines the url to clean
  30148. * @returns the cleaned url
  30149. */
  30150. static CleanUrl(url: string): string;
  30151. /**
  30152. * Gets or sets a function used to pre-process url before using them to load assets
  30153. */
  30154. static PreprocessUrl: (url: string) => string;
  30155. /**
  30156. * Loads an image as an HTMLImageElement.
  30157. * @param input url string, ArrayBuffer, or Blob to load
  30158. * @param onLoad callback called when the image successfully loads
  30159. * @param onError callback called when the image fails to load
  30160. * @param offlineProvider offline provider for caching
  30161. * @returns the HTMLImageElement of the loaded image
  30162. */
  30163. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30164. /**
  30165. * Loads a file
  30166. * @param url url string, ArrayBuffer, or Blob to load
  30167. * @param onSuccess callback called when the file successfully loads
  30168. * @param onProgress callback called while file is loading (if the server supports this mode)
  30169. * @param offlineProvider defines the offline provider for caching
  30170. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30171. * @param onError callback called when the file fails to load
  30172. * @returns a file request object
  30173. */
  30174. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  30175. /**
  30176. * Load a script (identified by an url). When the url returns, the
  30177. * content of this file is added into a new script element, attached to the DOM (body element)
  30178. * @param scriptUrl defines the url of the script to laod
  30179. * @param onSuccess defines the callback called when the script is loaded
  30180. * @param onError defines the callback to call if an error occurs
  30181. */
  30182. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30183. /**
  30184. * Loads a file from a blob
  30185. * @param fileToLoad defines the blob to use
  30186. * @param callback defines the callback to call when data is loaded
  30187. * @param progressCallback defines the callback to call during loading process
  30188. * @returns a file request object
  30189. */
  30190. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30191. /**
  30192. * Loads a file
  30193. * @param fileToLoad defines the file to load
  30194. * @param callback defines the callback to call when data is loaded
  30195. * @param progressCallBack defines the callback to call during loading process
  30196. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30197. * @returns a file request object
  30198. */
  30199. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30200. /**
  30201. * Creates a data url from a given string content
  30202. * @param content defines the content to convert
  30203. * @returns the new data url link
  30204. */
  30205. static FileAsURL(content: string): string;
  30206. /**
  30207. * Format the given number to a specific decimal format
  30208. * @param value defines the number to format
  30209. * @param decimals defines the number of decimals to use
  30210. * @returns the formatted string
  30211. */
  30212. static Format(value: number, decimals?: number): string;
  30213. /**
  30214. * Checks if a given vector is inside a specific range
  30215. * @param v defines the vector to test
  30216. * @param min defines the minimum range
  30217. * @param max defines the maximum range
  30218. */
  30219. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30220. /**
  30221. * Tries to copy an object by duplicating every property
  30222. * @param source defines the source object
  30223. * @param destination defines the target object
  30224. * @param doNotCopyList defines a list of properties to avoid
  30225. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30226. */
  30227. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30228. /**
  30229. * Gets a boolean indicating if the given object has no own property
  30230. * @param obj defines the object to test
  30231. * @returns true if object has no own property
  30232. */
  30233. static IsEmpty(obj: any): boolean;
  30234. /**
  30235. * Function used to register events at window level
  30236. * @param events defines the events to register
  30237. */
  30238. static RegisterTopRootEvents(events: {
  30239. name: string;
  30240. handler: Nullable<(e: FocusEvent) => any>;
  30241. }[]): void;
  30242. /**
  30243. * Function used to unregister events from window level
  30244. * @param events defines the events to unregister
  30245. */
  30246. static UnregisterTopRootEvents(events: {
  30247. name: string;
  30248. handler: Nullable<(e: FocusEvent) => any>;
  30249. }[]): void;
  30250. /**
  30251. * Dumps the current bound framebuffer
  30252. * @param width defines the rendering width
  30253. * @param height defines the rendering height
  30254. * @param engine defines the hosting engine
  30255. * @param successCallback defines the callback triggered once the data are available
  30256. * @param mimeType defines the mime type of the result
  30257. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30258. */
  30259. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30260. /**
  30261. * Converts the canvas data to blob.
  30262. * This acts as a polyfill for browsers not supporting the to blob function.
  30263. * @param canvas Defines the canvas to extract the data from
  30264. * @param successCallback Defines the callback triggered once the data are available
  30265. * @param mimeType Defines the mime type of the result
  30266. */
  30267. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30268. /**
  30269. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30270. * @param successCallback defines the callback triggered once the data are available
  30271. * @param mimeType defines the mime type of the result
  30272. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30273. */
  30274. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30275. /**
  30276. * Downloads a blob in the browser
  30277. * @param blob defines the blob to download
  30278. * @param fileName defines the name of the downloaded file
  30279. */
  30280. static Download(blob: Blob, fileName: string): void;
  30281. /**
  30282. * Captures a screenshot of the current rendering
  30283. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30284. * @param engine defines the rendering engine
  30285. * @param camera defines the source camera
  30286. * @param size This parameter can be set to a single number or to an object with the
  30287. * following (optional) properties: precision, width, height. If a single number is passed,
  30288. * it will be used for both width and height. If an object is passed, the screenshot size
  30289. * will be derived from the parameters. The precision property is a multiplier allowing
  30290. * rendering at a higher or lower resolution
  30291. * @param successCallback defines the callback receives a single parameter which contains the
  30292. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30293. * src parameter of an <img> to display it
  30294. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30295. * Check your browser for supported MIME types
  30296. */
  30297. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30298. /**
  30299. * Generates an image screenshot from the specified camera.
  30300. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30301. * @param engine The engine to use for rendering
  30302. * @param camera The camera to use for rendering
  30303. * @param size This parameter can be set to a single number or to an object with the
  30304. * following (optional) properties: precision, width, height. If a single number is passed,
  30305. * it will be used for both width and height. If an object is passed, the screenshot size
  30306. * will be derived from the parameters. The precision property is a multiplier allowing
  30307. * rendering at a higher or lower resolution
  30308. * @param successCallback The callback receives a single parameter which contains the
  30309. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30310. * src parameter of an <img> to display it
  30311. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30312. * Check your browser for supported MIME types
  30313. * @param samples Texture samples (default: 1)
  30314. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30315. * @param fileName A name for for the downloaded file.
  30316. */
  30317. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30318. /**
  30319. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30320. * Be aware Math.random() could cause collisions, but:
  30321. * "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"
  30322. * @returns a pseudo random id
  30323. */
  30324. static RandomId(): string;
  30325. /**
  30326. * Test if the given uri is a base64 string
  30327. * @param uri The uri to test
  30328. * @return True if the uri is a base64 string or false otherwise
  30329. */
  30330. static IsBase64(uri: string): boolean;
  30331. /**
  30332. * Decode the given base64 uri.
  30333. * @param uri The uri to decode
  30334. * @return The decoded base64 data.
  30335. */
  30336. static DecodeBase64(uri: string): ArrayBuffer;
  30337. /**
  30338. * No log
  30339. */
  30340. static readonly NoneLogLevel: number;
  30341. /**
  30342. * Only message logs
  30343. */
  30344. static readonly MessageLogLevel: number;
  30345. /**
  30346. * Only warning logs
  30347. */
  30348. static readonly WarningLogLevel: number;
  30349. /**
  30350. * Only error logs
  30351. */
  30352. static readonly ErrorLogLevel: number;
  30353. /**
  30354. * All logs
  30355. */
  30356. static readonly AllLogLevel: number;
  30357. /**
  30358. * Gets a value indicating the number of loading errors
  30359. * @ignorenaming
  30360. */
  30361. static readonly errorsCount: number;
  30362. /**
  30363. * Callback called when a new log is added
  30364. */
  30365. static OnNewCacheEntry: (entry: string) => void;
  30366. /**
  30367. * Log a message to the console
  30368. * @param message defines the message to log
  30369. */
  30370. static Log(message: string): void;
  30371. /**
  30372. * Write a warning message to the console
  30373. * @param message defines the message to log
  30374. */
  30375. static Warn(message: string): void;
  30376. /**
  30377. * Write an error message to the console
  30378. * @param message defines the message to log
  30379. */
  30380. static Error(message: string): void;
  30381. /**
  30382. * Gets current log cache (list of logs)
  30383. */
  30384. static readonly LogCache: string;
  30385. /**
  30386. * Clears the log cache
  30387. */
  30388. static ClearLogCache(): void;
  30389. /**
  30390. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30391. */
  30392. static LogLevels: number;
  30393. /**
  30394. * Checks if the loaded document was accessed via `file:`-Protocol.
  30395. * @returns boolean
  30396. */
  30397. static IsFileURL(): boolean;
  30398. /**
  30399. * Checks if the window object exists
  30400. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30401. */
  30402. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30403. /**
  30404. * No performance log
  30405. */
  30406. static readonly PerformanceNoneLogLevel: number;
  30407. /**
  30408. * Use user marks to log performance
  30409. */
  30410. static readonly PerformanceUserMarkLogLevel: number;
  30411. /**
  30412. * Log performance to the console
  30413. */
  30414. static readonly PerformanceConsoleLogLevel: number;
  30415. private static _performance;
  30416. /**
  30417. * Sets the current performance log level
  30418. */
  30419. static PerformanceLogLevel: number;
  30420. private static _StartPerformanceCounterDisabled;
  30421. private static _EndPerformanceCounterDisabled;
  30422. private static _StartUserMark;
  30423. private static _EndUserMark;
  30424. private static _StartPerformanceConsole;
  30425. private static _EndPerformanceConsole;
  30426. /**
  30427. * Injects the @see CustomRequestHeaders into the given request
  30428. * @param request the request that should be used for injection
  30429. */
  30430. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  30431. /**
  30432. * Starts a performance counter
  30433. */
  30434. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30435. /**
  30436. * Ends a specific performance coutner
  30437. */
  30438. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30439. /**
  30440. * Gets either window.performance.now() if supported or Date.now() else
  30441. */
  30442. static readonly Now: number;
  30443. /**
  30444. * This method will return the name of the class used to create the instance of the given object.
  30445. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30446. * @param object the object to get the class name from
  30447. * @param isType defines if the object is actually a type
  30448. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30449. */
  30450. static GetClassName(object: any, isType?: boolean): string;
  30451. /**
  30452. * Gets the first element of an array satisfying a given predicate
  30453. * @param array defines the array to browse
  30454. * @param predicate defines the predicate to use
  30455. * @returns null if not found or the element
  30456. */
  30457. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30458. /**
  30459. * This method will return the name of the full name of the class, including its owning module (if any).
  30460. * 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).
  30461. * @param object the object to get the class name from
  30462. * @param isType defines if the object is actually a type
  30463. * @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.
  30464. * @ignorenaming
  30465. */
  30466. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30467. /**
  30468. * Returns a promise that resolves after the given amount of time.
  30469. * @param delay Number of milliseconds to delay
  30470. * @returns Promise that resolves after the given amount of time
  30471. */
  30472. static DelayAsync(delay: number): Promise<void>;
  30473. /**
  30474. * Gets the current gradient from an array of IValueGradient
  30475. * @param ratio defines the current ratio to get
  30476. * @param gradients defines the array of IValueGradient
  30477. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30478. */
  30479. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30480. }
  30481. /**
  30482. * This class is used to track a performance counter which is number based.
  30483. * The user has access to many properties which give statistics of different nature.
  30484. *
  30485. * The implementer can track two kinds of Performance Counter: time and count.
  30486. * 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.
  30487. * 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.
  30488. */
  30489. export class PerfCounter {
  30490. /**
  30491. * Gets or sets a global boolean to turn on and off all the counters
  30492. */
  30493. static Enabled: boolean;
  30494. /**
  30495. * Returns the smallest value ever
  30496. */
  30497. readonly min: number;
  30498. /**
  30499. * Returns the biggest value ever
  30500. */
  30501. readonly max: number;
  30502. /**
  30503. * Returns the average value since the performance counter is running
  30504. */
  30505. readonly average: number;
  30506. /**
  30507. * Returns the average value of the last second the counter was monitored
  30508. */
  30509. readonly lastSecAverage: number;
  30510. /**
  30511. * Returns the current value
  30512. */
  30513. readonly current: number;
  30514. /**
  30515. * Gets the accumulated total
  30516. */
  30517. readonly total: number;
  30518. /**
  30519. * Gets the total value count
  30520. */
  30521. readonly count: number;
  30522. /**
  30523. * Creates a new counter
  30524. */
  30525. constructor();
  30526. /**
  30527. * Call this method to start monitoring a new frame.
  30528. * 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.
  30529. */
  30530. fetchNewFrame(): void;
  30531. /**
  30532. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30533. * @param newCount the count value to add to the monitored count
  30534. * @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.
  30535. */
  30536. addCount(newCount: number, fetchResult: boolean): void;
  30537. /**
  30538. * Start monitoring this performance counter
  30539. */
  30540. beginMonitoring(): void;
  30541. /**
  30542. * Compute the time lapsed since the previous beginMonitoring() call.
  30543. * @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
  30544. */
  30545. endMonitoring(newFrame?: boolean): void;
  30546. private _fetchResult;
  30547. private _startMonitoringTime;
  30548. private _min;
  30549. private _max;
  30550. private _average;
  30551. private _current;
  30552. private _totalValueCount;
  30553. private _totalAccumulated;
  30554. private _lastSecAverage;
  30555. private _lastSecAccumulated;
  30556. private _lastSecTime;
  30557. private _lastSecValueCount;
  30558. }
  30559. /**
  30560. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30561. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30562. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30563. * @param name The name of the class, case should be preserved
  30564. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30565. */
  30566. export function className(name: string, module?: string): (target: Object) => void;
  30567. /**
  30568. * An implementation of a loop for asynchronous functions.
  30569. */
  30570. export class AsyncLoop {
  30571. /**
  30572. * Defines the number of iterations for the loop
  30573. */
  30574. iterations: number;
  30575. /**
  30576. * Defines the current index of the loop.
  30577. */
  30578. index: number;
  30579. private _done;
  30580. private _fn;
  30581. private _successCallback;
  30582. /**
  30583. * Constructor.
  30584. * @param iterations the number of iterations.
  30585. * @param func the function to run each iteration
  30586. * @param successCallback the callback that will be called upon succesful execution
  30587. * @param offset starting offset.
  30588. */
  30589. constructor(
  30590. /**
  30591. * Defines the number of iterations for the loop
  30592. */
  30593. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30594. /**
  30595. * Execute the next iteration. Must be called after the last iteration was finished.
  30596. */
  30597. executeNext(): void;
  30598. /**
  30599. * Break the loop and run the success callback.
  30600. */
  30601. breakLoop(): void;
  30602. /**
  30603. * Create and run an async loop.
  30604. * @param iterations the number of iterations.
  30605. * @param fn the function to run each iteration
  30606. * @param successCallback the callback that will be called upon succesful execution
  30607. * @param offset starting offset.
  30608. * @returns the created async loop object
  30609. */
  30610. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30611. /**
  30612. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30613. * @param iterations total number of iterations
  30614. * @param syncedIterations number of synchronous iterations in each async iteration.
  30615. * @param fn the function to call each iteration.
  30616. * @param callback a success call back that will be called when iterating stops.
  30617. * @param breakFunction a break condition (optional)
  30618. * @param timeout timeout settings for the setTimeout function. default - 0.
  30619. * @returns the created async loop object
  30620. */
  30621. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30622. }
  30623. }
  30624. declare module BABYLON {
  30625. /** @hidden */
  30626. export interface ICollisionCoordinator {
  30627. createCollider(): Collider;
  30628. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30629. init(scene: Scene): void;
  30630. }
  30631. /** @hidden */
  30632. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30633. private _scene;
  30634. private _scaledPosition;
  30635. private _scaledVelocity;
  30636. private _finalPosition;
  30637. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30638. createCollider(): Collider;
  30639. init(scene: Scene): void;
  30640. private _collideWithWorld;
  30641. }
  30642. }
  30643. declare module BABYLON {
  30644. /**
  30645. * This class defines the direct association between an animation and a target
  30646. */
  30647. export class TargetedAnimation {
  30648. /**
  30649. * Animation to perform
  30650. */
  30651. animation: Animation;
  30652. /**
  30653. * Target to animate
  30654. */
  30655. target: any;
  30656. }
  30657. /**
  30658. * Use this class to create coordinated animations on multiple targets
  30659. */
  30660. export class AnimationGroup implements IDisposable {
  30661. /** The name of the animation group */
  30662. name: string;
  30663. private _scene;
  30664. private _targetedAnimations;
  30665. private _animatables;
  30666. private _from;
  30667. private _to;
  30668. private _isStarted;
  30669. private _isPaused;
  30670. private _speedRatio;
  30671. /**
  30672. * Gets or sets the unique id of the node
  30673. */
  30674. uniqueId: number;
  30675. /**
  30676. * This observable will notify when one animation have ended
  30677. */
  30678. onAnimationEndObservable: Observable<TargetedAnimation>;
  30679. /**
  30680. * Observer raised when one animation loops
  30681. */
  30682. onAnimationLoopObservable: Observable<TargetedAnimation>;
  30683. /**
  30684. * This observable will notify when all animations have ended.
  30685. */
  30686. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  30687. /**
  30688. * This observable will notify when all animations have paused.
  30689. */
  30690. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  30691. /**
  30692. * This observable will notify when all animations are playing.
  30693. */
  30694. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  30695. /**
  30696. * Gets the first frame
  30697. */
  30698. readonly from: number;
  30699. /**
  30700. * Gets the last frame
  30701. */
  30702. readonly to: number;
  30703. /**
  30704. * Define if the animations are started
  30705. */
  30706. readonly isStarted: boolean;
  30707. /**
  30708. * Gets a value indicating that the current group is playing
  30709. */
  30710. readonly isPlaying: boolean;
  30711. /**
  30712. * Gets or sets the speed ratio to use for all animations
  30713. */
  30714. /**
  30715. * Gets or sets the speed ratio to use for all animations
  30716. */
  30717. speedRatio: number;
  30718. /**
  30719. * Gets the targeted animations for this animation group
  30720. */
  30721. readonly targetedAnimations: Array<TargetedAnimation>;
  30722. /**
  30723. * returning the list of animatables controlled by this animation group.
  30724. */
  30725. readonly animatables: Array<Animatable>;
  30726. /**
  30727. * Instantiates a new Animation Group.
  30728. * This helps managing several animations at once.
  30729. * @see http://doc.babylonjs.com/how_to/group
  30730. * @param name Defines the name of the group
  30731. * @param scene Defines the scene the group belongs to
  30732. */
  30733. constructor(
  30734. /** The name of the animation group */
  30735. name: string, scene?: Nullable<Scene>);
  30736. /**
  30737. * Add an animation (with its target) in the group
  30738. * @param animation defines the animation we want to add
  30739. * @param target defines the target of the animation
  30740. * @returns the TargetedAnimation object
  30741. */
  30742. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  30743. /**
  30744. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  30745. * It can add constant keys at begin or end
  30746. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  30747. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  30748. * @returns the animation group
  30749. */
  30750. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  30751. /**
  30752. * Start all animations on given targets
  30753. * @param loop defines if animations must loop
  30754. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  30755. * @param from defines the from key (optional)
  30756. * @param to defines the to key (optional)
  30757. * @returns the current animation group
  30758. */
  30759. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  30760. /**
  30761. * Pause all animations
  30762. * @returns the animation group
  30763. */
  30764. pause(): AnimationGroup;
  30765. /**
  30766. * Play all animations to initial state
  30767. * This function will start() the animations if they were not started or will restart() them if they were paused
  30768. * @param loop defines if animations must loop
  30769. * @returns the animation group
  30770. */
  30771. play(loop?: boolean): AnimationGroup;
  30772. /**
  30773. * Reset all animations to initial state
  30774. * @returns the animation group
  30775. */
  30776. reset(): AnimationGroup;
  30777. /**
  30778. * Restart animations from key 0
  30779. * @returns the animation group
  30780. */
  30781. restart(): AnimationGroup;
  30782. /**
  30783. * Stop all animations
  30784. * @returns the animation group
  30785. */
  30786. stop(): AnimationGroup;
  30787. /**
  30788. * Set animation weight for all animatables
  30789. * @param weight defines the weight to use
  30790. * @return the animationGroup
  30791. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  30792. */
  30793. setWeightForAllAnimatables(weight: number): AnimationGroup;
  30794. /**
  30795. * Synchronize and normalize all animatables with a source animatable
  30796. * @param root defines the root animatable to synchronize with
  30797. * @return the animationGroup
  30798. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  30799. */
  30800. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  30801. /**
  30802. * Goes to a specific frame in this animation group
  30803. * @param frame the frame number to go to
  30804. * @return the animationGroup
  30805. */
  30806. goToFrame(frame: number): AnimationGroup;
  30807. /**
  30808. * Dispose all associated resources
  30809. */
  30810. dispose(): void;
  30811. private _checkAnimationGroupEnded;
  30812. /**
  30813. * Returns a new AnimationGroup object parsed from the source provided.
  30814. * @param parsedAnimationGroup defines the source
  30815. * @param scene defines the scene that will receive the animationGroup
  30816. * @returns a new AnimationGroup
  30817. */
  30818. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  30819. /**
  30820. * Returns the string "AnimationGroup"
  30821. * @returns "AnimationGroup"
  30822. */
  30823. getClassName(): string;
  30824. /**
  30825. * Creates a detailled string about the object
  30826. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  30827. * @returns a string representing the object
  30828. */
  30829. toString(fullDetails?: boolean): string;
  30830. }
  30831. }
  30832. declare module BABYLON {
  30833. /**
  30834. * Define an interface for all classes that will hold resources
  30835. */
  30836. export interface IDisposable {
  30837. /**
  30838. * Releases all held resources
  30839. */
  30840. dispose(): void;
  30841. }
  30842. /** Interface defining initialization parameters for Scene class */
  30843. export interface SceneOptions {
  30844. /**
  30845. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  30846. * It will improve performance when the number of geometries becomes important.
  30847. */
  30848. useGeometryUniqueIdsMap?: boolean;
  30849. /**
  30850. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  30851. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  30852. */
  30853. useMaterialMeshMap?: boolean;
  30854. /**
  30855. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  30856. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  30857. */
  30858. useClonedMeshhMap?: boolean;
  30859. }
  30860. /**
  30861. * Represents a scene to be rendered by the engine.
  30862. * @see http://doc.babylonjs.com/features/scene
  30863. */
  30864. export class Scene extends AbstractScene implements IAnimatable {
  30865. private static _uniqueIdCounter;
  30866. /** The fog is deactivated */
  30867. static readonly FOGMODE_NONE: number;
  30868. /** The fog density is following an exponential function */
  30869. static readonly FOGMODE_EXP: number;
  30870. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  30871. static readonly FOGMODE_EXP2: number;
  30872. /** The fog density is following a linear function. */
  30873. static readonly FOGMODE_LINEAR: number;
  30874. /**
  30875. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  30876. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30877. */
  30878. static MinDeltaTime: number;
  30879. /**
  30880. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  30881. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30882. */
  30883. static MaxDeltaTime: number;
  30884. /**
  30885. * Factory used to create the default material.
  30886. * @param name The name of the material to create
  30887. * @param scene The scene to create the material for
  30888. * @returns The default material
  30889. */
  30890. static DefaultMaterialFactory(scene: Scene): Material;
  30891. /**
  30892. * Factory used to create the a collision coordinator.
  30893. * @returns The collision coordinator
  30894. */
  30895. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  30896. /** @hidden */
  30897. readonly _isScene: boolean;
  30898. /**
  30899. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  30900. */
  30901. autoClear: boolean;
  30902. /**
  30903. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  30904. */
  30905. autoClearDepthAndStencil: boolean;
  30906. /**
  30907. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  30908. */
  30909. clearColor: Color4;
  30910. /**
  30911. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  30912. */
  30913. ambientColor: Color3;
  30914. /** @hidden */
  30915. _environmentBRDFTexture: BaseTexture;
  30916. /** @hidden */
  30917. protected _environmentTexture: Nullable<BaseTexture>;
  30918. /**
  30919. * Texture used in all pbr material as the reflection texture.
  30920. * As in the majority of the scene they are the same (exception for multi room and so on),
  30921. * this is easier to reference from here than from all the materials.
  30922. */
  30923. /**
  30924. * Texture used in all pbr material as the reflection texture.
  30925. * As in the majority of the scene they are the same (exception for multi room and so on),
  30926. * this is easier to set here than in all the materials.
  30927. */
  30928. environmentTexture: Nullable<BaseTexture>;
  30929. /** @hidden */
  30930. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30931. /**
  30932. * Default image processing configuration used either in the rendering
  30933. * Forward main pass or through the imageProcessingPostProcess if present.
  30934. * As in the majority of the scene they are the same (exception for multi camera),
  30935. * this is easier to reference from here than from all the materials and post process.
  30936. *
  30937. * No setter as we it is a shared configuration, you can set the values instead.
  30938. */
  30939. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  30940. private _forceWireframe;
  30941. /**
  30942. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  30943. */
  30944. forceWireframe: boolean;
  30945. private _forcePointsCloud;
  30946. /**
  30947. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  30948. */
  30949. forcePointsCloud: boolean;
  30950. /**
  30951. * Gets or sets the active clipplane 1
  30952. */
  30953. clipPlane: Nullable<Plane>;
  30954. /**
  30955. * Gets or sets the active clipplane 2
  30956. */
  30957. clipPlane2: Nullable<Plane>;
  30958. /**
  30959. * Gets or sets the active clipplane 3
  30960. */
  30961. clipPlane3: Nullable<Plane>;
  30962. /**
  30963. * Gets or sets the active clipplane 4
  30964. */
  30965. clipPlane4: Nullable<Plane>;
  30966. /**
  30967. * Gets or sets a boolean indicating if animations are enabled
  30968. */
  30969. animationsEnabled: boolean;
  30970. private _animationPropertiesOverride;
  30971. /**
  30972. * Gets or sets the animation properties override
  30973. */
  30974. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  30975. /**
  30976. * Gets or sets a boolean indicating if a constant deltatime has to be used
  30977. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  30978. */
  30979. useConstantAnimationDeltaTime: boolean;
  30980. /**
  30981. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  30982. * Please note that it requires to run a ray cast through the scene on every frame
  30983. */
  30984. constantlyUpdateMeshUnderPointer: boolean;
  30985. /**
  30986. * Defines the HTML cursor to use when hovering over interactive elements
  30987. */
  30988. hoverCursor: string;
  30989. /**
  30990. * Defines the HTML default cursor to use (empty by default)
  30991. */
  30992. defaultCursor: string;
  30993. /**
  30994. * This is used to call preventDefault() on pointer down
  30995. * in order to block unwanted artifacts like system double clicks
  30996. */
  30997. preventDefaultOnPointerDown: boolean;
  30998. /**
  30999. * This is used to call preventDefault() on pointer up
  31000. * in order to block unwanted artifacts like system double clicks
  31001. */
  31002. preventDefaultOnPointerUp: boolean;
  31003. /**
  31004. * Gets or sets user defined metadata
  31005. */
  31006. metadata: any;
  31007. /**
  31008. * For internal use only. Please do not use.
  31009. */
  31010. reservedDataStore: any;
  31011. /**
  31012. * Gets the name of the plugin used to load this scene (null by default)
  31013. */
  31014. loadingPluginName: string;
  31015. /**
  31016. * Use this array to add regular expressions used to disable offline support for specific urls
  31017. */
  31018. disableOfflineSupportExceptionRules: RegExp[];
  31019. /**
  31020. * An event triggered when the scene is disposed.
  31021. */
  31022. onDisposeObservable: Observable<Scene>;
  31023. private _onDisposeObserver;
  31024. /** Sets a function to be executed when this scene is disposed. */
  31025. onDispose: () => void;
  31026. /**
  31027. * An event triggered before rendering the scene (right after animations and physics)
  31028. */
  31029. onBeforeRenderObservable: Observable<Scene>;
  31030. private _onBeforeRenderObserver;
  31031. /** Sets a function to be executed before rendering this scene */
  31032. beforeRender: Nullable<() => void>;
  31033. /**
  31034. * An event triggered after rendering the scene
  31035. */
  31036. onAfterRenderObservable: Observable<Scene>;
  31037. private _onAfterRenderObserver;
  31038. /** Sets a function to be executed after rendering this scene */
  31039. afterRender: Nullable<() => void>;
  31040. /**
  31041. * An event triggered before animating the scene
  31042. */
  31043. onBeforeAnimationsObservable: Observable<Scene>;
  31044. /**
  31045. * An event triggered after animations processing
  31046. */
  31047. onAfterAnimationsObservable: Observable<Scene>;
  31048. /**
  31049. * An event triggered before draw calls are ready to be sent
  31050. */
  31051. onBeforeDrawPhaseObservable: Observable<Scene>;
  31052. /**
  31053. * An event triggered after draw calls have been sent
  31054. */
  31055. onAfterDrawPhaseObservable: Observable<Scene>;
  31056. /**
  31057. * An event triggered when the scene is ready
  31058. */
  31059. onReadyObservable: Observable<Scene>;
  31060. /**
  31061. * An event triggered before rendering a camera
  31062. */
  31063. onBeforeCameraRenderObservable: Observable<Camera>;
  31064. private _onBeforeCameraRenderObserver;
  31065. /** Sets a function to be executed before rendering a camera*/
  31066. beforeCameraRender: () => void;
  31067. /**
  31068. * An event triggered after rendering a camera
  31069. */
  31070. onAfterCameraRenderObservable: Observable<Camera>;
  31071. private _onAfterCameraRenderObserver;
  31072. /** Sets a function to be executed after rendering a camera*/
  31073. afterCameraRender: () => void;
  31074. /**
  31075. * An event triggered when active meshes evaluation is about to start
  31076. */
  31077. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31078. /**
  31079. * An event triggered when active meshes evaluation is done
  31080. */
  31081. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31082. /**
  31083. * An event triggered when particles rendering is about to start
  31084. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31085. */
  31086. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31087. /**
  31088. * An event triggered when particles rendering is done
  31089. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31090. */
  31091. onAfterParticlesRenderingObservable: Observable<Scene>;
  31092. /**
  31093. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31094. */
  31095. onDataLoadedObservable: Observable<Scene>;
  31096. /**
  31097. * An event triggered when a camera is created
  31098. */
  31099. onNewCameraAddedObservable: Observable<Camera>;
  31100. /**
  31101. * An event triggered when a camera is removed
  31102. */
  31103. onCameraRemovedObservable: Observable<Camera>;
  31104. /**
  31105. * An event triggered when a light is created
  31106. */
  31107. onNewLightAddedObservable: Observable<Light>;
  31108. /**
  31109. * An event triggered when a light is removed
  31110. */
  31111. onLightRemovedObservable: Observable<Light>;
  31112. /**
  31113. * An event triggered when a geometry is created
  31114. */
  31115. onNewGeometryAddedObservable: Observable<Geometry>;
  31116. /**
  31117. * An event triggered when a geometry is removed
  31118. */
  31119. onGeometryRemovedObservable: Observable<Geometry>;
  31120. /**
  31121. * An event triggered when a transform node is created
  31122. */
  31123. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31124. /**
  31125. * An event triggered when a transform node is removed
  31126. */
  31127. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31128. /**
  31129. * An event triggered when a mesh is created
  31130. */
  31131. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31132. /**
  31133. * An event triggered when a mesh is removed
  31134. */
  31135. onMeshRemovedObservable: Observable<AbstractMesh>;
  31136. /**
  31137. * An event triggered when a material is created
  31138. */
  31139. onNewMaterialAddedObservable: Observable<Material>;
  31140. /**
  31141. * An event triggered when a material is removed
  31142. */
  31143. onMaterialRemovedObservable: Observable<Material>;
  31144. /**
  31145. * An event triggered when a texture is created
  31146. */
  31147. onNewTextureAddedObservable: Observable<BaseTexture>;
  31148. /**
  31149. * An event triggered when a texture is removed
  31150. */
  31151. onTextureRemovedObservable: Observable<BaseTexture>;
  31152. /**
  31153. * An event triggered when render targets are about to be rendered
  31154. * Can happen multiple times per frame.
  31155. */
  31156. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31157. /**
  31158. * An event triggered when render targets were rendered.
  31159. * Can happen multiple times per frame.
  31160. */
  31161. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31162. /**
  31163. * An event triggered before calculating deterministic simulation step
  31164. */
  31165. onBeforeStepObservable: Observable<Scene>;
  31166. /**
  31167. * An event triggered after calculating deterministic simulation step
  31168. */
  31169. onAfterStepObservable: Observable<Scene>;
  31170. /**
  31171. * An event triggered when the activeCamera property is updated
  31172. */
  31173. onActiveCameraChanged: Observable<Scene>;
  31174. /**
  31175. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31176. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31177. * 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)
  31178. */
  31179. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31180. /**
  31181. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31182. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31183. * 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)
  31184. */
  31185. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31186. /**
  31187. * This Observable will when a mesh has been imported into the scene.
  31188. */
  31189. onMeshImportedObservable: Observable<AbstractMesh>;
  31190. /** @hidden */
  31191. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31192. /**
  31193. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31194. */
  31195. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31196. /**
  31197. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31198. */
  31199. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31200. /**
  31201. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31202. */
  31203. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31204. private _onPointerMove;
  31205. private _onPointerDown;
  31206. private _onPointerUp;
  31207. /** Callback called when a pointer move is detected */
  31208. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31209. /** Callback called when a pointer down is detected */
  31210. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31211. /** Callback called when a pointer up is detected */
  31212. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31213. /** Callback called when a pointer pick is detected */
  31214. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31215. /**
  31216. * 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).
  31217. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31218. */
  31219. onPrePointerObservable: Observable<PointerInfoPre>;
  31220. /**
  31221. * Observable event triggered each time an input event is received from the rendering canvas
  31222. */
  31223. onPointerObservable: Observable<PointerInfo>;
  31224. /**
  31225. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31226. */
  31227. readonly unTranslatedPointer: Vector2;
  31228. /** The distance in pixel that you have to move to prevent some events */
  31229. static DragMovementThreshold: number;
  31230. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31231. static LongPressDelay: number;
  31232. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31233. static DoubleClickDelay: number;
  31234. /** If you need to check double click without raising a single click at first click, enable this flag */
  31235. static ExclusiveDoubleClickMode: boolean;
  31236. private _initClickEvent;
  31237. private _initActionManager;
  31238. private _delayedSimpleClick;
  31239. private _delayedSimpleClickTimeout;
  31240. private _previousDelayedSimpleClickTimeout;
  31241. private _meshPickProceed;
  31242. private _previousButtonPressed;
  31243. private _currentPickResult;
  31244. private _previousPickResult;
  31245. private _totalPointersPressed;
  31246. private _doubleClickOccured;
  31247. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31248. cameraToUseForPointers: Nullable<Camera>;
  31249. private _pointerX;
  31250. private _pointerY;
  31251. private _unTranslatedPointerX;
  31252. private _unTranslatedPointerY;
  31253. private _startingPointerPosition;
  31254. private _previousStartingPointerPosition;
  31255. private _startingPointerTime;
  31256. private _previousStartingPointerTime;
  31257. private _pointerCaptures;
  31258. private _timeAccumulator;
  31259. private _currentStepId;
  31260. private _currentInternalStep;
  31261. /** @hidden */
  31262. _mirroredCameraPosition: Nullable<Vector3>;
  31263. /**
  31264. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31265. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31266. */
  31267. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31268. /**
  31269. * Observable event triggered each time an keyboard event is received from the hosting window
  31270. */
  31271. onKeyboardObservable: Observable<KeyboardInfo>;
  31272. private _onKeyDown;
  31273. private _onKeyUp;
  31274. private _onCanvasFocusObserver;
  31275. private _onCanvasBlurObserver;
  31276. private _useRightHandedSystem;
  31277. /**
  31278. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31279. */
  31280. useRightHandedSystem: boolean;
  31281. /**
  31282. * Sets the step Id used by deterministic lock step
  31283. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31284. * @param newStepId defines the step Id
  31285. */
  31286. setStepId(newStepId: number): void;
  31287. /**
  31288. * Gets the step Id used by deterministic lock step
  31289. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31290. * @returns the step Id
  31291. */
  31292. getStepId(): number;
  31293. /**
  31294. * Gets the internal step used by deterministic lock step
  31295. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31296. * @returns the internal step
  31297. */
  31298. getInternalStep(): number;
  31299. private _fogEnabled;
  31300. /**
  31301. * Gets or sets a boolean indicating if fog is enabled on this scene
  31302. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31303. * (Default is true)
  31304. */
  31305. fogEnabled: boolean;
  31306. private _fogMode;
  31307. /**
  31308. * Gets or sets the fog mode to use
  31309. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31310. * | mode | value |
  31311. * | --- | --- |
  31312. * | FOGMODE_NONE | 0 |
  31313. * | FOGMODE_EXP | 1 |
  31314. * | FOGMODE_EXP2 | 2 |
  31315. * | FOGMODE_LINEAR | 3 |
  31316. */
  31317. fogMode: number;
  31318. /**
  31319. * Gets or sets the fog color to use
  31320. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31321. * (Default is Color3(0.2, 0.2, 0.3))
  31322. */
  31323. fogColor: Color3;
  31324. /**
  31325. * Gets or sets the fog density to use
  31326. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31327. * (Default is 0.1)
  31328. */
  31329. fogDensity: number;
  31330. /**
  31331. * Gets or sets the fog start distance to use
  31332. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31333. * (Default is 0)
  31334. */
  31335. fogStart: number;
  31336. /**
  31337. * Gets or sets the fog end distance to use
  31338. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31339. * (Default is 1000)
  31340. */
  31341. fogEnd: number;
  31342. private _shadowsEnabled;
  31343. /**
  31344. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31345. */
  31346. shadowsEnabled: boolean;
  31347. private _lightsEnabled;
  31348. /**
  31349. * Gets or sets a boolean indicating if lights are enabled on this scene
  31350. */
  31351. lightsEnabled: boolean;
  31352. /** All of the active cameras added to this scene. */
  31353. activeCameras: Camera[];
  31354. private _activeCamera;
  31355. /** Gets or sets the current active camera */
  31356. activeCamera: Nullable<Camera>;
  31357. private _defaultMaterial;
  31358. /** The default material used on meshes when no material is affected */
  31359. /** The default material used on meshes when no material is affected */
  31360. defaultMaterial: Material;
  31361. private _texturesEnabled;
  31362. /**
  31363. * Gets or sets a boolean indicating if textures are enabled on this scene
  31364. */
  31365. texturesEnabled: boolean;
  31366. /**
  31367. * Gets or sets a boolean indicating if particles are enabled on this scene
  31368. */
  31369. particlesEnabled: boolean;
  31370. /**
  31371. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31372. */
  31373. spritesEnabled: boolean;
  31374. private _skeletonsEnabled;
  31375. /**
  31376. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31377. */
  31378. skeletonsEnabled: boolean;
  31379. /**
  31380. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31381. */
  31382. lensFlaresEnabled: boolean;
  31383. /**
  31384. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31385. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31386. */
  31387. collisionsEnabled: boolean;
  31388. private _collisionCoordinator;
  31389. /** @hidden */
  31390. readonly collisionCoordinator: ICollisionCoordinator;
  31391. /**
  31392. * Defines the gravity applied to this scene (used only for collisions)
  31393. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31394. */
  31395. gravity: Vector3;
  31396. /**
  31397. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31398. */
  31399. postProcessesEnabled: boolean;
  31400. /**
  31401. * The list of postprocesses added to the scene
  31402. */
  31403. postProcesses: PostProcess[];
  31404. /**
  31405. * Gets the current postprocess manager
  31406. */
  31407. postProcessManager: PostProcessManager;
  31408. /**
  31409. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31410. */
  31411. renderTargetsEnabled: boolean;
  31412. /**
  31413. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31414. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31415. */
  31416. dumpNextRenderTargets: boolean;
  31417. /**
  31418. * The list of user defined render targets added to the scene
  31419. */
  31420. customRenderTargets: RenderTargetTexture[];
  31421. /**
  31422. * Defines if texture loading must be delayed
  31423. * If true, textures will only be loaded when they need to be rendered
  31424. */
  31425. useDelayedTextureLoading: boolean;
  31426. /**
  31427. * Gets the list of meshes imported to the scene through SceneLoader
  31428. */
  31429. importedMeshesFiles: String[];
  31430. /**
  31431. * Gets or sets a boolean indicating if probes are enabled on this scene
  31432. */
  31433. probesEnabled: boolean;
  31434. /**
  31435. * Gets or sets the current offline provider to use to store scene data
  31436. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31437. */
  31438. offlineProvider: IOfflineProvider;
  31439. /**
  31440. * Gets or sets the action manager associated with the scene
  31441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31442. */
  31443. actionManager: AbstractActionManager;
  31444. private _meshesForIntersections;
  31445. /**
  31446. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31447. */
  31448. proceduralTexturesEnabled: boolean;
  31449. private _engine;
  31450. private _totalVertices;
  31451. /** @hidden */
  31452. _activeIndices: PerfCounter;
  31453. /** @hidden */
  31454. _activeParticles: PerfCounter;
  31455. /** @hidden */
  31456. _activeBones: PerfCounter;
  31457. private _animationRatio;
  31458. /** @hidden */
  31459. _animationTimeLast: number;
  31460. /** @hidden */
  31461. _animationTime: number;
  31462. /**
  31463. * Gets or sets a general scale for animation speed
  31464. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31465. */
  31466. animationTimeScale: number;
  31467. /** @hidden */
  31468. _cachedMaterial: Nullable<Material>;
  31469. /** @hidden */
  31470. _cachedEffect: Nullable<Effect>;
  31471. /** @hidden */
  31472. _cachedVisibility: Nullable<number>;
  31473. private _renderId;
  31474. private _frameId;
  31475. private _executeWhenReadyTimeoutId;
  31476. private _intermediateRendering;
  31477. private _viewUpdateFlag;
  31478. private _projectionUpdateFlag;
  31479. private _alternateViewUpdateFlag;
  31480. private _alternateProjectionUpdateFlag;
  31481. /** @hidden */
  31482. _toBeDisposed: Nullable<IDisposable>[];
  31483. private _activeRequests;
  31484. /** @hidden */
  31485. _pendingData: any[];
  31486. private _isDisposed;
  31487. /**
  31488. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31489. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31490. */
  31491. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31492. private _activeMeshes;
  31493. private _processedMaterials;
  31494. private _renderTargets;
  31495. /** @hidden */
  31496. _activeParticleSystems: SmartArray<IParticleSystem>;
  31497. private _activeSkeletons;
  31498. private _softwareSkinnedMeshes;
  31499. private _renderingManager;
  31500. /** @hidden */
  31501. _activeAnimatables: Animatable[];
  31502. private _transformMatrix;
  31503. private _sceneUbo;
  31504. private _alternateSceneUbo;
  31505. private _viewMatrix;
  31506. private _projectionMatrix;
  31507. private _alternateViewMatrix;
  31508. private _alternateProjectionMatrix;
  31509. private _alternateTransformMatrix;
  31510. private _useAlternateCameraConfiguration;
  31511. private _alternateRendering;
  31512. private _wheelEventName;
  31513. /** @hidden */
  31514. _forcedViewPosition: Nullable<Vector3>;
  31515. /** @hidden */
  31516. readonly _isAlternateRenderingEnabled: boolean;
  31517. private _frustumPlanes;
  31518. /**
  31519. * Gets the list of frustum planes (built from the active camera)
  31520. */
  31521. readonly frustumPlanes: Plane[];
  31522. /**
  31523. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31524. * This is useful if there are more lights that the maximum simulteanous authorized
  31525. */
  31526. requireLightSorting: boolean;
  31527. /** @hidden */
  31528. readonly useMaterialMeshMap: boolean;
  31529. /** @hidden */
  31530. readonly useClonedMeshhMap: boolean;
  31531. private _pointerOverMesh;
  31532. private _pickedDownMesh;
  31533. private _pickedUpMesh;
  31534. private _externalData;
  31535. private _uid;
  31536. /**
  31537. * @hidden
  31538. * Backing store of defined scene components.
  31539. */
  31540. _components: ISceneComponent[];
  31541. /**
  31542. * @hidden
  31543. * Backing store of defined scene components.
  31544. */
  31545. _serializableComponents: ISceneSerializableComponent[];
  31546. /**
  31547. * List of components to register on the next registration step.
  31548. */
  31549. private _transientComponents;
  31550. /**
  31551. * Registers the transient components if needed.
  31552. */
  31553. private _registerTransientComponents;
  31554. /**
  31555. * @hidden
  31556. * Add a component to the scene.
  31557. * Note that the ccomponent could be registered on th next frame if this is called after
  31558. * the register component stage.
  31559. * @param component Defines the component to add to the scene
  31560. */
  31561. _addComponent(component: ISceneComponent): void;
  31562. /**
  31563. * @hidden
  31564. * Gets a component from the scene.
  31565. * @param name defines the name of the component to retrieve
  31566. * @returns the component or null if not present
  31567. */
  31568. _getComponent(name: string): Nullable<ISceneComponent>;
  31569. /**
  31570. * @hidden
  31571. * Defines the actions happening before camera updates.
  31572. */
  31573. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31574. /**
  31575. * @hidden
  31576. * Defines the actions happening before clear the canvas.
  31577. */
  31578. _beforeClearStage: Stage<SimpleStageAction>;
  31579. /**
  31580. * @hidden
  31581. * Defines the actions when collecting render targets for the frame.
  31582. */
  31583. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31584. /**
  31585. * @hidden
  31586. * Defines the actions happening for one camera in the frame.
  31587. */
  31588. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31589. /**
  31590. * @hidden
  31591. * Defines the actions happening during the per mesh ready checks.
  31592. */
  31593. _isReadyForMeshStage: Stage<MeshStageAction>;
  31594. /**
  31595. * @hidden
  31596. * Defines the actions happening before evaluate active mesh checks.
  31597. */
  31598. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  31599. /**
  31600. * @hidden
  31601. * Defines the actions happening during the evaluate sub mesh checks.
  31602. */
  31603. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  31604. /**
  31605. * @hidden
  31606. * Defines the actions happening during the active mesh stage.
  31607. */
  31608. _activeMeshStage: Stage<ActiveMeshStageAction>;
  31609. /**
  31610. * @hidden
  31611. * Defines the actions happening during the per camera render target step.
  31612. */
  31613. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  31614. /**
  31615. * @hidden
  31616. * Defines the actions happening just before the active camera is drawing.
  31617. */
  31618. _beforeCameraDrawStage: Stage<CameraStageAction>;
  31619. /**
  31620. * @hidden
  31621. * Defines the actions happening just before a render target is drawing.
  31622. */
  31623. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31624. /**
  31625. * @hidden
  31626. * Defines the actions happening just before a rendering group is drawing.
  31627. */
  31628. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31629. /**
  31630. * @hidden
  31631. * Defines the actions happening just before a mesh is drawing.
  31632. */
  31633. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31634. /**
  31635. * @hidden
  31636. * Defines the actions happening just after a mesh has been drawn.
  31637. */
  31638. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31639. /**
  31640. * @hidden
  31641. * Defines the actions happening just after a rendering group has been drawn.
  31642. */
  31643. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31644. /**
  31645. * @hidden
  31646. * Defines the actions happening just after the active camera has been drawn.
  31647. */
  31648. _afterCameraDrawStage: Stage<CameraStageAction>;
  31649. /**
  31650. * @hidden
  31651. * Defines the actions happening just after a render target has been drawn.
  31652. */
  31653. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31654. /**
  31655. * @hidden
  31656. * Defines the actions happening just after rendering all cameras and computing intersections.
  31657. */
  31658. _afterRenderStage: Stage<SimpleStageAction>;
  31659. /**
  31660. * @hidden
  31661. * Defines the actions happening when a pointer move event happens.
  31662. */
  31663. _pointerMoveStage: Stage<PointerMoveStageAction>;
  31664. /**
  31665. * @hidden
  31666. * Defines the actions happening when a pointer down event happens.
  31667. */
  31668. _pointerDownStage: Stage<PointerUpDownStageAction>;
  31669. /**
  31670. * @hidden
  31671. * Defines the actions happening when a pointer up event happens.
  31672. */
  31673. _pointerUpStage: Stage<PointerUpDownStageAction>;
  31674. /**
  31675. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  31676. */
  31677. private geometriesByUniqueId;
  31678. /**
  31679. * Creates a new Scene
  31680. * @param engine defines the engine to use to render this scene
  31681. * @param options defines the scene options
  31682. */
  31683. constructor(engine: Engine, options?: SceneOptions);
  31684. private _defaultMeshCandidates;
  31685. /**
  31686. * @hidden
  31687. */
  31688. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  31689. private _defaultSubMeshCandidates;
  31690. /**
  31691. * @hidden
  31692. */
  31693. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  31694. /**
  31695. * Sets the default candidate providers for the scene.
  31696. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  31697. * and getCollidingSubMeshCandidates to their default function
  31698. */
  31699. setDefaultCandidateProviders(): void;
  31700. /**
  31701. * Gets the mesh that is currently under the pointer
  31702. */
  31703. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31704. /**
  31705. * Gets or sets the current on-screen X position of the pointer
  31706. */
  31707. pointerX: number;
  31708. /**
  31709. * Gets or sets the current on-screen Y position of the pointer
  31710. */
  31711. pointerY: number;
  31712. /**
  31713. * Gets the cached material (ie. the latest rendered one)
  31714. * @returns the cached material
  31715. */
  31716. getCachedMaterial(): Nullable<Material>;
  31717. /**
  31718. * Gets the cached effect (ie. the latest rendered one)
  31719. * @returns the cached effect
  31720. */
  31721. getCachedEffect(): Nullable<Effect>;
  31722. /**
  31723. * Gets the cached visibility state (ie. the latest rendered one)
  31724. * @returns the cached visibility state
  31725. */
  31726. getCachedVisibility(): Nullable<number>;
  31727. /**
  31728. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  31729. * @param material defines the current material
  31730. * @param effect defines the current effect
  31731. * @param visibility defines the current visibility state
  31732. * @returns true if one parameter is not cached
  31733. */
  31734. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  31735. /**
  31736. * Gets the engine associated with the scene
  31737. * @returns an Engine
  31738. */
  31739. getEngine(): Engine;
  31740. /**
  31741. * Gets the total number of vertices rendered per frame
  31742. * @returns the total number of vertices rendered per frame
  31743. */
  31744. getTotalVertices(): number;
  31745. /**
  31746. * Gets the performance counter for total vertices
  31747. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31748. */
  31749. readonly totalVerticesPerfCounter: PerfCounter;
  31750. /**
  31751. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  31752. * @returns the total number of active indices rendered per frame
  31753. */
  31754. getActiveIndices(): number;
  31755. /**
  31756. * Gets the performance counter for active indices
  31757. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31758. */
  31759. readonly totalActiveIndicesPerfCounter: PerfCounter;
  31760. /**
  31761. * Gets the total number of active particles rendered per frame
  31762. * @returns the total number of active particles rendered per frame
  31763. */
  31764. getActiveParticles(): number;
  31765. /**
  31766. * Gets the performance counter for active particles
  31767. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31768. */
  31769. readonly activeParticlesPerfCounter: PerfCounter;
  31770. /**
  31771. * Gets the total number of active bones rendered per frame
  31772. * @returns the total number of active bones rendered per frame
  31773. */
  31774. getActiveBones(): number;
  31775. /**
  31776. * Gets the performance counter for active bones
  31777. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31778. */
  31779. readonly activeBonesPerfCounter: PerfCounter;
  31780. /**
  31781. * Gets the array of active meshes
  31782. * @returns an array of AbstractMesh
  31783. */
  31784. getActiveMeshes(): SmartArray<AbstractMesh>;
  31785. /**
  31786. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  31787. * @returns a number
  31788. */
  31789. getAnimationRatio(): number;
  31790. /**
  31791. * Gets an unique Id for the current render phase
  31792. * @returns a number
  31793. */
  31794. getRenderId(): number;
  31795. /**
  31796. * Gets an unique Id for the current frame
  31797. * @returns a number
  31798. */
  31799. getFrameId(): number;
  31800. /** Call this function if you want to manually increment the render Id*/
  31801. incrementRenderId(): void;
  31802. private _updatePointerPosition;
  31803. private _createUbo;
  31804. private _createAlternateUbo;
  31805. private _setRayOnPointerInfo;
  31806. /**
  31807. * Use this method to simulate a pointer move on a mesh
  31808. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31809. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31810. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31811. * @returns the current scene
  31812. */
  31813. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  31814. private _processPointerMove;
  31815. private _checkPrePointerObservable;
  31816. /**
  31817. * Use this method to simulate a pointer down on a mesh
  31818. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31819. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31820. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31821. * @returns the current scene
  31822. */
  31823. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  31824. private _processPointerDown;
  31825. /**
  31826. * Use this method to simulate a pointer up on a mesh
  31827. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31828. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31829. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31830. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31831. * @returns the current scene
  31832. */
  31833. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  31834. private _processPointerUp;
  31835. /**
  31836. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31837. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31838. * @returns true if the pointer was captured
  31839. */
  31840. isPointerCaptured(pointerId?: number): boolean;
  31841. /** @hidden */
  31842. _isPointerSwiping(): boolean;
  31843. /**
  31844. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31845. * @param attachUp defines if you want to attach events to pointerup
  31846. * @param attachDown defines if you want to attach events to pointerdown
  31847. * @param attachMove defines if you want to attach events to pointermove
  31848. */
  31849. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31850. /** Detaches all event handlers*/
  31851. detachControl(): void;
  31852. /**
  31853. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  31854. * Delay loaded resources are not taking in account
  31855. * @return true if all required resources are ready
  31856. */
  31857. isReady(): boolean;
  31858. /** Resets all cached information relative to material (including effect and visibility) */
  31859. resetCachedMaterial(): void;
  31860. /**
  31861. * Registers a function to be called before every frame render
  31862. * @param func defines the function to register
  31863. */
  31864. registerBeforeRender(func: () => void): void;
  31865. /**
  31866. * Unregisters a function called before every frame render
  31867. * @param func defines the function to unregister
  31868. */
  31869. unregisterBeforeRender(func: () => void): void;
  31870. /**
  31871. * Registers a function to be called after every frame render
  31872. * @param func defines the function to register
  31873. */
  31874. registerAfterRender(func: () => void): void;
  31875. /**
  31876. * Unregisters a function called after every frame render
  31877. * @param func defines the function to unregister
  31878. */
  31879. unregisterAfterRender(func: () => void): void;
  31880. private _executeOnceBeforeRender;
  31881. /**
  31882. * The provided function will run before render once and will be disposed afterwards.
  31883. * A timeout delay can be provided so that the function will be executed in N ms.
  31884. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  31885. * @param func The function to be executed.
  31886. * @param timeout optional delay in ms
  31887. */
  31888. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  31889. /** @hidden */
  31890. _addPendingData(data: any): void;
  31891. /** @hidden */
  31892. _removePendingData(data: any): void;
  31893. /**
  31894. * Returns the number of items waiting to be loaded
  31895. * @returns the number of items waiting to be loaded
  31896. */
  31897. getWaitingItemsCount(): number;
  31898. /**
  31899. * Returns a boolean indicating if the scene is still loading data
  31900. */
  31901. readonly isLoading: boolean;
  31902. /**
  31903. * Registers a function to be executed when the scene is ready
  31904. * @param {Function} func - the function to be executed
  31905. */
  31906. executeWhenReady(func: () => void): void;
  31907. /**
  31908. * Returns a promise that resolves when the scene is ready
  31909. * @returns A promise that resolves when the scene is ready
  31910. */
  31911. whenReadyAsync(): Promise<void>;
  31912. /** @hidden */
  31913. _checkIsReady(): void;
  31914. /**
  31915. * Gets all animatable attached to the scene
  31916. */
  31917. readonly animatables: Animatable[];
  31918. /**
  31919. * Resets the last animation time frame.
  31920. * Useful to override when animations start running when loading a scene for the first time.
  31921. */
  31922. resetLastAnimationTimeFrame(): void;
  31923. /** @hidden */
  31924. _switchToAlternateCameraConfiguration(active: boolean): void;
  31925. /**
  31926. * Gets the current view matrix
  31927. * @returns a Matrix
  31928. */
  31929. getViewMatrix(): Matrix;
  31930. /**
  31931. * Gets the current projection matrix
  31932. * @returns a Matrix
  31933. */
  31934. getProjectionMatrix(): Matrix;
  31935. /**
  31936. * Gets the current transform matrix
  31937. * @returns a Matrix made of View * Projection
  31938. */
  31939. getTransformMatrix(): Matrix;
  31940. /**
  31941. * Sets the current transform matrix
  31942. * @param view defines the View matrix to use
  31943. * @param projection defines the Projection matrix to use
  31944. */
  31945. setTransformMatrix(view: Matrix, projection: Matrix): void;
  31946. /** @hidden */
  31947. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  31948. /**
  31949. * Gets the uniform buffer used to store scene data
  31950. * @returns a UniformBuffer
  31951. */
  31952. getSceneUniformBuffer(): UniformBuffer;
  31953. /**
  31954. * Gets an unique (relatively to the current scene) Id
  31955. * @returns an unique number for the scene
  31956. */
  31957. getUniqueId(): number;
  31958. /**
  31959. * Add a mesh to the list of scene's meshes
  31960. * @param newMesh defines the mesh to add
  31961. * @param recursive if all child meshes should also be added to the scene
  31962. */
  31963. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  31964. /**
  31965. * Remove a mesh for the list of scene's meshes
  31966. * @param toRemove defines the mesh to remove
  31967. * @param recursive if all child meshes should also be removed from the scene
  31968. * @returns the index where the mesh was in the mesh list
  31969. */
  31970. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  31971. /**
  31972. * Add a transform node to the list of scene's transform nodes
  31973. * @param newTransformNode defines the transform node to add
  31974. */
  31975. addTransformNode(newTransformNode: TransformNode): void;
  31976. /**
  31977. * Remove a transform node for the list of scene's transform nodes
  31978. * @param toRemove defines the transform node to remove
  31979. * @returns the index where the transform node was in the transform node list
  31980. */
  31981. removeTransformNode(toRemove: TransformNode): number;
  31982. /**
  31983. * Remove a skeleton for the list of scene's skeletons
  31984. * @param toRemove defines the skeleton to remove
  31985. * @returns the index where the skeleton was in the skeleton list
  31986. */
  31987. removeSkeleton(toRemove: Skeleton): number;
  31988. /**
  31989. * Remove a morph target for the list of scene's morph targets
  31990. * @param toRemove defines the morph target to remove
  31991. * @returns the index where the morph target was in the morph target list
  31992. */
  31993. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  31994. /**
  31995. * Remove a light for the list of scene's lights
  31996. * @param toRemove defines the light to remove
  31997. * @returns the index where the light was in the light list
  31998. */
  31999. removeLight(toRemove: Light): number;
  32000. /**
  32001. * Remove a camera for the list of scene's cameras
  32002. * @param toRemove defines the camera to remove
  32003. * @returns the index where the camera was in the camera list
  32004. */
  32005. removeCamera(toRemove: Camera): number;
  32006. /**
  32007. * Remove a particle system for the list of scene's particle systems
  32008. * @param toRemove defines the particle system to remove
  32009. * @returns the index where the particle system was in the particle system list
  32010. */
  32011. removeParticleSystem(toRemove: IParticleSystem): number;
  32012. /**
  32013. * Remove a animation for the list of scene's animations
  32014. * @param toRemove defines the animation to remove
  32015. * @returns the index where the animation was in the animation list
  32016. */
  32017. removeAnimation(toRemove: Animation): number;
  32018. /**
  32019. * Removes the given animation group from this scene.
  32020. * @param toRemove The animation group to remove
  32021. * @returns The index of the removed animation group
  32022. */
  32023. removeAnimationGroup(toRemove: AnimationGroup): number;
  32024. /**
  32025. * Removes the given multi-material from this scene.
  32026. * @param toRemove The multi-material to remove
  32027. * @returns The index of the removed multi-material
  32028. */
  32029. removeMultiMaterial(toRemove: MultiMaterial): number;
  32030. /**
  32031. * Removes the given material from this scene.
  32032. * @param toRemove The material to remove
  32033. * @returns The index of the removed material
  32034. */
  32035. removeMaterial(toRemove: Material): number;
  32036. /**
  32037. * Removes the given action manager from this scene.
  32038. * @param toRemove The action manager to remove
  32039. * @returns The index of the removed action manager
  32040. */
  32041. removeActionManager(toRemove: AbstractActionManager): number;
  32042. /**
  32043. * Removes the given texture from this scene.
  32044. * @param toRemove The texture to remove
  32045. * @returns The index of the removed texture
  32046. */
  32047. removeTexture(toRemove: BaseTexture): number;
  32048. /**
  32049. * Adds the given light to this scene
  32050. * @param newLight The light to add
  32051. */
  32052. addLight(newLight: Light): void;
  32053. /**
  32054. * Sorts the list list based on light priorities
  32055. */
  32056. sortLightsByPriority(): void;
  32057. /**
  32058. * Adds the given camera to this scene
  32059. * @param newCamera The camera to add
  32060. */
  32061. addCamera(newCamera: Camera): void;
  32062. /**
  32063. * Adds the given skeleton to this scene
  32064. * @param newSkeleton The skeleton to add
  32065. */
  32066. addSkeleton(newSkeleton: Skeleton): void;
  32067. /**
  32068. * Adds the given particle system to this scene
  32069. * @param newParticleSystem The particle system to add
  32070. */
  32071. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32072. /**
  32073. * Adds the given animation to this scene
  32074. * @param newAnimation The animation to add
  32075. */
  32076. addAnimation(newAnimation: Animation): void;
  32077. /**
  32078. * Adds the given animation group to this scene.
  32079. * @param newAnimationGroup The animation group to add
  32080. */
  32081. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32082. /**
  32083. * Adds the given multi-material to this scene
  32084. * @param newMultiMaterial The multi-material to add
  32085. */
  32086. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32087. /**
  32088. * Adds the given material to this scene
  32089. * @param newMaterial The material to add
  32090. */
  32091. addMaterial(newMaterial: Material): void;
  32092. /**
  32093. * Adds the given morph target to this scene
  32094. * @param newMorphTargetManager The morph target to add
  32095. */
  32096. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32097. /**
  32098. * Adds the given geometry to this scene
  32099. * @param newGeometry The geometry to add
  32100. */
  32101. addGeometry(newGeometry: Geometry): void;
  32102. /**
  32103. * Adds the given action manager to this scene
  32104. * @param newActionManager The action manager to add
  32105. */
  32106. addActionManager(newActionManager: AbstractActionManager): void;
  32107. /**
  32108. * Adds the given texture to this scene.
  32109. * @param newTexture The texture to add
  32110. */
  32111. addTexture(newTexture: BaseTexture): void;
  32112. /**
  32113. * Switch active camera
  32114. * @param newCamera defines the new active camera
  32115. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32116. */
  32117. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32118. /**
  32119. * sets the active camera of the scene using its ID
  32120. * @param id defines the camera's ID
  32121. * @return the new active camera or null if none found.
  32122. */
  32123. setActiveCameraByID(id: string): Nullable<Camera>;
  32124. /**
  32125. * sets the active camera of the scene using its name
  32126. * @param name defines the camera's name
  32127. * @returns the new active camera or null if none found.
  32128. */
  32129. setActiveCameraByName(name: string): Nullable<Camera>;
  32130. /**
  32131. * get an animation group using its name
  32132. * @param name defines the material's name
  32133. * @return the animation group or null if none found.
  32134. */
  32135. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32136. /**
  32137. * get a material using its id
  32138. * @param id defines the material's ID
  32139. * @return the material or null if none found.
  32140. */
  32141. getMaterialByID(id: string): Nullable<Material>;
  32142. /**
  32143. * Gets a material using its name
  32144. * @param name defines the material's name
  32145. * @return the material or null if none found.
  32146. */
  32147. getMaterialByName(name: string): Nullable<Material>;
  32148. /**
  32149. * Gets a camera using its id
  32150. * @param id defines the id to look for
  32151. * @returns the camera or null if not found
  32152. */
  32153. getCameraByID(id: string): Nullable<Camera>;
  32154. /**
  32155. * Gets a camera using its unique id
  32156. * @param uniqueId defines the unique id to look for
  32157. * @returns the camera or null if not found
  32158. */
  32159. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32160. /**
  32161. * Gets a camera using its name
  32162. * @param name defines the camera's name
  32163. * @return the camera or null if none found.
  32164. */
  32165. getCameraByName(name: string): Nullable<Camera>;
  32166. /**
  32167. * Gets a bone using its id
  32168. * @param id defines the bone's id
  32169. * @return the bone or null if not found
  32170. */
  32171. getBoneByID(id: string): Nullable<Bone>;
  32172. /**
  32173. * Gets a bone using its id
  32174. * @param name defines the bone's name
  32175. * @return the bone or null if not found
  32176. */
  32177. getBoneByName(name: string): Nullable<Bone>;
  32178. /**
  32179. * Gets a light node using its name
  32180. * @param name defines the the light's name
  32181. * @return the light or null if none found.
  32182. */
  32183. getLightByName(name: string): Nullable<Light>;
  32184. /**
  32185. * Gets a light node using its id
  32186. * @param id defines the light's id
  32187. * @return the light or null if none found.
  32188. */
  32189. getLightByID(id: string): Nullable<Light>;
  32190. /**
  32191. * Gets a light node using its scene-generated unique ID
  32192. * @param uniqueId defines the light's unique id
  32193. * @return the light or null if none found.
  32194. */
  32195. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32196. /**
  32197. * Gets a particle system by id
  32198. * @param id defines the particle system id
  32199. * @return the corresponding system or null if none found
  32200. */
  32201. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32202. /**
  32203. * Gets a geometry using its ID
  32204. * @param id defines the geometry's id
  32205. * @return the geometry or null if none found.
  32206. */
  32207. getGeometryByID(id: string): Nullable<Geometry>;
  32208. private _getGeometryByUniqueID;
  32209. /**
  32210. * Add a new geometry to this scene
  32211. * @param geometry defines the geometry to be added to the scene.
  32212. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32213. * @return a boolean defining if the geometry was added or not
  32214. */
  32215. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32216. /**
  32217. * Removes an existing geometry
  32218. * @param geometry defines the geometry to be removed from the scene
  32219. * @return a boolean defining if the geometry was removed or not
  32220. */
  32221. removeGeometry(geometry: Geometry): boolean;
  32222. /**
  32223. * Gets the list of geometries attached to the scene
  32224. * @returns an array of Geometry
  32225. */
  32226. getGeometries(): Geometry[];
  32227. /**
  32228. * Gets the first added mesh found of a given ID
  32229. * @param id defines the id to search for
  32230. * @return the mesh found or null if not found at all
  32231. */
  32232. getMeshByID(id: string): Nullable<AbstractMesh>;
  32233. /**
  32234. * Gets a list of meshes using their id
  32235. * @param id defines the id to search for
  32236. * @returns a list of meshes
  32237. */
  32238. getMeshesByID(id: string): Array<AbstractMesh>;
  32239. /**
  32240. * Gets the first added transform node found of a given ID
  32241. * @param id defines the id to search for
  32242. * @return the found transform node or null if not found at all.
  32243. */
  32244. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32245. /**
  32246. * Gets a list of transform nodes using their id
  32247. * @param id defines the id to search for
  32248. * @returns a list of transform nodes
  32249. */
  32250. getTransformNodesByID(id: string): Array<TransformNode>;
  32251. /**
  32252. * Gets a mesh with its auto-generated unique id
  32253. * @param uniqueId defines the unique id to search for
  32254. * @return the found mesh or null if not found at all.
  32255. */
  32256. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32257. /**
  32258. * Gets a the last added mesh using a given id
  32259. * @param id defines the id to search for
  32260. * @return the found mesh or null if not found at all.
  32261. */
  32262. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32263. /**
  32264. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32265. * @param id defines the id to search for
  32266. * @return the found node or null if not found at all
  32267. */
  32268. getLastEntryByID(id: string): Nullable<Node>;
  32269. /**
  32270. * Gets a node (Mesh, Camera, Light) using a given id
  32271. * @param id defines the id to search for
  32272. * @return the found node or null if not found at all
  32273. */
  32274. getNodeByID(id: string): Nullable<Node>;
  32275. /**
  32276. * Gets a node (Mesh, Camera, Light) using a given name
  32277. * @param name defines the name to search for
  32278. * @return the found node or null if not found at all.
  32279. */
  32280. getNodeByName(name: string): Nullable<Node>;
  32281. /**
  32282. * Gets a mesh using a given name
  32283. * @param name defines the name to search for
  32284. * @return the found mesh or null if not found at all.
  32285. */
  32286. getMeshByName(name: string): Nullable<AbstractMesh>;
  32287. /**
  32288. * Gets a transform node using a given name
  32289. * @param name defines the name to search for
  32290. * @return the found transform node or null if not found at all.
  32291. */
  32292. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32293. /**
  32294. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32295. * @param id defines the id to search for
  32296. * @return the found skeleton or null if not found at all.
  32297. */
  32298. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32299. /**
  32300. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32301. * @param id defines the id to search for
  32302. * @return the found skeleton or null if not found at all.
  32303. */
  32304. getSkeletonById(id: string): Nullable<Skeleton>;
  32305. /**
  32306. * Gets a skeleton using a given name
  32307. * @param name defines the name to search for
  32308. * @return the found skeleton or null if not found at all.
  32309. */
  32310. getSkeletonByName(name: string): Nullable<Skeleton>;
  32311. /**
  32312. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32313. * @param id defines the id to search for
  32314. * @return the found morph target manager or null if not found at all.
  32315. */
  32316. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32317. /**
  32318. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32319. * @param id defines the id to search for
  32320. * @return the found morph target or null if not found at all.
  32321. */
  32322. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32323. /**
  32324. * Gets a boolean indicating if the given mesh is active
  32325. * @param mesh defines the mesh to look for
  32326. * @returns true if the mesh is in the active list
  32327. */
  32328. isActiveMesh(mesh: AbstractMesh): boolean;
  32329. /**
  32330. * Return a unique id as a string which can serve as an identifier for the scene
  32331. */
  32332. readonly uid: string;
  32333. /**
  32334. * Add an externaly attached data from its key.
  32335. * This method call will fail and return false, if such key already exists.
  32336. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32337. * @param key the unique key that identifies the data
  32338. * @param data the data object to associate to the key for this Engine instance
  32339. * @return true if no such key were already present and the data was added successfully, false otherwise
  32340. */
  32341. addExternalData<T>(key: string, data: T): boolean;
  32342. /**
  32343. * Get an externaly attached data from its key
  32344. * @param key the unique key that identifies the data
  32345. * @return the associated data, if present (can be null), or undefined if not present
  32346. */
  32347. getExternalData<T>(key: string): Nullable<T>;
  32348. /**
  32349. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32350. * @param key the unique key that identifies the data
  32351. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32352. * @return the associated data, can be null if the factory returned null.
  32353. */
  32354. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32355. /**
  32356. * Remove an externaly attached data from the Engine instance
  32357. * @param key the unique key that identifies the data
  32358. * @return true if the data was successfully removed, false if it doesn't exist
  32359. */
  32360. removeExternalData(key: string): boolean;
  32361. private _evaluateSubMesh;
  32362. /**
  32363. * Clear the processed materials smart array preventing retention point in material dispose.
  32364. */
  32365. freeProcessedMaterials(): void;
  32366. private _preventFreeActiveMeshesAndRenderingGroups;
  32367. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32368. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32369. * when disposing several meshes in a row or a hierarchy of meshes.
  32370. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32371. */
  32372. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32373. /**
  32374. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32375. */
  32376. freeActiveMeshes(): void;
  32377. /**
  32378. * Clear the info related to rendering groups preventing retention points during dispose.
  32379. */
  32380. freeRenderingGroups(): void;
  32381. /** @hidden */
  32382. _isInIntermediateRendering(): boolean;
  32383. /**
  32384. * Lambda returning the list of potentially active meshes.
  32385. */
  32386. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32387. /**
  32388. * Lambda returning the list of potentially active sub meshes.
  32389. */
  32390. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32391. /**
  32392. * Lambda returning the list of potentially intersecting sub meshes.
  32393. */
  32394. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32395. /**
  32396. * Lambda returning the list of potentially colliding sub meshes.
  32397. */
  32398. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32399. private _activeMeshesFrozen;
  32400. /**
  32401. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32402. * @returns the current scene
  32403. */
  32404. freezeActiveMeshes(): Scene;
  32405. /**
  32406. * Use this function to restart evaluating active meshes on every frame
  32407. * @returns the current scene
  32408. */
  32409. unfreezeActiveMeshes(): Scene;
  32410. private _evaluateActiveMeshes;
  32411. private _activeMesh;
  32412. /**
  32413. * Update the transform matrix to update from the current active camera
  32414. * @param force defines a boolean used to force the update even if cache is up to date
  32415. */
  32416. updateTransformMatrix(force?: boolean): void;
  32417. /**
  32418. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  32419. * @param alternateCamera defines the camera to use
  32420. */
  32421. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  32422. /** @hidden */
  32423. _allowPostProcessClearColor: boolean;
  32424. private _renderForCamera;
  32425. private _processSubCameras;
  32426. private _checkIntersections;
  32427. /** @hidden */
  32428. _advancePhysicsEngineStep(step: number): void;
  32429. /**
  32430. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32431. */
  32432. getDeterministicFrameTime: () => number;
  32433. /** @hidden */
  32434. _animate(): void;
  32435. /**
  32436. * Render the scene
  32437. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32438. */
  32439. render(updateCameras?: boolean): void;
  32440. /**
  32441. * Freeze all materials
  32442. * A frozen material will not be updatable but should be faster to render
  32443. */
  32444. freezeMaterials(): void;
  32445. /**
  32446. * Unfreeze all materials
  32447. * A frozen material will not be updatable but should be faster to render
  32448. */
  32449. unfreezeMaterials(): void;
  32450. /**
  32451. * Releases all held ressources
  32452. */
  32453. dispose(): void;
  32454. /**
  32455. * Gets if the scene is already disposed
  32456. */
  32457. readonly isDisposed: boolean;
  32458. /**
  32459. * Call this function to reduce memory footprint of the scene.
  32460. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32461. */
  32462. clearCachedVertexData(): void;
  32463. /**
  32464. * This function will remove the local cached buffer data from texture.
  32465. * It will save memory but will prevent the texture from being rebuilt
  32466. */
  32467. cleanCachedTextureBuffer(): void;
  32468. /**
  32469. * Get the world extend vectors with an optional filter
  32470. *
  32471. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32472. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32473. */
  32474. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32475. min: Vector3;
  32476. max: Vector3;
  32477. };
  32478. /**
  32479. * Creates a ray that can be used to pick in the scene
  32480. * @param x defines the x coordinate of the origin (on-screen)
  32481. * @param y defines the y coordinate of the origin (on-screen)
  32482. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32483. * @param camera defines the camera to use for the picking
  32484. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32485. * @returns a Ray
  32486. */
  32487. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32488. /**
  32489. * Creates a ray that can be used to pick in the scene
  32490. * @param x defines the x coordinate of the origin (on-screen)
  32491. * @param y defines the y coordinate of the origin (on-screen)
  32492. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32493. * @param result defines the ray where to store the picking ray
  32494. * @param camera defines the camera to use for the picking
  32495. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32496. * @returns the current scene
  32497. */
  32498. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32499. /**
  32500. * Creates a ray that can be used to pick in the scene
  32501. * @param x defines the x coordinate of the origin (on-screen)
  32502. * @param y defines the y coordinate of the origin (on-screen)
  32503. * @param camera defines the camera to use for the picking
  32504. * @returns a Ray
  32505. */
  32506. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32507. /**
  32508. * Creates a ray that can be used to pick in the scene
  32509. * @param x defines the x coordinate of the origin (on-screen)
  32510. * @param y defines the y coordinate of the origin (on-screen)
  32511. * @param result defines the ray where to store the picking ray
  32512. * @param camera defines the camera to use for the picking
  32513. * @returns the current scene
  32514. */
  32515. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32516. /** Launch a ray to try to pick a mesh in the scene
  32517. * @param x position on screen
  32518. * @param y position on screen
  32519. * @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
  32520. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32521. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32522. * @returns a PickingInfo
  32523. */
  32524. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  32525. /** Use the given ray to pick a mesh in the scene
  32526. * @param ray The ray to use to pick meshes
  32527. * @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
  32528. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32529. * @returns a PickingInfo
  32530. */
  32531. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  32532. /**
  32533. * Launch a ray to try to pick a mesh in the scene
  32534. * @param x X position on screen
  32535. * @param y Y position on screen
  32536. * @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
  32537. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32538. * @returns an array of PickingInfo
  32539. */
  32540. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  32541. /**
  32542. * Launch a ray to try to pick a mesh in the scene
  32543. * @param ray Ray to use
  32544. * @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
  32545. * @returns an array of PickingInfo
  32546. */
  32547. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  32548. /**
  32549. * Force the value of meshUnderPointer
  32550. * @param mesh defines the mesh to use
  32551. */
  32552. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32553. /**
  32554. * Gets the mesh under the pointer
  32555. * @returns a Mesh or null if no mesh is under the pointer
  32556. */
  32557. getPointerOverMesh(): Nullable<AbstractMesh>;
  32558. /** @hidden */
  32559. _rebuildGeometries(): void;
  32560. /** @hidden */
  32561. _rebuildTextures(): void;
  32562. private _getByTags;
  32563. /**
  32564. * Get a list of meshes by tags
  32565. * @param tagsQuery defines the tags query to use
  32566. * @param forEach defines a predicate used to filter results
  32567. * @returns an array of Mesh
  32568. */
  32569. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32570. /**
  32571. * Get a list of cameras by tags
  32572. * @param tagsQuery defines the tags query to use
  32573. * @param forEach defines a predicate used to filter results
  32574. * @returns an array of Camera
  32575. */
  32576. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32577. /**
  32578. * Get a list of lights by tags
  32579. * @param tagsQuery defines the tags query to use
  32580. * @param forEach defines a predicate used to filter results
  32581. * @returns an array of Light
  32582. */
  32583. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32584. /**
  32585. * Get a list of materials by tags
  32586. * @param tagsQuery defines the tags query to use
  32587. * @param forEach defines a predicate used to filter results
  32588. * @returns an array of Material
  32589. */
  32590. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  32591. /**
  32592. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32593. * This allowed control for front to back rendering or reversly depending of the special needs.
  32594. *
  32595. * @param renderingGroupId The rendering group id corresponding to its index
  32596. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32597. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32598. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32599. */
  32600. 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;
  32601. /**
  32602. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32603. *
  32604. * @param renderingGroupId The rendering group id corresponding to its index
  32605. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32606. * @param depth Automatically clears depth between groups if true and autoClear is true.
  32607. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  32608. */
  32609. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  32610. /**
  32611. * Gets the current auto clear configuration for one rendering group of the rendering
  32612. * manager.
  32613. * @param index the rendering group index to get the information for
  32614. * @returns The auto clear setup for the requested rendering group
  32615. */
  32616. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  32617. private _blockMaterialDirtyMechanism;
  32618. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  32619. blockMaterialDirtyMechanism: boolean;
  32620. /**
  32621. * Will flag all materials as dirty to trigger new shader compilation
  32622. * @param flag defines the flag used to specify which material part must be marked as dirty
  32623. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  32624. */
  32625. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32626. /** @hidden */
  32627. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  32628. /** @hidden */
  32629. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32630. }
  32631. }
  32632. declare module BABYLON {
  32633. /**
  32634. * Set of assets to keep when moving a scene into an asset container.
  32635. */
  32636. export class KeepAssets extends AbstractScene {
  32637. }
  32638. /**
  32639. * Container with a set of assets that can be added or removed from a scene.
  32640. */
  32641. export class AssetContainer extends AbstractScene {
  32642. /**
  32643. * The scene the AssetContainer belongs to.
  32644. */
  32645. scene: Scene;
  32646. /**
  32647. * Instantiates an AssetContainer.
  32648. * @param scene The scene the AssetContainer belongs to.
  32649. */
  32650. constructor(scene: Scene);
  32651. /**
  32652. * Adds all the assets from the container to the scene.
  32653. */
  32654. addAllToScene(): void;
  32655. /**
  32656. * Removes all the assets in the container from the scene
  32657. */
  32658. removeAllFromScene(): void;
  32659. /**
  32660. * Disposes all the assets in the container
  32661. */
  32662. dispose(): void;
  32663. private _moveAssets;
  32664. /**
  32665. * Removes all the assets contained in the scene and adds them to the container.
  32666. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  32667. */
  32668. moveAllFromScene(keepAssets?: KeepAssets): void;
  32669. /**
  32670. * 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.
  32671. * @returns the root mesh
  32672. */
  32673. createRootMesh(): Mesh;
  32674. }
  32675. }
  32676. declare module BABYLON {
  32677. /**
  32678. * Defines how the parser contract is defined.
  32679. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  32680. */
  32681. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  32682. /**
  32683. * Defines how the individual parser contract is defined.
  32684. * These parser can parse an individual asset
  32685. */
  32686. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  32687. /**
  32688. * Base class of the scene acting as a container for the different elements composing a scene.
  32689. * This class is dynamically extended by the different components of the scene increasing
  32690. * flexibility and reducing coupling
  32691. */
  32692. export abstract class AbstractScene {
  32693. /**
  32694. * Stores the list of available parsers in the application.
  32695. */
  32696. private static _BabylonFileParsers;
  32697. /**
  32698. * Stores the list of available individual parsers in the application.
  32699. */
  32700. private static _IndividualBabylonFileParsers;
  32701. /**
  32702. * Adds a parser in the list of available ones
  32703. * @param name Defines the name of the parser
  32704. * @param parser Defines the parser to add
  32705. */
  32706. static AddParser(name: string, parser: BabylonFileParser): void;
  32707. /**
  32708. * Gets a general parser from the list of avaialble ones
  32709. * @param name Defines the name of the parser
  32710. * @returns the requested parser or null
  32711. */
  32712. static GetParser(name: string): Nullable<BabylonFileParser>;
  32713. /**
  32714. * Adds n individual parser in the list of available ones
  32715. * @param name Defines the name of the parser
  32716. * @param parser Defines the parser to add
  32717. */
  32718. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  32719. /**
  32720. * Gets an individual parser from the list of avaialble ones
  32721. * @param name Defines the name of the parser
  32722. * @returns the requested parser or null
  32723. */
  32724. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  32725. /**
  32726. * Parser json data and populate both a scene and its associated container object
  32727. * @param jsonData Defines the data to parse
  32728. * @param scene Defines the scene to parse the data for
  32729. * @param container Defines the container attached to the parsing sequence
  32730. * @param rootUrl Defines the root url of the data
  32731. */
  32732. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  32733. /**
  32734. * Gets the list of root nodes (ie. nodes with no parent)
  32735. */
  32736. rootNodes: Node[];
  32737. /** All of the cameras added to this scene
  32738. * @see http://doc.babylonjs.com/babylon101/cameras
  32739. */
  32740. cameras: Camera[];
  32741. /**
  32742. * All of the lights added to this scene
  32743. * @see http://doc.babylonjs.com/babylon101/lights
  32744. */
  32745. lights: Light[];
  32746. /**
  32747. * All of the (abstract) meshes added to this scene
  32748. */
  32749. meshes: AbstractMesh[];
  32750. /**
  32751. * The list of skeletons added to the scene
  32752. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32753. */
  32754. skeletons: Skeleton[];
  32755. /**
  32756. * All of the particle systems added to this scene
  32757. * @see http://doc.babylonjs.com/babylon101/particles
  32758. */
  32759. particleSystems: IParticleSystem[];
  32760. /**
  32761. * Gets a list of Animations associated with the scene
  32762. */
  32763. animations: Animation[];
  32764. /**
  32765. * All of the animation groups added to this scene
  32766. * @see http://doc.babylonjs.com/how_to/group
  32767. */
  32768. animationGroups: AnimationGroup[];
  32769. /**
  32770. * All of the multi-materials added to this scene
  32771. * @see http://doc.babylonjs.com/how_to/multi_materials
  32772. */
  32773. multiMaterials: MultiMaterial[];
  32774. /**
  32775. * All of the materials added to this scene
  32776. * In the context of a Scene, it is not supposed to be modified manually.
  32777. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  32778. * Note also that the order of the Material wihin the array is not significant and might change.
  32779. * @see http://doc.babylonjs.com/babylon101/materials
  32780. */
  32781. materials: Material[];
  32782. /**
  32783. * The list of morph target managers added to the scene
  32784. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  32785. */
  32786. morphTargetManagers: MorphTargetManager[];
  32787. /**
  32788. * The list of geometries used in the scene.
  32789. */
  32790. geometries: Geometry[];
  32791. /**
  32792. * All of the tranform nodes added to this scene
  32793. * In the context of a Scene, it is not supposed to be modified manually.
  32794. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  32795. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  32796. * @see http://doc.babylonjs.com/how_to/transformnode
  32797. */
  32798. transformNodes: TransformNode[];
  32799. /**
  32800. * ActionManagers available on the scene.
  32801. */
  32802. actionManagers: AbstractActionManager[];
  32803. /**
  32804. * Textures to keep.
  32805. */
  32806. textures: BaseTexture[];
  32807. }
  32808. }
  32809. declare module BABYLON {
  32810. /**
  32811. * Defines a sound that can be played in the application.
  32812. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  32813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32814. */
  32815. export class Sound {
  32816. /**
  32817. * The name of the sound in the scene.
  32818. */
  32819. name: string;
  32820. /**
  32821. * Does the sound autoplay once loaded.
  32822. */
  32823. autoplay: boolean;
  32824. /**
  32825. * Does the sound loop after it finishes playing once.
  32826. */
  32827. loop: boolean;
  32828. /**
  32829. * Does the sound use a custom attenuation curve to simulate the falloff
  32830. * happening when the source gets further away from the camera.
  32831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  32832. */
  32833. useCustomAttenuation: boolean;
  32834. /**
  32835. * The sound track id this sound belongs to.
  32836. */
  32837. soundTrackId: number;
  32838. /**
  32839. * Is this sound currently played.
  32840. */
  32841. isPlaying: boolean;
  32842. /**
  32843. * Is this sound currently paused.
  32844. */
  32845. isPaused: boolean;
  32846. /**
  32847. * Does this sound enables spatial sound.
  32848. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32849. */
  32850. spatialSound: boolean;
  32851. /**
  32852. * Define the reference distance the sound should be heard perfectly.
  32853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32854. */
  32855. refDistance: number;
  32856. /**
  32857. * Define the roll off factor of spatial sounds.
  32858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32859. */
  32860. rolloffFactor: number;
  32861. /**
  32862. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  32863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32864. */
  32865. maxDistance: number;
  32866. /**
  32867. * Define the distance attenuation model the sound will follow.
  32868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32869. */
  32870. distanceModel: string;
  32871. /**
  32872. * @hidden
  32873. * Back Compat
  32874. **/
  32875. onended: () => any;
  32876. /**
  32877. * Observable event when the current playing sound finishes.
  32878. */
  32879. onEndedObservable: Observable<Sound>;
  32880. private _panningModel;
  32881. private _playbackRate;
  32882. private _streaming;
  32883. private _startTime;
  32884. private _startOffset;
  32885. private _position;
  32886. /** @hidden */
  32887. _positionInEmitterSpace: boolean;
  32888. private _localDirection;
  32889. private _volume;
  32890. private _isReadyToPlay;
  32891. private _isDirectional;
  32892. private _readyToPlayCallback;
  32893. private _audioBuffer;
  32894. private _soundSource;
  32895. private _streamingSource;
  32896. private _soundPanner;
  32897. private _soundGain;
  32898. private _inputAudioNode;
  32899. private _outputAudioNode;
  32900. private _coneInnerAngle;
  32901. private _coneOuterAngle;
  32902. private _coneOuterGain;
  32903. private _scene;
  32904. private _connectedTransformNode;
  32905. private _customAttenuationFunction;
  32906. private _registerFunc;
  32907. private _isOutputConnected;
  32908. private _htmlAudioElement;
  32909. private _urlType;
  32910. /** @hidden */
  32911. static _SceneComponentInitialization: (scene: Scene) => void;
  32912. /**
  32913. * Create a sound and attach it to a scene
  32914. * @param name Name of your sound
  32915. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  32916. * @param scene defines the scene the sound belongs to
  32917. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  32918. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  32919. */
  32920. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  32921. /**
  32922. * Release the sound and its associated resources
  32923. */
  32924. dispose(): void;
  32925. /**
  32926. * Gets if the sounds is ready to be played or not.
  32927. * @returns true if ready, otherwise false
  32928. */
  32929. isReady(): boolean;
  32930. private _soundLoaded;
  32931. /**
  32932. * Sets the data of the sound from an audiobuffer
  32933. * @param audioBuffer The audioBuffer containing the data
  32934. */
  32935. setAudioBuffer(audioBuffer: AudioBuffer): void;
  32936. /**
  32937. * Updates the current sounds options such as maxdistance, loop...
  32938. * @param options A JSON object containing values named as the object properties
  32939. */
  32940. updateOptions(options: any): void;
  32941. private _createSpatialParameters;
  32942. private _updateSpatialParameters;
  32943. /**
  32944. * Switch the panning model to HRTF:
  32945. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  32946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32947. */
  32948. switchPanningModelToHRTF(): void;
  32949. /**
  32950. * Switch the panning model to Equal Power:
  32951. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  32952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32953. */
  32954. switchPanningModelToEqualPower(): void;
  32955. private _switchPanningModel;
  32956. /**
  32957. * Connect this sound to a sound track audio node like gain...
  32958. * @param soundTrackAudioNode the sound track audio node to connect to
  32959. */
  32960. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  32961. /**
  32962. * Transform this sound into a directional source
  32963. * @param coneInnerAngle Size of the inner cone in degree
  32964. * @param coneOuterAngle Size of the outer cone in degree
  32965. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  32966. */
  32967. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  32968. /**
  32969. * Gets or sets the inner angle for the directional cone.
  32970. */
  32971. /**
  32972. * Gets or sets the inner angle for the directional cone.
  32973. */
  32974. directionalConeInnerAngle: number;
  32975. /**
  32976. * Gets or sets the outer angle for the directional cone.
  32977. */
  32978. /**
  32979. * Gets or sets the outer angle for the directional cone.
  32980. */
  32981. directionalConeOuterAngle: number;
  32982. /**
  32983. * Sets the position of the emitter if spatial sound is enabled
  32984. * @param newPosition Defines the new posisiton
  32985. */
  32986. setPosition(newPosition: Vector3): void;
  32987. /**
  32988. * Sets the local direction of the emitter if spatial sound is enabled
  32989. * @param newLocalDirection Defines the new local direction
  32990. */
  32991. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  32992. private _updateDirection;
  32993. /** @hidden */
  32994. updateDistanceFromListener(): void;
  32995. /**
  32996. * Sets a new custom attenuation function for the sound.
  32997. * @param callback Defines the function used for the attenuation
  32998. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  32999. */
  33000. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33001. /**
  33002. * Play the sound
  33003. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33004. * @param offset (optional) Start the sound setting it at a specific time
  33005. */
  33006. play(time?: number, offset?: number): void;
  33007. private _onended;
  33008. /**
  33009. * Stop the sound
  33010. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33011. */
  33012. stop(time?: number): void;
  33013. /**
  33014. * Put the sound in pause
  33015. */
  33016. pause(): void;
  33017. /**
  33018. * Sets a dedicated volume for this sounds
  33019. * @param newVolume Define the new volume of the sound
  33020. * @param time Define in how long the sound should be at this value
  33021. */
  33022. setVolume(newVolume: number, time?: number): void;
  33023. /**
  33024. * Set the sound play back rate
  33025. * @param newPlaybackRate Define the playback rate the sound should be played at
  33026. */
  33027. setPlaybackRate(newPlaybackRate: number): void;
  33028. /**
  33029. * Gets the volume of the sound.
  33030. * @returns the volume of the sound
  33031. */
  33032. getVolume(): number;
  33033. /**
  33034. * Attach the sound to a dedicated mesh
  33035. * @param transformNode The transform node to connect the sound with
  33036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33037. */
  33038. attachToMesh(transformNode: TransformNode): void;
  33039. /**
  33040. * Detach the sound from the previously attached mesh
  33041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33042. */
  33043. detachFromMesh(): void;
  33044. private _onRegisterAfterWorldMatrixUpdate;
  33045. /**
  33046. * Clone the current sound in the scene.
  33047. * @returns the new sound clone
  33048. */
  33049. clone(): Nullable<Sound>;
  33050. /**
  33051. * Gets the current underlying audio buffer containing the data
  33052. * @returns the audio buffer
  33053. */
  33054. getAudioBuffer(): Nullable<AudioBuffer>;
  33055. /**
  33056. * Serializes the Sound in a JSON representation
  33057. * @returns the JSON representation of the sound
  33058. */
  33059. serialize(): any;
  33060. /**
  33061. * Parse a JSON representation of a sound to innstantiate in a given scene
  33062. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33063. * @param scene Define the scene the new parsed sound should be created in
  33064. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33065. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33066. * @returns the newly parsed sound
  33067. */
  33068. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33069. }
  33070. }
  33071. declare module BABYLON {
  33072. /**
  33073. * This defines an action helpful to play a defined sound on a triggered action.
  33074. */
  33075. export class PlaySoundAction extends Action {
  33076. private _sound;
  33077. /**
  33078. * Instantiate the action
  33079. * @param triggerOptions defines the trigger options
  33080. * @param sound defines the sound to play
  33081. * @param condition defines the trigger related conditions
  33082. */
  33083. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33084. /** @hidden */
  33085. _prepare(): void;
  33086. /**
  33087. * Execute the action and play the sound.
  33088. */
  33089. execute(): void;
  33090. /**
  33091. * Serializes the actions and its related information.
  33092. * @param parent defines the object to serialize in
  33093. * @returns the serialized object
  33094. */
  33095. serialize(parent: any): any;
  33096. }
  33097. /**
  33098. * This defines an action helpful to stop a defined sound on a triggered action.
  33099. */
  33100. export class StopSoundAction extends Action {
  33101. private _sound;
  33102. /**
  33103. * Instantiate the action
  33104. * @param triggerOptions defines the trigger options
  33105. * @param sound defines the sound to stop
  33106. * @param condition defines the trigger related conditions
  33107. */
  33108. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33109. /** @hidden */
  33110. _prepare(): void;
  33111. /**
  33112. * Execute the action and stop the sound.
  33113. */
  33114. execute(): void;
  33115. /**
  33116. * Serializes the actions and its related information.
  33117. * @param parent defines the object to serialize in
  33118. * @returns the serialized object
  33119. */
  33120. serialize(parent: any): any;
  33121. }
  33122. }
  33123. declare module BABYLON {
  33124. /**
  33125. * This defines an action responsible to change the value of a property
  33126. * by interpolating between its current value and the newly set one once triggered.
  33127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33128. */
  33129. export class InterpolateValueAction extends Action {
  33130. /**
  33131. * Defines the path of the property where the value should be interpolated
  33132. */
  33133. propertyPath: string;
  33134. /**
  33135. * Defines the target value at the end of the interpolation.
  33136. */
  33137. value: any;
  33138. /**
  33139. * Defines the time it will take for the property to interpolate to the value.
  33140. */
  33141. duration: number;
  33142. /**
  33143. * Defines if the other scene animations should be stopped when the action has been triggered
  33144. */
  33145. stopOtherAnimations?: boolean;
  33146. /**
  33147. * Defines a callback raised once the interpolation animation has been done.
  33148. */
  33149. onInterpolationDone?: () => void;
  33150. /**
  33151. * Observable triggered once the interpolation animation has been done.
  33152. */
  33153. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33154. private _target;
  33155. private _effectiveTarget;
  33156. private _property;
  33157. /**
  33158. * Instantiate the action
  33159. * @param triggerOptions defines the trigger options
  33160. * @param target defines the object containing the value to interpolate
  33161. * @param propertyPath defines the path to the property in the target object
  33162. * @param value defines the target value at the end of the interpolation
  33163. * @param duration deines the time it will take for the property to interpolate to the value.
  33164. * @param condition defines the trigger related conditions
  33165. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33166. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33167. */
  33168. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33169. /** @hidden */
  33170. _prepare(): void;
  33171. /**
  33172. * Execute the action starts the value interpolation.
  33173. */
  33174. execute(): void;
  33175. /**
  33176. * Serializes the actions and its related information.
  33177. * @param parent defines the object to serialize in
  33178. * @returns the serialized object
  33179. */
  33180. serialize(parent: any): any;
  33181. }
  33182. }
  33183. declare module BABYLON {
  33184. /**
  33185. * Options allowed during the creation of a sound track.
  33186. */
  33187. export interface ISoundTrackOptions {
  33188. /**
  33189. * The volume the sound track should take during creation
  33190. */
  33191. volume?: number;
  33192. /**
  33193. * Define if the sound track is the main sound track of the scene
  33194. */
  33195. mainTrack?: boolean;
  33196. }
  33197. /**
  33198. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33199. * It will be also used in a future release to apply effects on a specific track.
  33200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33201. */
  33202. export class SoundTrack {
  33203. /**
  33204. * The unique identifier of the sound track in the scene.
  33205. */
  33206. id: number;
  33207. /**
  33208. * The list of sounds included in the sound track.
  33209. */
  33210. soundCollection: Array<Sound>;
  33211. private _outputAudioNode;
  33212. private _scene;
  33213. private _isMainTrack;
  33214. private _connectedAnalyser;
  33215. private _options;
  33216. private _isInitialized;
  33217. /**
  33218. * Creates a new sound track.
  33219. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33220. * @param scene Define the scene the sound track belongs to
  33221. * @param options
  33222. */
  33223. constructor(scene: Scene, options?: ISoundTrackOptions);
  33224. private _initializeSoundTrackAudioGraph;
  33225. /**
  33226. * Release the sound track and its associated resources
  33227. */
  33228. dispose(): void;
  33229. /**
  33230. * Adds a sound to this sound track
  33231. * @param sound define the cound to add
  33232. * @ignoreNaming
  33233. */
  33234. AddSound(sound: Sound): void;
  33235. /**
  33236. * Removes a sound to this sound track
  33237. * @param sound define the cound to remove
  33238. * @ignoreNaming
  33239. */
  33240. RemoveSound(sound: Sound): void;
  33241. /**
  33242. * Set a global volume for the full sound track.
  33243. * @param newVolume Define the new volume of the sound track
  33244. */
  33245. setVolume(newVolume: number): void;
  33246. /**
  33247. * Switch the panning model to HRTF:
  33248. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33250. */
  33251. switchPanningModelToHRTF(): void;
  33252. /**
  33253. * Switch the panning model to Equal Power:
  33254. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33256. */
  33257. switchPanningModelToEqualPower(): void;
  33258. /**
  33259. * Connect the sound track to an audio analyser allowing some amazing
  33260. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33261. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33262. * @param analyser The analyser to connect to the engine
  33263. */
  33264. connectToAnalyser(analyser: Analyser): void;
  33265. }
  33266. }
  33267. declare module BABYLON {
  33268. interface AbstractScene {
  33269. /**
  33270. * The list of sounds used in the scene.
  33271. */
  33272. sounds: Nullable<Array<Sound>>;
  33273. }
  33274. interface Scene {
  33275. /**
  33276. * @hidden
  33277. * Backing field
  33278. */
  33279. _mainSoundTrack: SoundTrack;
  33280. /**
  33281. * The main sound track played by the scene.
  33282. * It cotains your primary collection of sounds.
  33283. */
  33284. mainSoundTrack: SoundTrack;
  33285. /**
  33286. * The list of sound tracks added to the scene
  33287. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33288. */
  33289. soundTracks: Nullable<Array<SoundTrack>>;
  33290. /**
  33291. * Gets a sound using a given name
  33292. * @param name defines the name to search for
  33293. * @return the found sound or null if not found at all.
  33294. */
  33295. getSoundByName(name: string): Nullable<Sound>;
  33296. /**
  33297. * Gets or sets if audio support is enabled
  33298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33299. */
  33300. audioEnabled: boolean;
  33301. /**
  33302. * Gets or sets if audio will be output to headphones
  33303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33304. */
  33305. headphone: boolean;
  33306. }
  33307. /**
  33308. * Defines the sound scene component responsible to manage any sounds
  33309. * in a given scene.
  33310. */
  33311. export class AudioSceneComponent implements ISceneSerializableComponent {
  33312. /**
  33313. * The component name helpfull to identify the component in the list of scene components.
  33314. */
  33315. readonly name: string;
  33316. /**
  33317. * The scene the component belongs to.
  33318. */
  33319. scene: Scene;
  33320. private _audioEnabled;
  33321. /**
  33322. * Gets whether audio is enabled or not.
  33323. * Please use related enable/disable method to switch state.
  33324. */
  33325. readonly audioEnabled: boolean;
  33326. private _headphone;
  33327. /**
  33328. * Gets whether audio is outputing to headphone or not.
  33329. * Please use the according Switch methods to change output.
  33330. */
  33331. readonly headphone: boolean;
  33332. /**
  33333. * Creates a new instance of the component for the given scene
  33334. * @param scene Defines the scene to register the component in
  33335. */
  33336. constructor(scene: Scene);
  33337. /**
  33338. * Registers the component in a given scene
  33339. */
  33340. register(): void;
  33341. /**
  33342. * Rebuilds the elements related to this component in case of
  33343. * context lost for instance.
  33344. */
  33345. rebuild(): void;
  33346. /**
  33347. * Serializes the component data to the specified json object
  33348. * @param serializationObject The object to serialize to
  33349. */
  33350. serialize(serializationObject: any): void;
  33351. /**
  33352. * Adds all the element from the container to the scene
  33353. * @param container the container holding the elements
  33354. */
  33355. addFromContainer(container: AbstractScene): void;
  33356. /**
  33357. * Removes all the elements in the container from the scene
  33358. * @param container contains the elements to remove
  33359. */
  33360. removeFromContainer(container: AbstractScene): void;
  33361. /**
  33362. * Disposes the component and the associated ressources.
  33363. */
  33364. dispose(): void;
  33365. /**
  33366. * Disables audio in the associated scene.
  33367. */
  33368. disableAudio(): void;
  33369. /**
  33370. * Enables audio in the associated scene.
  33371. */
  33372. enableAudio(): void;
  33373. /**
  33374. * Switch audio to headphone output.
  33375. */
  33376. switchAudioModeForHeadphones(): void;
  33377. /**
  33378. * Switch audio to normal speakers.
  33379. */
  33380. switchAudioModeForNormalSpeakers(): void;
  33381. private _afterRender;
  33382. }
  33383. }
  33384. declare module BABYLON {
  33385. /**
  33386. * Wraps one or more Sound objects and selects one with random weight for playback.
  33387. */
  33388. export class WeightedSound {
  33389. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33390. loop: boolean;
  33391. private _coneInnerAngle;
  33392. private _coneOuterAngle;
  33393. private _volume;
  33394. /** A Sound is currently playing. */
  33395. isPlaying: boolean;
  33396. /** A Sound is currently paused. */
  33397. isPaused: boolean;
  33398. private _sounds;
  33399. private _weights;
  33400. private _currentIndex?;
  33401. /**
  33402. * Creates a new WeightedSound from the list of sounds given.
  33403. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33404. * @param sounds Array of Sounds that will be selected from.
  33405. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33406. */
  33407. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33408. /**
  33409. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33410. */
  33411. /**
  33412. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33413. */
  33414. directionalConeInnerAngle: number;
  33415. /**
  33416. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33417. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33418. */
  33419. /**
  33420. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33421. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33422. */
  33423. directionalConeOuterAngle: number;
  33424. /**
  33425. * Playback volume.
  33426. */
  33427. /**
  33428. * Playback volume.
  33429. */
  33430. volume: number;
  33431. private _onended;
  33432. /**
  33433. * Suspend playback
  33434. */
  33435. pause(): void;
  33436. /**
  33437. * Stop playback
  33438. */
  33439. stop(): void;
  33440. /**
  33441. * Start playback.
  33442. * @param startOffset Position the clip head at a specific time in seconds.
  33443. */
  33444. play(startOffset?: number): void;
  33445. }
  33446. }
  33447. declare module BABYLON {
  33448. /**
  33449. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33450. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33451. */
  33452. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33453. /**
  33454. * Gets the name of the behavior.
  33455. */
  33456. readonly name: string;
  33457. /**
  33458. * The easing function used by animations
  33459. */
  33460. static EasingFunction: BackEase;
  33461. /**
  33462. * The easing mode used by animations
  33463. */
  33464. static EasingMode: number;
  33465. /**
  33466. * The duration of the animation, in milliseconds
  33467. */
  33468. transitionDuration: number;
  33469. /**
  33470. * Length of the distance animated by the transition when lower radius is reached
  33471. */
  33472. lowerRadiusTransitionRange: number;
  33473. /**
  33474. * Length of the distance animated by the transition when upper radius is reached
  33475. */
  33476. upperRadiusTransitionRange: number;
  33477. private _autoTransitionRange;
  33478. /**
  33479. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33480. */
  33481. /**
  33482. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33483. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33484. */
  33485. autoTransitionRange: boolean;
  33486. private _attachedCamera;
  33487. private _onAfterCheckInputsObserver;
  33488. private _onMeshTargetChangedObserver;
  33489. /**
  33490. * Initializes the behavior.
  33491. */
  33492. init(): void;
  33493. /**
  33494. * Attaches the behavior to its arc rotate camera.
  33495. * @param camera Defines the camera to attach the behavior to
  33496. */
  33497. attach(camera: ArcRotateCamera): void;
  33498. /**
  33499. * Detaches the behavior from its current arc rotate camera.
  33500. */
  33501. detach(): void;
  33502. private _radiusIsAnimating;
  33503. private _radiusBounceTransition;
  33504. private _animatables;
  33505. private _cachedWheelPrecision;
  33506. /**
  33507. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33508. * @param radiusLimit The limit to check against.
  33509. * @return Bool to indicate if at limit.
  33510. */
  33511. private _isRadiusAtLimit;
  33512. /**
  33513. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33514. * @param radiusDelta The delta by which to animate to. Can be negative.
  33515. */
  33516. private _applyBoundRadiusAnimation;
  33517. /**
  33518. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33519. */
  33520. protected _clearAnimationLocks(): void;
  33521. /**
  33522. * Stops and removes all animations that have been applied to the camera
  33523. */
  33524. stopAllAnimations(): void;
  33525. }
  33526. }
  33527. declare module BABYLON {
  33528. /**
  33529. * 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.
  33530. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33531. */
  33532. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33533. /**
  33534. * Gets the name of the behavior.
  33535. */
  33536. readonly name: string;
  33537. private _mode;
  33538. private _radiusScale;
  33539. private _positionScale;
  33540. private _defaultElevation;
  33541. private _elevationReturnTime;
  33542. private _elevationReturnWaitTime;
  33543. private _zoomStopsAnimation;
  33544. private _framingTime;
  33545. /**
  33546. * The easing function used by animations
  33547. */
  33548. static EasingFunction: ExponentialEase;
  33549. /**
  33550. * The easing mode used by animations
  33551. */
  33552. static EasingMode: number;
  33553. /**
  33554. * Sets the current mode used by the behavior
  33555. */
  33556. /**
  33557. * Gets current mode used by the behavior.
  33558. */
  33559. mode: number;
  33560. /**
  33561. * Sets the scale applied to the radius (1 by default)
  33562. */
  33563. /**
  33564. * Gets the scale applied to the radius
  33565. */
  33566. radiusScale: number;
  33567. /**
  33568. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33569. */
  33570. /**
  33571. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33572. */
  33573. positionScale: number;
  33574. /**
  33575. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33576. * behaviour is triggered, in radians.
  33577. */
  33578. /**
  33579. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33580. * behaviour is triggered, in radians.
  33581. */
  33582. defaultElevation: number;
  33583. /**
  33584. * Sets the time (in milliseconds) taken to return to the default beta position.
  33585. * Negative value indicates camera should not return to default.
  33586. */
  33587. /**
  33588. * Gets the time (in milliseconds) taken to return to the default beta position.
  33589. * Negative value indicates camera should not return to default.
  33590. */
  33591. elevationReturnTime: number;
  33592. /**
  33593. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33594. */
  33595. /**
  33596. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33597. */
  33598. elevationReturnWaitTime: number;
  33599. /**
  33600. * Sets the flag that indicates if user zooming should stop animation.
  33601. */
  33602. /**
  33603. * Gets the flag that indicates if user zooming should stop animation.
  33604. */
  33605. zoomStopsAnimation: boolean;
  33606. /**
  33607. * Sets the transition time when framing the mesh, in milliseconds
  33608. */
  33609. /**
  33610. * Gets the transition time when framing the mesh, in milliseconds
  33611. */
  33612. framingTime: number;
  33613. /**
  33614. * Define if the behavior should automatically change the configured
  33615. * camera limits and sensibilities.
  33616. */
  33617. autoCorrectCameraLimitsAndSensibility: boolean;
  33618. private _onPrePointerObservableObserver;
  33619. private _onAfterCheckInputsObserver;
  33620. private _onMeshTargetChangedObserver;
  33621. private _attachedCamera;
  33622. private _isPointerDown;
  33623. private _lastInteractionTime;
  33624. /**
  33625. * Initializes the behavior.
  33626. */
  33627. init(): void;
  33628. /**
  33629. * Attaches the behavior to its arc rotate camera.
  33630. * @param camera Defines the camera to attach the behavior to
  33631. */
  33632. attach(camera: ArcRotateCamera): void;
  33633. /**
  33634. * Detaches the behavior from its current arc rotate camera.
  33635. */
  33636. detach(): void;
  33637. private _animatables;
  33638. private _betaIsAnimating;
  33639. private _betaTransition;
  33640. private _radiusTransition;
  33641. private _vectorTransition;
  33642. /**
  33643. * Targets the given mesh and updates zoom level accordingly.
  33644. * @param mesh The mesh to target.
  33645. * @param radius Optional. If a cached radius position already exists, overrides default.
  33646. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33647. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33648. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33649. */
  33650. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33651. /**
  33652. * Targets the given mesh with its children and updates zoom level accordingly.
  33653. * @param mesh The mesh to target.
  33654. * @param radius Optional. If a cached radius position already exists, overrides default.
  33655. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33656. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33657. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33658. */
  33659. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33660. /**
  33661. * Targets the given meshes with their children and updates zoom level accordingly.
  33662. * @param meshes The mesh to target.
  33663. * @param radius Optional. If a cached radius position already exists, overrides default.
  33664. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33665. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33666. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33667. */
  33668. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33669. /**
  33670. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  33671. * @param minimumWorld Determines the smaller position of the bounding box extend
  33672. * @param maximumWorld Determines the bigger position of the bounding box extend
  33673. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33674. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33675. */
  33676. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33677. /**
  33678. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  33679. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  33680. * frustum width.
  33681. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  33682. * to fully enclose the mesh in the viewing frustum.
  33683. */
  33684. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  33685. /**
  33686. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  33687. * is automatically returned to its default position (expected to be above ground plane).
  33688. */
  33689. private _maintainCameraAboveGround;
  33690. /**
  33691. * Returns the frustum slope based on the canvas ratio and camera FOV
  33692. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  33693. */
  33694. private _getFrustumSlope;
  33695. /**
  33696. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  33697. */
  33698. private _clearAnimationLocks;
  33699. /**
  33700. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33701. */
  33702. private _applyUserInteraction;
  33703. /**
  33704. * Stops and removes all animations that have been applied to the camera
  33705. */
  33706. stopAllAnimations(): void;
  33707. /**
  33708. * Gets a value indicating if the user is moving the camera
  33709. */
  33710. readonly isUserIsMoving: boolean;
  33711. /**
  33712. * The camera can move all the way towards the mesh.
  33713. */
  33714. static IgnoreBoundsSizeMode: number;
  33715. /**
  33716. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  33717. */
  33718. static FitFrustumSidesMode: number;
  33719. }
  33720. }
  33721. declare module BABYLON {
  33722. /**
  33723. * Manage the pointers inputs to control an arc rotate camera.
  33724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33725. */
  33726. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  33727. /**
  33728. * Defines the camera the input is attached to.
  33729. */
  33730. camera: ArcRotateCamera;
  33731. /**
  33732. * Defines the buttons associated with the input to handle camera move.
  33733. */
  33734. buttons: number[];
  33735. /**
  33736. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  33737. */
  33738. angularSensibilityX: number;
  33739. /**
  33740. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  33741. */
  33742. angularSensibilityY: number;
  33743. /**
  33744. * Defines the pointer pinch precision or how fast is the camera zooming.
  33745. */
  33746. pinchPrecision: number;
  33747. /**
  33748. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  33749. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  33750. */
  33751. pinchDeltaPercentage: number;
  33752. /**
  33753. * Defines the pointer panning sensibility or how fast is the camera moving.
  33754. */
  33755. panningSensibility: number;
  33756. /**
  33757. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  33758. */
  33759. multiTouchPanning: boolean;
  33760. /**
  33761. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  33762. */
  33763. multiTouchPanAndZoom: boolean;
  33764. /**
  33765. * Revers pinch action direction.
  33766. */
  33767. pinchInwards: boolean;
  33768. private _isPanClick;
  33769. private _pointerInput;
  33770. private _observer;
  33771. private _onMouseMove;
  33772. private _onGestureStart;
  33773. private _onGesture;
  33774. private _MSGestureHandler;
  33775. private _onLostFocus;
  33776. private _onContextMenu;
  33777. /**
  33778. * Attach the input controls to a specific dom element to get the input from.
  33779. * @param element Defines the element the controls should be listened from
  33780. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33781. */
  33782. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33783. /**
  33784. * Detach the current controls from the specified dom element.
  33785. * @param element Defines the element to stop listening the inputs from
  33786. */
  33787. detachControl(element: Nullable<HTMLElement>): void;
  33788. /**
  33789. * Gets the class name of the current intput.
  33790. * @returns the class name
  33791. */
  33792. getClassName(): string;
  33793. /**
  33794. * Get the friendly name associated with the input class.
  33795. * @returns the input friendly name
  33796. */
  33797. getSimpleName(): string;
  33798. }
  33799. }
  33800. declare module BABYLON {
  33801. /**
  33802. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  33803. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33804. */
  33805. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  33806. /**
  33807. * Defines the camera the input is attached to.
  33808. */
  33809. camera: ArcRotateCamera;
  33810. /**
  33811. * Defines the list of key codes associated with the up action (increase alpha)
  33812. */
  33813. keysUp: number[];
  33814. /**
  33815. * Defines the list of key codes associated with the down action (decrease alpha)
  33816. */
  33817. keysDown: number[];
  33818. /**
  33819. * Defines the list of key codes associated with the left action (increase beta)
  33820. */
  33821. keysLeft: number[];
  33822. /**
  33823. * Defines the list of key codes associated with the right action (decrease beta)
  33824. */
  33825. keysRight: number[];
  33826. /**
  33827. * Defines the list of key codes associated with the reset action.
  33828. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  33829. */
  33830. keysReset: number[];
  33831. /**
  33832. * Defines the panning sensibility of the inputs.
  33833. * (How fast is the camera paning)
  33834. */
  33835. panningSensibility: number;
  33836. /**
  33837. * Defines the zooming sensibility of the inputs.
  33838. * (How fast is the camera zooming)
  33839. */
  33840. zoomingSensibility: number;
  33841. /**
  33842. * Defines wether maintaining the alt key down switch the movement mode from
  33843. * orientation to zoom.
  33844. */
  33845. useAltToZoom: boolean;
  33846. /**
  33847. * Rotation speed of the camera
  33848. */
  33849. angularSpeed: number;
  33850. private _keys;
  33851. private _ctrlPressed;
  33852. private _altPressed;
  33853. private _onCanvasBlurObserver;
  33854. private _onKeyboardObserver;
  33855. private _engine;
  33856. private _scene;
  33857. /**
  33858. * Attach the input controls to a specific dom element to get the input from.
  33859. * @param element Defines the element the controls should be listened from
  33860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33861. */
  33862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33863. /**
  33864. * Detach the current controls from the specified dom element.
  33865. * @param element Defines the element to stop listening the inputs from
  33866. */
  33867. detachControl(element: Nullable<HTMLElement>): void;
  33868. /**
  33869. * Update the current camera state depending on the inputs that have been used this frame.
  33870. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  33871. */
  33872. checkInputs(): void;
  33873. /**
  33874. * Gets the class name of the current intput.
  33875. * @returns the class name
  33876. */
  33877. getClassName(): string;
  33878. /**
  33879. * Get the friendly name associated with the input class.
  33880. * @returns the input friendly name
  33881. */
  33882. getSimpleName(): string;
  33883. }
  33884. }
  33885. declare module BABYLON {
  33886. /**
  33887. * Manage the mouse wheel inputs to control an arc rotate camera.
  33888. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33889. */
  33890. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  33891. /**
  33892. * Defines the camera the input is attached to.
  33893. */
  33894. camera: ArcRotateCamera;
  33895. /**
  33896. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  33897. */
  33898. wheelPrecision: number;
  33899. /**
  33900. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  33901. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  33902. */
  33903. wheelDeltaPercentage: number;
  33904. private _wheel;
  33905. private _observer;
  33906. /**
  33907. * Attach the input controls to a specific dom element to get the input from.
  33908. * @param element Defines the element the controls should be listened from
  33909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33910. */
  33911. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33912. /**
  33913. * Detach the current controls from the specified dom element.
  33914. * @param element Defines the element to stop listening the inputs from
  33915. */
  33916. detachControl(element: Nullable<HTMLElement>): void;
  33917. /**
  33918. * Gets the class name of the current intput.
  33919. * @returns the class name
  33920. */
  33921. getClassName(): string;
  33922. /**
  33923. * Get the friendly name associated with the input class.
  33924. * @returns the input friendly name
  33925. */
  33926. getSimpleName(): string;
  33927. }
  33928. }
  33929. declare module BABYLON {
  33930. /**
  33931. * Default Inputs manager for the ArcRotateCamera.
  33932. * It groups all the default supported inputs for ease of use.
  33933. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33934. */
  33935. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  33936. /**
  33937. * Instantiates a new ArcRotateCameraInputsManager.
  33938. * @param camera Defines the camera the inputs belong to
  33939. */
  33940. constructor(camera: ArcRotateCamera);
  33941. /**
  33942. * Add mouse wheel input support to the input manager.
  33943. * @returns the current input manager
  33944. */
  33945. addMouseWheel(): ArcRotateCameraInputsManager;
  33946. /**
  33947. * Add pointers input support to the input manager.
  33948. * @returns the current input manager
  33949. */
  33950. addPointers(): ArcRotateCameraInputsManager;
  33951. /**
  33952. * Add keyboard input support to the input manager.
  33953. * @returns the current input manager
  33954. */
  33955. addKeyboard(): ArcRotateCameraInputsManager;
  33956. }
  33957. }
  33958. declare module BABYLON {
  33959. /**
  33960. * This represents an orbital type of camera.
  33961. *
  33962. * 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.
  33963. * 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.
  33964. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  33965. */
  33966. export class ArcRotateCamera extends TargetCamera {
  33967. /**
  33968. * Defines the rotation angle of the camera along the longitudinal axis.
  33969. */
  33970. alpha: number;
  33971. /**
  33972. * Defines the rotation angle of the camera along the latitudinal axis.
  33973. */
  33974. beta: number;
  33975. /**
  33976. * Defines the radius of the camera from it s target point.
  33977. */
  33978. radius: number;
  33979. protected _target: Vector3;
  33980. protected _targetHost: Nullable<AbstractMesh>;
  33981. /**
  33982. * Defines the target point of the camera.
  33983. * The camera looks towards it form the radius distance.
  33984. */
  33985. target: Vector3;
  33986. /**
  33987. * Current inertia value on the longitudinal axis.
  33988. * The bigger this number the longer it will take for the camera to stop.
  33989. */
  33990. inertialAlphaOffset: number;
  33991. /**
  33992. * Current inertia value on the latitudinal axis.
  33993. * The bigger this number the longer it will take for the camera to stop.
  33994. */
  33995. inertialBetaOffset: number;
  33996. /**
  33997. * Current inertia value on the radius axis.
  33998. * The bigger this number the longer it will take for the camera to stop.
  33999. */
  34000. inertialRadiusOffset: number;
  34001. /**
  34002. * Minimum allowed angle on the longitudinal axis.
  34003. * This can help limiting how the Camera is able to move in the scene.
  34004. */
  34005. lowerAlphaLimit: Nullable<number>;
  34006. /**
  34007. * Maximum allowed angle on the longitudinal axis.
  34008. * This can help limiting how the Camera is able to move in the scene.
  34009. */
  34010. upperAlphaLimit: Nullable<number>;
  34011. /**
  34012. * Minimum allowed angle on the latitudinal axis.
  34013. * This can help limiting how the Camera is able to move in the scene.
  34014. */
  34015. lowerBetaLimit: number;
  34016. /**
  34017. * Maximum allowed angle on the latitudinal axis.
  34018. * This can help limiting how the Camera is able to move in the scene.
  34019. */
  34020. upperBetaLimit: number;
  34021. /**
  34022. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34023. * This can help limiting how the Camera is able to move in the scene.
  34024. */
  34025. lowerRadiusLimit: Nullable<number>;
  34026. /**
  34027. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34028. * This can help limiting how the Camera is able to move in the scene.
  34029. */
  34030. upperRadiusLimit: Nullable<number>;
  34031. /**
  34032. * Defines the current inertia value used during panning of the camera along the X axis.
  34033. */
  34034. inertialPanningX: number;
  34035. /**
  34036. * Defines the current inertia value used during panning of the camera along the Y axis.
  34037. */
  34038. inertialPanningY: number;
  34039. /**
  34040. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34041. * Basically if your fingers moves away from more than this distance you will be considered
  34042. * in pinch mode.
  34043. */
  34044. pinchToPanMaxDistance: number;
  34045. /**
  34046. * Defines the maximum distance the camera can pan.
  34047. * This could help keeping the cammera always in your scene.
  34048. */
  34049. panningDistanceLimit: Nullable<number>;
  34050. /**
  34051. * Defines the target of the camera before paning.
  34052. */
  34053. panningOriginTarget: Vector3;
  34054. /**
  34055. * Defines the value of the inertia used during panning.
  34056. * 0 would mean stop inertia and one would mean no decelleration at all.
  34057. */
  34058. panningInertia: number;
  34059. /**
  34060. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34061. */
  34062. angularSensibilityX: number;
  34063. /**
  34064. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34065. */
  34066. angularSensibilityY: number;
  34067. /**
  34068. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34069. */
  34070. pinchPrecision: number;
  34071. /**
  34072. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34073. * It will be used instead of pinchDeltaPrecision if different from 0.
  34074. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34075. */
  34076. pinchDeltaPercentage: number;
  34077. /**
  34078. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34079. */
  34080. panningSensibility: number;
  34081. /**
  34082. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34083. */
  34084. keysUp: number[];
  34085. /**
  34086. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34087. */
  34088. keysDown: number[];
  34089. /**
  34090. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34091. */
  34092. keysLeft: number[];
  34093. /**
  34094. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34095. */
  34096. keysRight: number[];
  34097. /**
  34098. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34099. */
  34100. wheelPrecision: number;
  34101. /**
  34102. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34103. * It will be used instead of pinchDeltaPrecision if different from 0.
  34104. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34105. */
  34106. wheelDeltaPercentage: number;
  34107. /**
  34108. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34109. */
  34110. zoomOnFactor: number;
  34111. /**
  34112. * Defines a screen offset for the camera position.
  34113. */
  34114. targetScreenOffset: Vector2;
  34115. /**
  34116. * Allows the camera to be completely reversed.
  34117. * If false the camera can not arrive upside down.
  34118. */
  34119. allowUpsideDown: boolean;
  34120. /**
  34121. * Define if double tap/click is used to restore the previously saved state of the camera.
  34122. */
  34123. useInputToRestoreState: boolean;
  34124. /** @hidden */
  34125. _viewMatrix: Matrix;
  34126. /** @hidden */
  34127. _useCtrlForPanning: boolean;
  34128. /** @hidden */
  34129. _panningMouseButton: number;
  34130. /**
  34131. * Defines the input associated to the camera.
  34132. */
  34133. inputs: ArcRotateCameraInputsManager;
  34134. /** @hidden */
  34135. _reset: () => void;
  34136. /**
  34137. * Defines the allowed panning axis.
  34138. */
  34139. panningAxis: Vector3;
  34140. protected _localDirection: Vector3;
  34141. protected _transformedDirection: Vector3;
  34142. private _bouncingBehavior;
  34143. /**
  34144. * Gets the bouncing behavior of the camera if it has been enabled.
  34145. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34146. */
  34147. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34148. /**
  34149. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34150. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34151. */
  34152. useBouncingBehavior: boolean;
  34153. private _framingBehavior;
  34154. /**
  34155. * Gets the framing behavior of the camera if it has been enabled.
  34156. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34157. */
  34158. readonly framingBehavior: Nullable<FramingBehavior>;
  34159. /**
  34160. * Defines if the framing behavior of the camera is enabled on the camera.
  34161. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34162. */
  34163. useFramingBehavior: boolean;
  34164. private _autoRotationBehavior;
  34165. /**
  34166. * Gets the auto rotation behavior of the camera if it has been enabled.
  34167. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34168. */
  34169. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34170. /**
  34171. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34172. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34173. */
  34174. useAutoRotationBehavior: boolean;
  34175. /**
  34176. * Observable triggered when the mesh target has been changed on the camera.
  34177. */
  34178. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34179. /**
  34180. * Event raised when the camera is colliding with a mesh.
  34181. */
  34182. onCollide: (collidedMesh: AbstractMesh) => void;
  34183. /**
  34184. * Defines whether the camera should check collision with the objects oh the scene.
  34185. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34186. */
  34187. checkCollisions: boolean;
  34188. /**
  34189. * Defines the collision radius of the camera.
  34190. * This simulates a sphere around the camera.
  34191. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34192. */
  34193. collisionRadius: Vector3;
  34194. protected _collider: Collider;
  34195. protected _previousPosition: Vector3;
  34196. protected _collisionVelocity: Vector3;
  34197. protected _newPosition: Vector3;
  34198. protected _previousAlpha: number;
  34199. protected _previousBeta: number;
  34200. protected _previousRadius: number;
  34201. protected _collisionTriggered: boolean;
  34202. protected _targetBoundingCenter: Nullable<Vector3>;
  34203. private _computationVector;
  34204. private _tempAxisVector;
  34205. private _tempAxisRotationMatrix;
  34206. /**
  34207. * Instantiates a new ArcRotateCamera in a given scene
  34208. * @param name Defines the name of the camera
  34209. * @param alpha Defines the camera rotation along the logitudinal axis
  34210. * @param beta Defines the camera rotation along the latitudinal axis
  34211. * @param radius Defines the camera distance from its target
  34212. * @param target Defines the camera target
  34213. * @param scene Defines the scene the camera belongs to
  34214. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34215. */
  34216. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34217. /** @hidden */
  34218. _initCache(): void;
  34219. /** @hidden */
  34220. _updateCache(ignoreParentClass?: boolean): void;
  34221. protected _getTargetPosition(): Vector3;
  34222. private _storedAlpha;
  34223. private _storedBeta;
  34224. private _storedRadius;
  34225. private _storedTarget;
  34226. /**
  34227. * Stores the current state of the camera (alpha, beta, radius and target)
  34228. * @returns the camera itself
  34229. */
  34230. storeState(): Camera;
  34231. /**
  34232. * @hidden
  34233. * Restored camera state. You must call storeState() first
  34234. */
  34235. _restoreStateValues(): boolean;
  34236. /** @hidden */
  34237. _isSynchronizedViewMatrix(): boolean;
  34238. /**
  34239. * Attached controls to the current camera.
  34240. * @param element Defines the element the controls should be listened from
  34241. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34242. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34243. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34244. */
  34245. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34246. /**
  34247. * Detach the current controls from the camera.
  34248. * The camera will stop reacting to inputs.
  34249. * @param element Defines the element to stop listening the inputs from
  34250. */
  34251. detachControl(element: HTMLElement): void;
  34252. /** @hidden */
  34253. _checkInputs(): void;
  34254. protected _checkLimits(): void;
  34255. /**
  34256. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  34257. */
  34258. rebuildAnglesAndRadius(): void;
  34259. /**
  34260. * Use a position to define the current camera related information like aplha, beta and radius
  34261. * @param position Defines the position to set the camera at
  34262. */
  34263. setPosition(position: Vector3): void;
  34264. /**
  34265. * Defines the target the camera should look at.
  34266. * This will automatically adapt alpha beta and radius to fit within the new target.
  34267. * @param target Defines the new target as a Vector or a mesh
  34268. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34269. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34270. */
  34271. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34272. /** @hidden */
  34273. _getViewMatrix(): Matrix;
  34274. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34275. /**
  34276. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34277. * @param meshes Defines the mesh to zoom on
  34278. * @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)
  34279. */
  34280. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34281. /**
  34282. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34283. * The target will be changed but the radius
  34284. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34285. * @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)
  34286. */
  34287. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34288. min: Vector3;
  34289. max: Vector3;
  34290. distance: number;
  34291. }, doNotUpdateMaxZ?: boolean): void;
  34292. /**
  34293. * @override
  34294. * Override Camera.createRigCamera
  34295. */
  34296. createRigCamera(name: string, cameraIndex: number): Camera;
  34297. /**
  34298. * @hidden
  34299. * @override
  34300. * Override Camera._updateRigCameras
  34301. */
  34302. _updateRigCameras(): void;
  34303. /**
  34304. * Destroy the camera and release the current resources hold by it.
  34305. */
  34306. dispose(): void;
  34307. /**
  34308. * Gets the current object class name.
  34309. * @return the class name
  34310. */
  34311. getClassName(): string;
  34312. }
  34313. }
  34314. declare module BABYLON {
  34315. /**
  34316. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34317. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34318. */
  34319. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34320. /**
  34321. * Gets the name of the behavior.
  34322. */
  34323. readonly name: string;
  34324. private _zoomStopsAnimation;
  34325. private _idleRotationSpeed;
  34326. private _idleRotationWaitTime;
  34327. private _idleRotationSpinupTime;
  34328. /**
  34329. * Sets the flag that indicates if user zooming should stop animation.
  34330. */
  34331. /**
  34332. * Gets the flag that indicates if user zooming should stop animation.
  34333. */
  34334. zoomStopsAnimation: boolean;
  34335. /**
  34336. * Sets the default speed at which the camera rotates around the model.
  34337. */
  34338. /**
  34339. * Gets the default speed at which the camera rotates around the model.
  34340. */
  34341. idleRotationSpeed: number;
  34342. /**
  34343. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34344. */
  34345. /**
  34346. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34347. */
  34348. idleRotationWaitTime: number;
  34349. /**
  34350. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34351. */
  34352. /**
  34353. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34354. */
  34355. idleRotationSpinupTime: number;
  34356. /**
  34357. * Gets a value indicating if the camera is currently rotating because of this behavior
  34358. */
  34359. readonly rotationInProgress: boolean;
  34360. private _onPrePointerObservableObserver;
  34361. private _onAfterCheckInputsObserver;
  34362. private _attachedCamera;
  34363. private _isPointerDown;
  34364. private _lastFrameTime;
  34365. private _lastInteractionTime;
  34366. private _cameraRotationSpeed;
  34367. /**
  34368. * Initializes the behavior.
  34369. */
  34370. init(): void;
  34371. /**
  34372. * Attaches the behavior to its arc rotate camera.
  34373. * @param camera Defines the camera to attach the behavior to
  34374. */
  34375. attach(camera: ArcRotateCamera): void;
  34376. /**
  34377. * Detaches the behavior from its current arc rotate camera.
  34378. */
  34379. detach(): void;
  34380. /**
  34381. * Returns true if user is scrolling.
  34382. * @return true if user is scrolling.
  34383. */
  34384. private _userIsZooming;
  34385. private _lastFrameRadius;
  34386. private _shouldAnimationStopForInteraction;
  34387. /**
  34388. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34389. */
  34390. private _applyUserInteraction;
  34391. private _userIsMoving;
  34392. }
  34393. }
  34394. declare module BABYLON {
  34395. /**
  34396. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34397. */
  34398. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34399. private ui;
  34400. /**
  34401. * The name of the behavior
  34402. */
  34403. name: string;
  34404. /**
  34405. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34406. */
  34407. distanceAwayFromFace: number;
  34408. /**
  34409. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34410. */
  34411. distanceAwayFromBottomOfFace: number;
  34412. private _faceVectors;
  34413. private _target;
  34414. private _scene;
  34415. private _onRenderObserver;
  34416. private _tmpMatrix;
  34417. private _tmpVector;
  34418. /**
  34419. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34420. * @param ui The transform node that should be attched to the mesh
  34421. */
  34422. constructor(ui: TransformNode);
  34423. /**
  34424. * Initializes the behavior
  34425. */
  34426. init(): void;
  34427. private _closestFace;
  34428. private _zeroVector;
  34429. private _lookAtTmpMatrix;
  34430. private _lookAtToRef;
  34431. /**
  34432. * Attaches the AttachToBoxBehavior to the passed in mesh
  34433. * @param target The mesh that the specified node will be attached to
  34434. */
  34435. attach(target: Mesh): void;
  34436. /**
  34437. * Detaches the behavior from the mesh
  34438. */
  34439. detach(): void;
  34440. }
  34441. }
  34442. declare module BABYLON {
  34443. /**
  34444. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  34445. */
  34446. export class FadeInOutBehavior implements Behavior<Mesh> {
  34447. /**
  34448. * Time in milliseconds to delay before fading in (Default: 0)
  34449. */
  34450. delay: number;
  34451. /**
  34452. * Time in milliseconds for the mesh to fade in (Default: 300)
  34453. */
  34454. fadeInTime: number;
  34455. private _millisecondsPerFrame;
  34456. private _hovered;
  34457. private _hoverValue;
  34458. private _ownerNode;
  34459. /**
  34460. * Instatiates the FadeInOutBehavior
  34461. */
  34462. constructor();
  34463. /**
  34464. * The name of the behavior
  34465. */
  34466. readonly name: string;
  34467. /**
  34468. * Initializes the behavior
  34469. */
  34470. init(): void;
  34471. /**
  34472. * Attaches the fade behavior on the passed in mesh
  34473. * @param ownerNode The mesh that will be faded in/out once attached
  34474. */
  34475. attach(ownerNode: Mesh): void;
  34476. /**
  34477. * Detaches the behavior from the mesh
  34478. */
  34479. detach(): void;
  34480. /**
  34481. * Triggers the mesh to begin fading in or out
  34482. * @param value if the object should fade in or out (true to fade in)
  34483. */
  34484. fadeIn(value: boolean): void;
  34485. private _update;
  34486. private _setAllVisibility;
  34487. }
  34488. }
  34489. declare module BABYLON {
  34490. /**
  34491. * Class containing a set of static utilities functions for managing Pivots
  34492. * @hidden
  34493. */
  34494. export class PivotTools {
  34495. private static _PivotCached;
  34496. private static _OldPivotPoint;
  34497. private static _PivotTranslation;
  34498. private static _PivotTmpVector;
  34499. /** @hidden */
  34500. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  34501. /** @hidden */
  34502. static _RestorePivotPoint(mesh: AbstractMesh): void;
  34503. }
  34504. }
  34505. declare module BABYLON {
  34506. /**
  34507. * Class containing static functions to help procedurally build meshes
  34508. */
  34509. export class PlaneBuilder {
  34510. /**
  34511. * Creates a plane mesh
  34512. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  34513. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  34514. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  34515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34516. * * 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
  34517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34518. * @param name defines the name of the mesh
  34519. * @param options defines the options used to create the mesh
  34520. * @param scene defines the hosting scene
  34521. * @returns the plane mesh
  34522. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  34523. */
  34524. static CreatePlane(name: string, options: {
  34525. size?: number;
  34526. width?: number;
  34527. height?: number;
  34528. sideOrientation?: number;
  34529. frontUVs?: Vector4;
  34530. backUVs?: Vector4;
  34531. updatable?: boolean;
  34532. sourcePlane?: Plane;
  34533. }, scene: Scene): Mesh;
  34534. }
  34535. }
  34536. declare module BABYLON {
  34537. /**
  34538. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  34539. */
  34540. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  34541. private static _AnyMouseID;
  34542. private _attachedNode;
  34543. private _dragPlane;
  34544. private _scene;
  34545. private _pointerObserver;
  34546. private _beforeRenderObserver;
  34547. private static _planeScene;
  34548. /**
  34549. * 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)
  34550. */
  34551. maxDragAngle: number;
  34552. /**
  34553. * @hidden
  34554. */
  34555. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  34556. /**
  34557. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34558. */
  34559. currentDraggingPointerID: number;
  34560. /**
  34561. * The last position where the pointer hit the drag plane in world space
  34562. */
  34563. lastDragPosition: Vector3;
  34564. /**
  34565. * If the behavior is currently in a dragging state
  34566. */
  34567. dragging: boolean;
  34568. /**
  34569. * 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)
  34570. */
  34571. dragDeltaRatio: number;
  34572. /**
  34573. * If the drag plane orientation should be updated during the dragging (Default: true)
  34574. */
  34575. updateDragPlane: boolean;
  34576. private _debugMode;
  34577. private _moving;
  34578. /**
  34579. * Fires each time the attached mesh is dragged with the pointer
  34580. * * delta between last drag position and current drag position in world space
  34581. * * dragDistance along the drag axis
  34582. * * dragPlaneNormal normal of the current drag plane used during the drag
  34583. * * dragPlanePoint in world space where the drag intersects the drag plane
  34584. */
  34585. onDragObservable: Observable<{
  34586. delta: Vector3;
  34587. dragPlanePoint: Vector3;
  34588. dragPlaneNormal: Vector3;
  34589. dragDistance: number;
  34590. pointerId: number;
  34591. }>;
  34592. /**
  34593. * Fires each time a drag begins (eg. mouse down on mesh)
  34594. */
  34595. onDragStartObservable: Observable<{
  34596. dragPlanePoint: Vector3;
  34597. pointerId: number;
  34598. }>;
  34599. /**
  34600. * Fires each time a drag ends (eg. mouse release after drag)
  34601. */
  34602. onDragEndObservable: Observable<{
  34603. dragPlanePoint: Vector3;
  34604. pointerId: number;
  34605. }>;
  34606. /**
  34607. * If the attached mesh should be moved when dragged
  34608. */
  34609. moveAttached: boolean;
  34610. /**
  34611. * If the drag behavior will react to drag events (Default: true)
  34612. */
  34613. enabled: boolean;
  34614. /**
  34615. * If camera controls should be detached during the drag
  34616. */
  34617. detachCameraControls: boolean;
  34618. /**
  34619. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  34620. */
  34621. useObjectOrienationForDragging: boolean;
  34622. private _options;
  34623. /**
  34624. * Creates a pointer drag behavior that can be attached to a mesh
  34625. * @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)
  34626. */
  34627. constructor(options?: {
  34628. dragAxis?: Vector3;
  34629. dragPlaneNormal?: Vector3;
  34630. });
  34631. /**
  34632. * Predicate to determine if it is valid to move the object to a new position when it is moved
  34633. */
  34634. validateDrag: (targetPosition: Vector3) => boolean;
  34635. /**
  34636. * The name of the behavior
  34637. */
  34638. readonly name: string;
  34639. /**
  34640. * Initializes the behavior
  34641. */
  34642. init(): void;
  34643. private _tmpVector;
  34644. private _alternatePickedPoint;
  34645. private _worldDragAxis;
  34646. private _targetPosition;
  34647. private _attachedElement;
  34648. /**
  34649. * Attaches the drag behavior the passed in mesh
  34650. * @param ownerNode The mesh that will be dragged around once attached
  34651. */
  34652. attach(ownerNode: AbstractMesh): void;
  34653. /**
  34654. * Force relase the drag action by code.
  34655. */
  34656. releaseDrag(): void;
  34657. private _startDragRay;
  34658. private _lastPointerRay;
  34659. /**
  34660. * Simulates the start of a pointer drag event on the behavior
  34661. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  34662. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  34663. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  34664. */
  34665. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  34666. private _startDrag;
  34667. private _dragDelta;
  34668. private _moveDrag;
  34669. private _pickWithRayOnDragPlane;
  34670. private _pointA;
  34671. private _pointB;
  34672. private _pointC;
  34673. private _lineA;
  34674. private _lineB;
  34675. private _localAxis;
  34676. private _lookAt;
  34677. private _updateDragPlanePosition;
  34678. /**
  34679. * Detaches the behavior from the mesh
  34680. */
  34681. detach(): void;
  34682. }
  34683. }
  34684. declare module BABYLON {
  34685. /**
  34686. * A behavior that when attached to a mesh will allow the mesh to be scaled
  34687. */
  34688. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  34689. private _dragBehaviorA;
  34690. private _dragBehaviorB;
  34691. private _startDistance;
  34692. private _initialScale;
  34693. private _targetScale;
  34694. private _ownerNode;
  34695. private _sceneRenderObserver;
  34696. /**
  34697. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  34698. */
  34699. constructor();
  34700. /**
  34701. * The name of the behavior
  34702. */
  34703. readonly name: string;
  34704. /**
  34705. * Initializes the behavior
  34706. */
  34707. init(): void;
  34708. private _getCurrentDistance;
  34709. /**
  34710. * Attaches the scale behavior the passed in mesh
  34711. * @param ownerNode The mesh that will be scaled around once attached
  34712. */
  34713. attach(ownerNode: Mesh): void;
  34714. /**
  34715. * Detaches the behavior from the mesh
  34716. */
  34717. detach(): void;
  34718. }
  34719. }
  34720. declare module BABYLON {
  34721. /**
  34722. * 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
  34723. */
  34724. export class SixDofDragBehavior implements Behavior<Mesh> {
  34725. private static _virtualScene;
  34726. private _ownerNode;
  34727. private _sceneRenderObserver;
  34728. private _scene;
  34729. private _targetPosition;
  34730. private _virtualOriginMesh;
  34731. private _virtualDragMesh;
  34732. private _pointerObserver;
  34733. private _moving;
  34734. private _startingOrientation;
  34735. /**
  34736. * 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)
  34737. */
  34738. private zDragFactor;
  34739. /**
  34740. * If the object should rotate to face the drag origin
  34741. */
  34742. rotateDraggedObject: boolean;
  34743. /**
  34744. * If the behavior is currently in a dragging state
  34745. */
  34746. dragging: boolean;
  34747. /**
  34748. * 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)
  34749. */
  34750. dragDeltaRatio: number;
  34751. /**
  34752. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34753. */
  34754. currentDraggingPointerID: number;
  34755. /**
  34756. * If camera controls should be detached during the drag
  34757. */
  34758. detachCameraControls: boolean;
  34759. /**
  34760. * Fires each time a drag starts
  34761. */
  34762. onDragStartObservable: Observable<{}>;
  34763. /**
  34764. * Fires each time a drag ends (eg. mouse release after drag)
  34765. */
  34766. onDragEndObservable: Observable<{}>;
  34767. /**
  34768. * 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
  34769. */
  34770. constructor();
  34771. /**
  34772. * The name of the behavior
  34773. */
  34774. readonly name: string;
  34775. /**
  34776. * Initializes the behavior
  34777. */
  34778. init(): void;
  34779. /**
  34780. * Attaches the scale behavior the passed in mesh
  34781. * @param ownerNode The mesh that will be scaled around once attached
  34782. */
  34783. attach(ownerNode: Mesh): void;
  34784. /**
  34785. * Detaches the behavior from the mesh
  34786. */
  34787. detach(): void;
  34788. }
  34789. }
  34790. declare module BABYLON {
  34791. /**
  34792. * Class used to apply inverse kinematics to bones
  34793. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  34794. */
  34795. export class BoneIKController {
  34796. private static _tmpVecs;
  34797. private static _tmpQuat;
  34798. private static _tmpMats;
  34799. /**
  34800. * Gets or sets the target mesh
  34801. */
  34802. targetMesh: AbstractMesh;
  34803. /** Gets or sets the mesh used as pole */
  34804. poleTargetMesh: AbstractMesh;
  34805. /**
  34806. * Gets or sets the bone used as pole
  34807. */
  34808. poleTargetBone: Nullable<Bone>;
  34809. /**
  34810. * Gets or sets the target position
  34811. */
  34812. targetPosition: Vector3;
  34813. /**
  34814. * Gets or sets the pole target position
  34815. */
  34816. poleTargetPosition: Vector3;
  34817. /**
  34818. * Gets or sets the pole target local offset
  34819. */
  34820. poleTargetLocalOffset: Vector3;
  34821. /**
  34822. * Gets or sets the pole angle
  34823. */
  34824. poleAngle: number;
  34825. /**
  34826. * Gets or sets the mesh associated with the controller
  34827. */
  34828. mesh: AbstractMesh;
  34829. /**
  34830. * 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)
  34831. */
  34832. slerpAmount: number;
  34833. private _bone1Quat;
  34834. private _bone1Mat;
  34835. private _bone2Ang;
  34836. private _bone1;
  34837. private _bone2;
  34838. private _bone1Length;
  34839. private _bone2Length;
  34840. private _maxAngle;
  34841. private _maxReach;
  34842. private _rightHandedSystem;
  34843. private _bendAxis;
  34844. private _slerping;
  34845. private _adjustRoll;
  34846. /**
  34847. * Gets or sets maximum allowed angle
  34848. */
  34849. maxAngle: number;
  34850. /**
  34851. * Creates a new BoneIKController
  34852. * @param mesh defines the mesh to control
  34853. * @param bone defines the bone to control
  34854. * @param options defines options to set up the controller
  34855. */
  34856. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  34857. targetMesh?: AbstractMesh;
  34858. poleTargetMesh?: AbstractMesh;
  34859. poleTargetBone?: Bone;
  34860. poleTargetLocalOffset?: Vector3;
  34861. poleAngle?: number;
  34862. bendAxis?: Vector3;
  34863. maxAngle?: number;
  34864. slerpAmount?: number;
  34865. });
  34866. private _setMaxAngle;
  34867. /**
  34868. * Force the controller to update the bones
  34869. */
  34870. update(): void;
  34871. }
  34872. }
  34873. declare module BABYLON {
  34874. /**
  34875. * Class used to make a bone look toward a point in space
  34876. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  34877. */
  34878. export class BoneLookController {
  34879. private static _tmpVecs;
  34880. private static _tmpQuat;
  34881. private static _tmpMats;
  34882. /**
  34883. * The target Vector3 that the bone will look at
  34884. */
  34885. target: Vector3;
  34886. /**
  34887. * The mesh that the bone is attached to
  34888. */
  34889. mesh: AbstractMesh;
  34890. /**
  34891. * The bone that will be looking to the target
  34892. */
  34893. bone: Bone;
  34894. /**
  34895. * The up axis of the coordinate system that is used when the bone is rotated
  34896. */
  34897. upAxis: Vector3;
  34898. /**
  34899. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  34900. */
  34901. upAxisSpace: Space;
  34902. /**
  34903. * Used to make an adjustment to the yaw of the bone
  34904. */
  34905. adjustYaw: number;
  34906. /**
  34907. * Used to make an adjustment to the pitch of the bone
  34908. */
  34909. adjustPitch: number;
  34910. /**
  34911. * Used to make an adjustment to the roll of the bone
  34912. */
  34913. adjustRoll: number;
  34914. /**
  34915. * 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)
  34916. */
  34917. slerpAmount: number;
  34918. private _minYaw;
  34919. private _maxYaw;
  34920. private _minPitch;
  34921. private _maxPitch;
  34922. private _minYawSin;
  34923. private _minYawCos;
  34924. private _maxYawSin;
  34925. private _maxYawCos;
  34926. private _midYawConstraint;
  34927. private _minPitchTan;
  34928. private _maxPitchTan;
  34929. private _boneQuat;
  34930. private _slerping;
  34931. private _transformYawPitch;
  34932. private _transformYawPitchInv;
  34933. private _firstFrameSkipped;
  34934. private _yawRange;
  34935. private _fowardAxis;
  34936. /**
  34937. * Gets or sets the minimum yaw angle that the bone can look to
  34938. */
  34939. minYaw: number;
  34940. /**
  34941. * Gets or sets the maximum yaw angle that the bone can look to
  34942. */
  34943. maxYaw: number;
  34944. /**
  34945. * Gets or sets the minimum pitch angle that the bone can look to
  34946. */
  34947. minPitch: number;
  34948. /**
  34949. * Gets or sets the maximum pitch angle that the bone can look to
  34950. */
  34951. maxPitch: number;
  34952. /**
  34953. * Create a BoneLookController
  34954. * @param mesh the mesh that the bone belongs to
  34955. * @param bone the bone that will be looking to the target
  34956. * @param target the target Vector3 to look at
  34957. * @param options optional settings:
  34958. * * maxYaw: the maximum angle the bone will yaw to
  34959. * * minYaw: the minimum angle the bone will yaw to
  34960. * * maxPitch: the maximum angle the bone will pitch to
  34961. * * minPitch: the minimum angle the bone will yaw to
  34962. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  34963. * * upAxis: the up axis of the coordinate system
  34964. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  34965. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  34966. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  34967. * * adjustYaw: used to make an adjustment to the yaw of the bone
  34968. * * adjustPitch: used to make an adjustment to the pitch of the bone
  34969. * * adjustRoll: used to make an adjustment to the roll of the bone
  34970. **/
  34971. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  34972. maxYaw?: number;
  34973. minYaw?: number;
  34974. maxPitch?: number;
  34975. minPitch?: number;
  34976. slerpAmount?: number;
  34977. upAxis?: Vector3;
  34978. upAxisSpace?: Space;
  34979. yawAxis?: Vector3;
  34980. pitchAxis?: Vector3;
  34981. adjustYaw?: number;
  34982. adjustPitch?: number;
  34983. adjustRoll?: number;
  34984. });
  34985. /**
  34986. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  34987. */
  34988. update(): void;
  34989. private _getAngleDiff;
  34990. private _getAngleBetween;
  34991. private _isAngleBetween;
  34992. }
  34993. }
  34994. declare module BABYLON {
  34995. /**
  34996. * Manage the gamepad inputs to control an arc rotate camera.
  34997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34998. */
  34999. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35000. /**
  35001. * Defines the camera the input is attached to.
  35002. */
  35003. camera: ArcRotateCamera;
  35004. /**
  35005. * Defines the gamepad the input is gathering event from.
  35006. */
  35007. gamepad: Nullable<Gamepad>;
  35008. /**
  35009. * Defines the gamepad rotation sensiblity.
  35010. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35011. */
  35012. gamepadRotationSensibility: number;
  35013. /**
  35014. * Defines the gamepad move sensiblity.
  35015. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35016. */
  35017. gamepadMoveSensibility: number;
  35018. private _onGamepadConnectedObserver;
  35019. private _onGamepadDisconnectedObserver;
  35020. /**
  35021. * Attach the input controls to a specific dom element to get the input from.
  35022. * @param element Defines the element the controls should be listened from
  35023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35024. */
  35025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35026. /**
  35027. * Detach the current controls from the specified dom element.
  35028. * @param element Defines the element to stop listening the inputs from
  35029. */
  35030. detachControl(element: Nullable<HTMLElement>): void;
  35031. /**
  35032. * Update the current camera state depending on the inputs that have been used this frame.
  35033. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35034. */
  35035. checkInputs(): void;
  35036. /**
  35037. * Gets the class name of the current intput.
  35038. * @returns the class name
  35039. */
  35040. getClassName(): string;
  35041. /**
  35042. * Get the friendly name associated with the input class.
  35043. * @returns the input friendly name
  35044. */
  35045. getSimpleName(): string;
  35046. }
  35047. }
  35048. declare module BABYLON {
  35049. interface ArcRotateCameraInputsManager {
  35050. /**
  35051. * Add orientation input support to the input manager.
  35052. * @returns the current input manager
  35053. */
  35054. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35055. }
  35056. /**
  35057. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35058. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35059. */
  35060. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35061. /**
  35062. * Defines the camera the input is attached to.
  35063. */
  35064. camera: ArcRotateCamera;
  35065. /**
  35066. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35067. */
  35068. alphaCorrection: number;
  35069. /**
  35070. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35071. */
  35072. gammaCorrection: number;
  35073. private _alpha;
  35074. private _gamma;
  35075. private _dirty;
  35076. private _deviceOrientationHandler;
  35077. /**
  35078. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35079. */
  35080. constructor();
  35081. /**
  35082. * Attach the input controls to a specific dom element to get the input from.
  35083. * @param element Defines the element the controls should be listened from
  35084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35085. */
  35086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35087. /** @hidden */
  35088. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  35089. /**
  35090. * Update the current camera state depending on the inputs that have been used this frame.
  35091. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35092. */
  35093. checkInputs(): void;
  35094. /**
  35095. * Detach the current controls from the specified dom element.
  35096. * @param element Defines the element to stop listening the inputs from
  35097. */
  35098. detachControl(element: Nullable<HTMLElement>): void;
  35099. /**
  35100. * Gets the class name of the current intput.
  35101. * @returns the class name
  35102. */
  35103. getClassName(): string;
  35104. /**
  35105. * Get the friendly name associated with the input class.
  35106. * @returns the input friendly name
  35107. */
  35108. getSimpleName(): string;
  35109. }
  35110. }
  35111. declare module BABYLON {
  35112. /**
  35113. * Listen to mouse events to control the camera.
  35114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35115. */
  35116. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35117. /**
  35118. * Defines the camera the input is attached to.
  35119. */
  35120. camera: FlyCamera;
  35121. /**
  35122. * Defines if touch is enabled. (Default is true.)
  35123. */
  35124. touchEnabled: boolean;
  35125. /**
  35126. * Defines the buttons associated with the input to handle camera rotation.
  35127. */
  35128. buttons: number[];
  35129. /**
  35130. * Assign buttons for Yaw control.
  35131. */
  35132. buttonsYaw: number[];
  35133. /**
  35134. * Assign buttons for Pitch control.
  35135. */
  35136. buttonsPitch: number[];
  35137. /**
  35138. * Assign buttons for Roll control.
  35139. */
  35140. buttonsRoll: number[];
  35141. /**
  35142. * Detect if any button is being pressed while mouse is moved.
  35143. * -1 = Mouse locked.
  35144. * 0 = Left button.
  35145. * 1 = Middle Button.
  35146. * 2 = Right Button.
  35147. */
  35148. activeButton: number;
  35149. /**
  35150. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35151. * Higher values reduce its sensitivity.
  35152. */
  35153. angularSensibility: number;
  35154. private _mousemoveCallback;
  35155. private _observer;
  35156. private _rollObserver;
  35157. private previousPosition;
  35158. private noPreventDefault;
  35159. private element;
  35160. /**
  35161. * Listen to mouse events to control the camera.
  35162. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35164. */
  35165. constructor(touchEnabled?: boolean);
  35166. /**
  35167. * Attach the mouse control to the HTML DOM element.
  35168. * @param element Defines the element that listens to the input events.
  35169. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35170. */
  35171. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35172. /**
  35173. * Detach the current controls from the specified dom element.
  35174. * @param element Defines the element to stop listening the inputs from
  35175. */
  35176. detachControl(element: Nullable<HTMLElement>): void;
  35177. /**
  35178. * Gets the class name of the current input.
  35179. * @returns the class name.
  35180. */
  35181. getClassName(): string;
  35182. /**
  35183. * Get the friendly name associated with the input class.
  35184. * @returns the input's friendly name.
  35185. */
  35186. getSimpleName(): string;
  35187. private _pointerInput;
  35188. private _onMouseMove;
  35189. /**
  35190. * Rotate camera by mouse offset.
  35191. */
  35192. private rotateCamera;
  35193. }
  35194. }
  35195. declare module BABYLON {
  35196. /**
  35197. * Default Inputs manager for the FlyCamera.
  35198. * It groups all the default supported inputs for ease of use.
  35199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35200. */
  35201. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35202. /**
  35203. * Instantiates a new FlyCameraInputsManager.
  35204. * @param camera Defines the camera the inputs belong to.
  35205. */
  35206. constructor(camera: FlyCamera);
  35207. /**
  35208. * Add keyboard input support to the input manager.
  35209. * @returns the new FlyCameraKeyboardMoveInput().
  35210. */
  35211. addKeyboard(): FlyCameraInputsManager;
  35212. /**
  35213. * Add mouse input support to the input manager.
  35214. * @param touchEnabled Enable touch screen support.
  35215. * @returns the new FlyCameraMouseInput().
  35216. */
  35217. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35218. }
  35219. }
  35220. declare module BABYLON {
  35221. /**
  35222. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35223. * such as in a 3D Space Shooter or a Flight Simulator.
  35224. */
  35225. export class FlyCamera extends TargetCamera {
  35226. /**
  35227. * Define the collision ellipsoid of the camera.
  35228. * This is helpful for simulating a camera body, like a player's body.
  35229. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35230. */
  35231. ellipsoid: Vector3;
  35232. /**
  35233. * Define an offset for the position of the ellipsoid around the camera.
  35234. * This can be helpful if the camera is attached away from the player's body center,
  35235. * such as at its head.
  35236. */
  35237. ellipsoidOffset: Vector3;
  35238. /**
  35239. * Enable or disable collisions of the camera with the rest of the scene objects.
  35240. */
  35241. checkCollisions: boolean;
  35242. /**
  35243. * Enable or disable gravity on the camera.
  35244. */
  35245. applyGravity: boolean;
  35246. /**
  35247. * Define the current direction the camera is moving to.
  35248. */
  35249. cameraDirection: Vector3;
  35250. /**
  35251. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35252. * This overrides and empties cameraRotation.
  35253. */
  35254. rotationQuaternion: Quaternion;
  35255. /**
  35256. * Track Roll to maintain the wanted Rolling when looking around.
  35257. */
  35258. _trackRoll: number;
  35259. /**
  35260. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35261. */
  35262. rollCorrect: number;
  35263. /**
  35264. * Mimic a banked turn, Rolling the camera when Yawing.
  35265. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35266. */
  35267. bankedTurn: boolean;
  35268. /**
  35269. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35270. */
  35271. bankedTurnLimit: number;
  35272. /**
  35273. * Value of 0 disables the banked Roll.
  35274. * Value of 1 is equal to the Yaw angle in radians.
  35275. */
  35276. bankedTurnMultiplier: number;
  35277. /**
  35278. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35279. */
  35280. inputs: FlyCameraInputsManager;
  35281. /**
  35282. * Gets the input sensibility for mouse input.
  35283. * Higher values reduce sensitivity.
  35284. */
  35285. /**
  35286. * Sets the input sensibility for a mouse input.
  35287. * Higher values reduce sensitivity.
  35288. */
  35289. angularSensibility: number;
  35290. /**
  35291. * Get the keys for camera movement forward.
  35292. */
  35293. /**
  35294. * Set the keys for camera movement forward.
  35295. */
  35296. keysForward: number[];
  35297. /**
  35298. * Get the keys for camera movement backward.
  35299. */
  35300. keysBackward: number[];
  35301. /**
  35302. * Get the keys for camera movement up.
  35303. */
  35304. /**
  35305. * Set the keys for camera movement up.
  35306. */
  35307. keysUp: number[];
  35308. /**
  35309. * Get the keys for camera movement down.
  35310. */
  35311. /**
  35312. * Set the keys for camera movement down.
  35313. */
  35314. keysDown: number[];
  35315. /**
  35316. * Get the keys for camera movement left.
  35317. */
  35318. /**
  35319. * Set the keys for camera movement left.
  35320. */
  35321. keysLeft: number[];
  35322. /**
  35323. * Set the keys for camera movement right.
  35324. */
  35325. /**
  35326. * Set the keys for camera movement right.
  35327. */
  35328. keysRight: number[];
  35329. /**
  35330. * Event raised when the camera collides with a mesh in the scene.
  35331. */
  35332. onCollide: (collidedMesh: AbstractMesh) => void;
  35333. private _collider;
  35334. private _needMoveForGravity;
  35335. private _oldPosition;
  35336. private _diffPosition;
  35337. private _newPosition;
  35338. /** @hidden */
  35339. _localDirection: Vector3;
  35340. /** @hidden */
  35341. _transformedDirection: Vector3;
  35342. /**
  35343. * Instantiates a FlyCamera.
  35344. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35345. * such as in a 3D Space Shooter or a Flight Simulator.
  35346. * @param name Define the name of the camera in the scene.
  35347. * @param position Define the starting position of the camera in the scene.
  35348. * @param scene Define the scene the camera belongs to.
  35349. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35350. */
  35351. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35352. /**
  35353. * Attach a control to the HTML DOM element.
  35354. * @param element Defines the element that listens to the input events.
  35355. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35356. */
  35357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35358. /**
  35359. * Detach a control from the HTML DOM element.
  35360. * The camera will stop reacting to that input.
  35361. * @param element Defines the element that listens to the input events.
  35362. */
  35363. detachControl(element: HTMLElement): void;
  35364. private _collisionMask;
  35365. /**
  35366. * Get the mask that the camera ignores in collision events.
  35367. */
  35368. /**
  35369. * Set the mask that the camera ignores in collision events.
  35370. */
  35371. collisionMask: number;
  35372. /** @hidden */
  35373. _collideWithWorld(displacement: Vector3): void;
  35374. /** @hidden */
  35375. private _onCollisionPositionChange;
  35376. /** @hidden */
  35377. _checkInputs(): void;
  35378. /** @hidden */
  35379. _decideIfNeedsToMove(): boolean;
  35380. /** @hidden */
  35381. _updatePosition(): void;
  35382. /**
  35383. * Restore the Roll to its target value at the rate specified.
  35384. * @param rate - Higher means slower restoring.
  35385. * @hidden
  35386. */
  35387. restoreRoll(rate: number): void;
  35388. /**
  35389. * Destroy the camera and release the current resources held by it.
  35390. */
  35391. dispose(): void;
  35392. /**
  35393. * Get the current object class name.
  35394. * @returns the class name.
  35395. */
  35396. getClassName(): string;
  35397. }
  35398. }
  35399. declare module BABYLON {
  35400. /**
  35401. * Listen to keyboard events to control the camera.
  35402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35403. */
  35404. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35405. /**
  35406. * Defines the camera the input is attached to.
  35407. */
  35408. camera: FlyCamera;
  35409. /**
  35410. * The list of keyboard keys used to control the forward move of the camera.
  35411. */
  35412. keysForward: number[];
  35413. /**
  35414. * The list of keyboard keys used to control the backward move of the camera.
  35415. */
  35416. keysBackward: number[];
  35417. /**
  35418. * The list of keyboard keys used to control the forward move of the camera.
  35419. */
  35420. keysUp: number[];
  35421. /**
  35422. * The list of keyboard keys used to control the backward move of the camera.
  35423. */
  35424. keysDown: number[];
  35425. /**
  35426. * The list of keyboard keys used to control the right strafe move of the camera.
  35427. */
  35428. keysRight: number[];
  35429. /**
  35430. * The list of keyboard keys used to control the left strafe move of the camera.
  35431. */
  35432. keysLeft: number[];
  35433. private _keys;
  35434. private _onCanvasBlurObserver;
  35435. private _onKeyboardObserver;
  35436. private _engine;
  35437. private _scene;
  35438. /**
  35439. * Attach the input controls to a specific dom element to get the input from.
  35440. * @param element Defines the element the controls should be listened from
  35441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35442. */
  35443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35444. /**
  35445. * Detach the current controls from the specified dom element.
  35446. * @param element Defines the element to stop listening the inputs from
  35447. */
  35448. detachControl(element: Nullable<HTMLElement>): void;
  35449. /**
  35450. * Gets the class name of the current intput.
  35451. * @returns the class name
  35452. */
  35453. getClassName(): string;
  35454. /** @hidden */
  35455. _onLostFocus(e: FocusEvent): void;
  35456. /**
  35457. * Get the friendly name associated with the input class.
  35458. * @returns the input friendly name
  35459. */
  35460. getSimpleName(): string;
  35461. /**
  35462. * Update the current camera state depending on the inputs that have been used this frame.
  35463. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35464. */
  35465. checkInputs(): void;
  35466. }
  35467. }
  35468. declare module BABYLON {
  35469. interface FreeCameraInputsManager {
  35470. /**
  35471. * Add orientation input support to the input manager.
  35472. * @returns the current input manager
  35473. */
  35474. addDeviceOrientation(): FreeCameraInputsManager;
  35475. }
  35476. /**
  35477. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  35478. * Screen rotation is taken into account.
  35479. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35480. */
  35481. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  35482. private _camera;
  35483. private _screenOrientationAngle;
  35484. private _constantTranform;
  35485. private _screenQuaternion;
  35486. private _alpha;
  35487. private _beta;
  35488. private _gamma;
  35489. /**
  35490. * Instantiates a new input
  35491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35492. */
  35493. constructor();
  35494. /**
  35495. * Define the camera controlled by the input.
  35496. */
  35497. camera: FreeCamera;
  35498. /**
  35499. * Attach the input controls to a specific dom element to get the input from.
  35500. * @param element Defines the element the controls should be listened from
  35501. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35502. */
  35503. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35504. private _orientationChanged;
  35505. private _deviceOrientation;
  35506. /**
  35507. * Detach the current controls from the specified dom element.
  35508. * @param element Defines the element to stop listening the inputs from
  35509. */
  35510. detachControl(element: Nullable<HTMLElement>): void;
  35511. /**
  35512. * Update the current camera state depending on the inputs that have been used this frame.
  35513. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35514. */
  35515. checkInputs(): void;
  35516. /**
  35517. * Gets the class name of the current intput.
  35518. * @returns the class name
  35519. */
  35520. getClassName(): string;
  35521. /**
  35522. * Get the friendly name associated with the input class.
  35523. * @returns the input friendly name
  35524. */
  35525. getSimpleName(): string;
  35526. }
  35527. }
  35528. declare module BABYLON {
  35529. /**
  35530. * Manage the gamepad inputs to control a free camera.
  35531. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35532. */
  35533. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  35534. /**
  35535. * Define the camera the input is attached to.
  35536. */
  35537. camera: FreeCamera;
  35538. /**
  35539. * Define the Gamepad controlling the input
  35540. */
  35541. gamepad: Nullable<Gamepad>;
  35542. /**
  35543. * Defines the gamepad rotation sensiblity.
  35544. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35545. */
  35546. gamepadAngularSensibility: number;
  35547. /**
  35548. * Defines the gamepad move sensiblity.
  35549. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35550. */
  35551. gamepadMoveSensibility: number;
  35552. private _onGamepadConnectedObserver;
  35553. private _onGamepadDisconnectedObserver;
  35554. private _cameraTransform;
  35555. private _deltaTransform;
  35556. private _vector3;
  35557. private _vector2;
  35558. /**
  35559. * Attach the input controls to a specific dom element to get the input from.
  35560. * @param element Defines the element the controls should be listened from
  35561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35562. */
  35563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35564. /**
  35565. * Detach the current controls from the specified dom element.
  35566. * @param element Defines the element to stop listening the inputs from
  35567. */
  35568. detachControl(element: Nullable<HTMLElement>): void;
  35569. /**
  35570. * Update the current camera state depending on the inputs that have been used this frame.
  35571. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35572. */
  35573. checkInputs(): void;
  35574. /**
  35575. * Gets the class name of the current intput.
  35576. * @returns the class name
  35577. */
  35578. getClassName(): string;
  35579. /**
  35580. * Get the friendly name associated with the input class.
  35581. * @returns the input friendly name
  35582. */
  35583. getSimpleName(): string;
  35584. }
  35585. }
  35586. declare module BABYLON {
  35587. /**
  35588. * Defines the potential axis of a Joystick
  35589. */
  35590. export enum JoystickAxis {
  35591. /** X axis */
  35592. X = 0,
  35593. /** Y axis */
  35594. Y = 1,
  35595. /** Z axis */
  35596. Z = 2
  35597. }
  35598. /**
  35599. * Class used to define virtual joystick (used in touch mode)
  35600. */
  35601. export class VirtualJoystick {
  35602. /**
  35603. * Gets or sets a boolean indicating that left and right values must be inverted
  35604. */
  35605. reverseLeftRight: boolean;
  35606. /**
  35607. * Gets or sets a boolean indicating that up and down values must be inverted
  35608. */
  35609. reverseUpDown: boolean;
  35610. /**
  35611. * Gets the offset value for the position (ie. the change of the position value)
  35612. */
  35613. deltaPosition: Vector3;
  35614. /**
  35615. * Gets a boolean indicating if the virtual joystick was pressed
  35616. */
  35617. pressed: boolean;
  35618. /**
  35619. * Canvas the virtual joystick will render onto, default z-index of this is 5
  35620. */
  35621. static Canvas: Nullable<HTMLCanvasElement>;
  35622. private static _globalJoystickIndex;
  35623. private static vjCanvasContext;
  35624. private static vjCanvasWidth;
  35625. private static vjCanvasHeight;
  35626. private static halfWidth;
  35627. private _action;
  35628. private _axisTargetedByLeftAndRight;
  35629. private _axisTargetedByUpAndDown;
  35630. private _joystickSensibility;
  35631. private _inversedSensibility;
  35632. private _joystickPointerID;
  35633. private _joystickColor;
  35634. private _joystickPointerPos;
  35635. private _joystickPreviousPointerPos;
  35636. private _joystickPointerStartPos;
  35637. private _deltaJoystickVector;
  35638. private _leftJoystick;
  35639. private _touches;
  35640. private _onPointerDownHandlerRef;
  35641. private _onPointerMoveHandlerRef;
  35642. private _onPointerUpHandlerRef;
  35643. private _onResize;
  35644. /**
  35645. * Creates a new virtual joystick
  35646. * @param leftJoystick defines that the joystick is for left hand (false by default)
  35647. */
  35648. constructor(leftJoystick?: boolean);
  35649. /**
  35650. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  35651. * @param newJoystickSensibility defines the new sensibility
  35652. */
  35653. setJoystickSensibility(newJoystickSensibility: number): void;
  35654. private _onPointerDown;
  35655. private _onPointerMove;
  35656. private _onPointerUp;
  35657. /**
  35658. * Change the color of the virtual joystick
  35659. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  35660. */
  35661. setJoystickColor(newColor: string): void;
  35662. /**
  35663. * Defines a callback to call when the joystick is touched
  35664. * @param action defines the callback
  35665. */
  35666. setActionOnTouch(action: () => any): void;
  35667. /**
  35668. * Defines which axis you'd like to control for left & right
  35669. * @param axis defines the axis to use
  35670. */
  35671. setAxisForLeftRight(axis: JoystickAxis): void;
  35672. /**
  35673. * Defines which axis you'd like to control for up & down
  35674. * @param axis defines the axis to use
  35675. */
  35676. setAxisForUpDown(axis: JoystickAxis): void;
  35677. private _drawVirtualJoystick;
  35678. /**
  35679. * Release internal HTML canvas
  35680. */
  35681. releaseCanvas(): void;
  35682. }
  35683. }
  35684. declare module BABYLON {
  35685. interface FreeCameraInputsManager {
  35686. /**
  35687. * Add virtual joystick input support to the input manager.
  35688. * @returns the current input manager
  35689. */
  35690. addVirtualJoystick(): FreeCameraInputsManager;
  35691. }
  35692. /**
  35693. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  35694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35695. */
  35696. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  35697. /**
  35698. * Defines the camera the input is attached to.
  35699. */
  35700. camera: FreeCamera;
  35701. private _leftjoystick;
  35702. private _rightjoystick;
  35703. /**
  35704. * Gets the left stick of the virtual joystick.
  35705. * @returns The virtual Joystick
  35706. */
  35707. getLeftJoystick(): VirtualJoystick;
  35708. /**
  35709. * Gets the right stick of the virtual joystick.
  35710. * @returns The virtual Joystick
  35711. */
  35712. getRightJoystick(): VirtualJoystick;
  35713. /**
  35714. * Update the current camera state depending on the inputs that have been used this frame.
  35715. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35716. */
  35717. checkInputs(): void;
  35718. /**
  35719. * Attach the input controls to a specific dom element to get the input from.
  35720. * @param element Defines the element the controls should be listened from
  35721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35722. */
  35723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35724. /**
  35725. * Detach the current controls from the specified dom element.
  35726. * @param element Defines the element to stop listening the inputs from
  35727. */
  35728. detachControl(element: Nullable<HTMLElement>): void;
  35729. /**
  35730. * Gets the class name of the current intput.
  35731. * @returns the class name
  35732. */
  35733. getClassName(): string;
  35734. /**
  35735. * Get the friendly name associated with the input class.
  35736. * @returns the input friendly name
  35737. */
  35738. getSimpleName(): string;
  35739. }
  35740. }
  35741. declare module BABYLON {
  35742. /**
  35743. * This represents a FPS type of camera controlled by touch.
  35744. * This is like a universal camera minus the Gamepad controls.
  35745. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35746. */
  35747. export class TouchCamera extends FreeCamera {
  35748. /**
  35749. * Defines the touch sensibility for rotation.
  35750. * The higher the faster.
  35751. */
  35752. touchAngularSensibility: number;
  35753. /**
  35754. * Defines the touch sensibility for move.
  35755. * The higher the faster.
  35756. */
  35757. touchMoveSensibility: number;
  35758. /**
  35759. * Instantiates a new touch camera.
  35760. * This represents a FPS type of camera controlled by touch.
  35761. * This is like a universal camera minus the Gamepad controls.
  35762. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35763. * @param name Define the name of the camera in the scene
  35764. * @param position Define the start position of the camera in the scene
  35765. * @param scene Define the scene the camera belongs to
  35766. */
  35767. constructor(name: string, position: Vector3, scene: Scene);
  35768. /**
  35769. * Gets the current object class name.
  35770. * @return the class name
  35771. */
  35772. getClassName(): string;
  35773. /** @hidden */
  35774. _setupInputs(): void;
  35775. }
  35776. }
  35777. declare module BABYLON {
  35778. /**
  35779. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  35780. * being tilted forward or back and left or right.
  35781. */
  35782. export class DeviceOrientationCamera extends FreeCamera {
  35783. private _initialQuaternion;
  35784. private _quaternionCache;
  35785. /**
  35786. * Creates a new device orientation camera
  35787. * @param name The name of the camera
  35788. * @param position The start position camera
  35789. * @param scene The scene the camera belongs to
  35790. */
  35791. constructor(name: string, position: Vector3, scene: Scene);
  35792. /**
  35793. * Gets the current instance class name ("DeviceOrientationCamera").
  35794. * This helps avoiding instanceof at run time.
  35795. * @returns the class name
  35796. */
  35797. getClassName(): string;
  35798. /**
  35799. * @hidden
  35800. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  35801. */
  35802. _checkInputs(): void;
  35803. /**
  35804. * Reset the camera to its default orientation on the specified axis only.
  35805. * @param axis The axis to reset
  35806. */
  35807. resetToCurrentRotation(axis?: Axis): void;
  35808. }
  35809. }
  35810. declare module BABYLON {
  35811. /**
  35812. * Manage the keyboard inputs to control the movement of a follow camera.
  35813. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35814. */
  35815. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  35816. /**
  35817. * Defines the camera the input is attached to.
  35818. */
  35819. camera: FollowCamera;
  35820. /**
  35821. * Defines the list of key codes associated with the up action (increase heightOffset)
  35822. */
  35823. keysHeightOffsetIncr: number[];
  35824. /**
  35825. * Defines the list of key codes associated with the down action (decrease heightOffset)
  35826. */
  35827. keysHeightOffsetDecr: number[];
  35828. /**
  35829. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  35830. */
  35831. keysHeightOffsetModifierAlt: boolean;
  35832. /**
  35833. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  35834. */
  35835. keysHeightOffsetModifierCtrl: boolean;
  35836. /**
  35837. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  35838. */
  35839. keysHeightOffsetModifierShift: boolean;
  35840. /**
  35841. * Defines the list of key codes associated with the left action (increase rotationOffset)
  35842. */
  35843. keysRotationOffsetIncr: number[];
  35844. /**
  35845. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  35846. */
  35847. keysRotationOffsetDecr: number[];
  35848. /**
  35849. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  35850. */
  35851. keysRotationOffsetModifierAlt: boolean;
  35852. /**
  35853. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  35854. */
  35855. keysRotationOffsetModifierCtrl: boolean;
  35856. /**
  35857. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  35858. */
  35859. keysRotationOffsetModifierShift: boolean;
  35860. /**
  35861. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  35862. */
  35863. keysRadiusIncr: number[];
  35864. /**
  35865. * Defines the list of key codes associated with the zoom-out action (increase radius)
  35866. */
  35867. keysRadiusDecr: number[];
  35868. /**
  35869. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  35870. */
  35871. keysRadiusModifierAlt: boolean;
  35872. /**
  35873. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  35874. */
  35875. keysRadiusModifierCtrl: boolean;
  35876. /**
  35877. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  35878. */
  35879. keysRadiusModifierShift: boolean;
  35880. /**
  35881. * Defines the rate of change of heightOffset.
  35882. */
  35883. heightSensibility: number;
  35884. /**
  35885. * Defines the rate of change of rotationOffset.
  35886. */
  35887. rotationSensibility: number;
  35888. /**
  35889. * Defines the rate of change of radius.
  35890. */
  35891. radiusSensibility: number;
  35892. private _keys;
  35893. private _ctrlPressed;
  35894. private _altPressed;
  35895. private _shiftPressed;
  35896. private _onCanvasBlurObserver;
  35897. private _onKeyboardObserver;
  35898. private _engine;
  35899. private _scene;
  35900. /**
  35901. * Attach the input controls to a specific dom element to get the input from.
  35902. * @param element Defines the element the controls should be listened from
  35903. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35904. */
  35905. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35906. /**
  35907. * Detach the current controls from the specified dom element.
  35908. * @param element Defines the element to stop listening the inputs from
  35909. */
  35910. detachControl(element: Nullable<HTMLElement>): void;
  35911. /**
  35912. * Update the current camera state depending on the inputs that have been used this frame.
  35913. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35914. */
  35915. checkInputs(): void;
  35916. /**
  35917. * Gets the class name of the current input.
  35918. * @returns the class name
  35919. */
  35920. getClassName(): string;
  35921. /**
  35922. * Get the friendly name associated with the input class.
  35923. * @returns the input friendly name
  35924. */
  35925. getSimpleName(): string;
  35926. /**
  35927. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35928. * allow modification of the heightOffset value.
  35929. */
  35930. private _modifierHeightOffset;
  35931. /**
  35932. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35933. * allow modification of the rotationOffset value.
  35934. */
  35935. private _modifierRotationOffset;
  35936. /**
  35937. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35938. * allow modification of the radius value.
  35939. */
  35940. private _modifierRadius;
  35941. }
  35942. }
  35943. declare module BABYLON {
  35944. /**
  35945. * Manage the mouse wheel inputs to control a follow camera.
  35946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35947. */
  35948. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35949. /**
  35950. * Defines the camera the input is attached to.
  35951. */
  35952. camera: FollowCamera;
  35953. /**
  35954. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  35955. */
  35956. axisControlRadius: boolean;
  35957. /**
  35958. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  35959. */
  35960. axisControlHeight: boolean;
  35961. /**
  35962. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  35963. */
  35964. axisControlRotation: boolean;
  35965. /**
  35966. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35967. * relation to mouseWheel events.
  35968. */
  35969. wheelPrecision: number;
  35970. /**
  35971. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35972. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35973. */
  35974. wheelDeltaPercentage: number;
  35975. private _wheel;
  35976. private _observer;
  35977. /**
  35978. * Attach the input controls to a specific dom element to get the input from.
  35979. * @param element Defines the element the controls should be listened from
  35980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35981. */
  35982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35983. /**
  35984. * Detach the current controls from the specified dom element.
  35985. * @param element Defines the element to stop listening the inputs from
  35986. */
  35987. detachControl(element: Nullable<HTMLElement>): void;
  35988. /**
  35989. * Gets the class name of the current intput.
  35990. * @returns the class name
  35991. */
  35992. getClassName(): string;
  35993. /**
  35994. * Get the friendly name associated with the input class.
  35995. * @returns the input friendly name
  35996. */
  35997. getSimpleName(): string;
  35998. }
  35999. }
  36000. declare module BABYLON {
  36001. /**
  36002. * Default Inputs manager for the FollowCamera.
  36003. * It groups all the default supported inputs for ease of use.
  36004. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36005. */
  36006. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36007. /**
  36008. * Instantiates a new FollowCameraInputsManager.
  36009. * @param camera Defines the camera the inputs belong to
  36010. */
  36011. constructor(camera: FollowCamera);
  36012. /**
  36013. * Add keyboard input support to the input manager.
  36014. * @returns the current input manager
  36015. */
  36016. addKeyboard(): FollowCameraInputsManager;
  36017. /**
  36018. * Add mouse wheel input support to the input manager.
  36019. * @returns the current input manager
  36020. */
  36021. addMouseWheel(): FollowCameraInputsManager;
  36022. /**
  36023. * Add pointers input support to the input manager.
  36024. * @returns the current input manager
  36025. */
  36026. addPointers(): FollowCameraInputsManager;
  36027. /**
  36028. * Add orientation input support to the input manager.
  36029. * @returns the current input manager
  36030. */
  36031. addVRDeviceOrientation(): FollowCameraInputsManager;
  36032. }
  36033. }
  36034. declare module BABYLON {
  36035. /**
  36036. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36037. * an arc rotate version arcFollowCamera are available.
  36038. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36039. */
  36040. export class FollowCamera extends TargetCamera {
  36041. /**
  36042. * Distance the follow camera should follow an object at
  36043. */
  36044. radius: number;
  36045. /**
  36046. * Minimum allowed distance of the camera to the axis of rotation
  36047. * (The camera can not get closer).
  36048. * This can help limiting how the Camera is able to move in the scene.
  36049. */
  36050. lowerRadiusLimit: Nullable<number>;
  36051. /**
  36052. * Maximum allowed distance of the camera to the axis of rotation
  36053. * (The camera can not get further).
  36054. * This can help limiting how the Camera is able to move in the scene.
  36055. */
  36056. upperRadiusLimit: Nullable<number>;
  36057. /**
  36058. * Define a rotation offset between the camera and the object it follows
  36059. */
  36060. rotationOffset: number;
  36061. /**
  36062. * Minimum allowed angle to camera position relative to target object.
  36063. * This can help limiting how the Camera is able to move in the scene.
  36064. */
  36065. lowerRotationOffsetLimit: Nullable<number>;
  36066. /**
  36067. * Maximum allowed angle to camera position relative to target object.
  36068. * This can help limiting how the Camera is able to move in the scene.
  36069. */
  36070. upperRotationOffsetLimit: Nullable<number>;
  36071. /**
  36072. * Define a height offset between the camera and the object it follows.
  36073. * It can help following an object from the top (like a car chaing a plane)
  36074. */
  36075. heightOffset: number;
  36076. /**
  36077. * Minimum allowed height of camera position relative to target object.
  36078. * This can help limiting how the Camera is able to move in the scene.
  36079. */
  36080. lowerHeightOffsetLimit: Nullable<number>;
  36081. /**
  36082. * Maximum allowed height of camera position relative to target object.
  36083. * This can help limiting how the Camera is able to move in the scene.
  36084. */
  36085. upperHeightOffsetLimit: Nullable<number>;
  36086. /**
  36087. * Define how fast the camera can accelerate to follow it s target.
  36088. */
  36089. cameraAcceleration: number;
  36090. /**
  36091. * Define the speed limit of the camera following an object.
  36092. */
  36093. maxCameraSpeed: number;
  36094. /**
  36095. * Define the target of the camera.
  36096. */
  36097. lockedTarget: Nullable<AbstractMesh>;
  36098. /**
  36099. * Defines the input associated with the camera.
  36100. */
  36101. inputs: FollowCameraInputsManager;
  36102. /**
  36103. * Instantiates the follow camera.
  36104. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36105. * @param name Define the name of the camera in the scene
  36106. * @param position Define the position of the camera
  36107. * @param scene Define the scene the camera belong to
  36108. * @param lockedTarget Define the target of the camera
  36109. */
  36110. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36111. private _follow;
  36112. /**
  36113. * Attached controls to the current camera.
  36114. * @param element Defines the element the controls should be listened from
  36115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36116. */
  36117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36118. /**
  36119. * Detach the current controls from the camera.
  36120. * The camera will stop reacting to inputs.
  36121. * @param element Defines the element to stop listening the inputs from
  36122. */
  36123. detachControl(element: HTMLElement): void;
  36124. /** @hidden */
  36125. _checkInputs(): void;
  36126. private _checkLimits;
  36127. /**
  36128. * Gets the camera class name.
  36129. * @returns the class name
  36130. */
  36131. getClassName(): string;
  36132. }
  36133. /**
  36134. * Arc Rotate version of the follow camera.
  36135. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36136. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36137. */
  36138. export class ArcFollowCamera extends TargetCamera {
  36139. /** The longitudinal angle of the camera */
  36140. alpha: number;
  36141. /** The latitudinal angle of the camera */
  36142. beta: number;
  36143. /** The radius of the camera from its target */
  36144. radius: number;
  36145. /** Define the camera target (the messh it should follow) */
  36146. target: Nullable<AbstractMesh>;
  36147. private _cartesianCoordinates;
  36148. /**
  36149. * Instantiates a new ArcFollowCamera
  36150. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36151. * @param name Define the name of the camera
  36152. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36153. * @param beta Define the rotation angle of the camera around the elevation axis
  36154. * @param radius Define the radius of the camera from its target point
  36155. * @param target Define the target of the camera
  36156. * @param scene Define the scene the camera belongs to
  36157. */
  36158. constructor(name: string,
  36159. /** The longitudinal angle of the camera */
  36160. alpha: number,
  36161. /** The latitudinal angle of the camera */
  36162. beta: number,
  36163. /** The radius of the camera from its target */
  36164. radius: number,
  36165. /** Define the camera target (the messh it should follow) */
  36166. target: Nullable<AbstractMesh>, scene: Scene);
  36167. private _follow;
  36168. /** @hidden */
  36169. _checkInputs(): void;
  36170. /**
  36171. * Returns the class name of the object.
  36172. * It is mostly used internally for serialization purposes.
  36173. */
  36174. getClassName(): string;
  36175. }
  36176. }
  36177. declare module BABYLON {
  36178. /**
  36179. * 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,
  36180. * which still works and will still be found in many Playgrounds.
  36181. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36182. */
  36183. export class UniversalCamera extends TouchCamera {
  36184. /**
  36185. * Defines the gamepad rotation sensiblity.
  36186. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36187. */
  36188. gamepadAngularSensibility: number;
  36189. /**
  36190. * Defines the gamepad move sensiblity.
  36191. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36192. */
  36193. gamepadMoveSensibility: number;
  36194. /**
  36195. * 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,
  36196. * which still works and will still be found in many Playgrounds.
  36197. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36198. * @param name Define the name of the camera in the scene
  36199. * @param position Define the start position of the camera in the scene
  36200. * @param scene Define the scene the camera belongs to
  36201. */
  36202. constructor(name: string, position: Vector3, scene: Scene);
  36203. /**
  36204. * Gets the current object class name.
  36205. * @return the class name
  36206. */
  36207. getClassName(): string;
  36208. }
  36209. }
  36210. declare module BABYLON {
  36211. /**
  36212. * This represents a FPS type of camera. This is only here for back compat purpose.
  36213. * Please use the UniversalCamera instead as both are identical.
  36214. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36215. */
  36216. export class GamepadCamera extends UniversalCamera {
  36217. /**
  36218. * Instantiates a new Gamepad Camera
  36219. * This represents a FPS type of camera. This is only here for back compat purpose.
  36220. * Please use the UniversalCamera instead as both are identical.
  36221. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36222. * @param name Define the name of the camera in the scene
  36223. * @param position Define the start position of the camera in the scene
  36224. * @param scene Define the scene the camera belongs to
  36225. */
  36226. constructor(name: string, position: Vector3, scene: Scene);
  36227. /**
  36228. * Gets the current object class name.
  36229. * @return the class name
  36230. */
  36231. getClassName(): string;
  36232. }
  36233. }
  36234. declare module BABYLON {
  36235. /** @hidden */
  36236. export var passPixelShader: {
  36237. name: string;
  36238. shader: string;
  36239. };
  36240. }
  36241. declare module BABYLON {
  36242. /** @hidden */
  36243. export var passCubePixelShader: {
  36244. name: string;
  36245. shader: string;
  36246. };
  36247. }
  36248. declare module BABYLON {
  36249. /**
  36250. * PassPostProcess which produces an output the same as it's input
  36251. */
  36252. export class PassPostProcess extends PostProcess {
  36253. /**
  36254. * Creates the PassPostProcess
  36255. * @param name The name of the effect.
  36256. * @param options The required width/height ratio to downsize to before computing the render pass.
  36257. * @param camera The camera to apply the render pass to.
  36258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36259. * @param engine The engine which the post process will be applied. (default: current engine)
  36260. * @param reusable If the post process can be reused on the same frame. (default: false)
  36261. * @param textureType The type of texture to be used when performing the post processing.
  36262. * @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)
  36263. */
  36264. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36265. }
  36266. /**
  36267. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36268. */
  36269. export class PassCubePostProcess extends PostProcess {
  36270. private _face;
  36271. /**
  36272. * Gets or sets the cube face to display.
  36273. * * 0 is +X
  36274. * * 1 is -X
  36275. * * 2 is +Y
  36276. * * 3 is -Y
  36277. * * 4 is +Z
  36278. * * 5 is -Z
  36279. */
  36280. face: number;
  36281. /**
  36282. * Creates the PassCubePostProcess
  36283. * @param name The name of the effect.
  36284. * @param options The required width/height ratio to downsize to before computing the render pass.
  36285. * @param camera The camera to apply the render pass to.
  36286. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36287. * @param engine The engine which the post process will be applied. (default: current engine)
  36288. * @param reusable If the post process can be reused on the same frame. (default: false)
  36289. * @param textureType The type of texture to be used when performing the post processing.
  36290. * @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)
  36291. */
  36292. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36293. }
  36294. }
  36295. declare module BABYLON {
  36296. /** @hidden */
  36297. export var anaglyphPixelShader: {
  36298. name: string;
  36299. shader: string;
  36300. };
  36301. }
  36302. declare module BABYLON {
  36303. /**
  36304. * Postprocess used to generate anaglyphic rendering
  36305. */
  36306. export class AnaglyphPostProcess extends PostProcess {
  36307. private _passedProcess;
  36308. /**
  36309. * Creates a new AnaglyphPostProcess
  36310. * @param name defines postprocess name
  36311. * @param options defines creation options or target ratio scale
  36312. * @param rigCameras defines cameras using this postprocess
  36313. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  36314. * @param engine defines hosting engine
  36315. * @param reusable defines if the postprocess will be reused multiple times per frame
  36316. */
  36317. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  36318. }
  36319. }
  36320. declare module BABYLON {
  36321. /**
  36322. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  36323. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36324. */
  36325. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  36326. /**
  36327. * Creates a new AnaglyphArcRotateCamera
  36328. * @param name defines camera name
  36329. * @param alpha defines alpha angle (in radians)
  36330. * @param beta defines beta angle (in radians)
  36331. * @param radius defines radius
  36332. * @param target defines camera target
  36333. * @param interaxialDistance defines distance between each color axis
  36334. * @param scene defines the hosting scene
  36335. */
  36336. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  36337. /**
  36338. * Gets camera class name
  36339. * @returns AnaglyphArcRotateCamera
  36340. */
  36341. getClassName(): string;
  36342. }
  36343. }
  36344. declare module BABYLON {
  36345. /**
  36346. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  36347. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36348. */
  36349. export class AnaglyphFreeCamera extends FreeCamera {
  36350. /**
  36351. * Creates a new AnaglyphFreeCamera
  36352. * @param name defines camera name
  36353. * @param position defines initial position
  36354. * @param interaxialDistance defines distance between each color axis
  36355. * @param scene defines the hosting scene
  36356. */
  36357. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36358. /**
  36359. * Gets camera class name
  36360. * @returns AnaglyphFreeCamera
  36361. */
  36362. getClassName(): string;
  36363. }
  36364. }
  36365. declare module BABYLON {
  36366. /**
  36367. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  36368. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36369. */
  36370. export class AnaglyphGamepadCamera extends GamepadCamera {
  36371. /**
  36372. * Creates a new AnaglyphGamepadCamera
  36373. * @param name defines camera name
  36374. * @param position defines initial position
  36375. * @param interaxialDistance defines distance between each color axis
  36376. * @param scene defines the hosting scene
  36377. */
  36378. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36379. /**
  36380. * Gets camera class name
  36381. * @returns AnaglyphGamepadCamera
  36382. */
  36383. getClassName(): string;
  36384. }
  36385. }
  36386. declare module BABYLON {
  36387. /**
  36388. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  36389. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36390. */
  36391. export class AnaglyphUniversalCamera extends UniversalCamera {
  36392. /**
  36393. * Creates a new AnaglyphUniversalCamera
  36394. * @param name defines camera name
  36395. * @param position defines initial position
  36396. * @param interaxialDistance defines distance between each color axis
  36397. * @param scene defines the hosting scene
  36398. */
  36399. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36400. /**
  36401. * Gets camera class name
  36402. * @returns AnaglyphUniversalCamera
  36403. */
  36404. getClassName(): string;
  36405. }
  36406. }
  36407. declare module BABYLON {
  36408. /** @hidden */
  36409. export var stereoscopicInterlacePixelShader: {
  36410. name: string;
  36411. shader: string;
  36412. };
  36413. }
  36414. declare module BABYLON {
  36415. /**
  36416. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36417. */
  36418. export class StereoscopicInterlacePostProcess extends PostProcess {
  36419. private _stepSize;
  36420. private _passedProcess;
  36421. /**
  36422. * Initializes a StereoscopicInterlacePostProcess
  36423. * @param name The name of the effect.
  36424. * @param rigCameras The rig cameras to be appled to the post process
  36425. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36427. * @param engine The engine which the post process will be applied. (default: current engine)
  36428. * @param reusable If the post process can be reused on the same frame. (default: false)
  36429. */
  36430. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36431. }
  36432. }
  36433. declare module BABYLON {
  36434. /**
  36435. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  36436. * @see http://doc.babylonjs.com/features/cameras
  36437. */
  36438. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  36439. /**
  36440. * Creates a new StereoscopicArcRotateCamera
  36441. * @param name defines camera name
  36442. * @param alpha defines alpha angle (in radians)
  36443. * @param beta defines beta angle (in radians)
  36444. * @param radius defines radius
  36445. * @param target defines camera target
  36446. * @param interaxialDistance defines distance between each color axis
  36447. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36448. * @param scene defines the hosting scene
  36449. */
  36450. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36451. /**
  36452. * Gets camera class name
  36453. * @returns StereoscopicArcRotateCamera
  36454. */
  36455. getClassName(): string;
  36456. }
  36457. }
  36458. declare module BABYLON {
  36459. /**
  36460. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  36461. * @see http://doc.babylonjs.com/features/cameras
  36462. */
  36463. export class StereoscopicFreeCamera extends FreeCamera {
  36464. /**
  36465. * Creates a new StereoscopicFreeCamera
  36466. * @param name defines camera name
  36467. * @param position defines initial position
  36468. * @param interaxialDistance defines distance between each color axis
  36469. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36470. * @param scene defines the hosting scene
  36471. */
  36472. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36473. /**
  36474. * Gets camera class name
  36475. * @returns StereoscopicFreeCamera
  36476. */
  36477. getClassName(): string;
  36478. }
  36479. }
  36480. declare module BABYLON {
  36481. /**
  36482. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  36483. * @see http://doc.babylonjs.com/features/cameras
  36484. */
  36485. export class StereoscopicGamepadCamera extends GamepadCamera {
  36486. /**
  36487. * Creates a new StereoscopicGamepadCamera
  36488. * @param name defines camera name
  36489. * @param position defines initial position
  36490. * @param interaxialDistance defines distance between each color axis
  36491. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36492. * @param scene defines the hosting scene
  36493. */
  36494. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36495. /**
  36496. * Gets camera class name
  36497. * @returns StereoscopicGamepadCamera
  36498. */
  36499. getClassName(): string;
  36500. }
  36501. }
  36502. declare module BABYLON {
  36503. /**
  36504. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  36505. * @see http://doc.babylonjs.com/features/cameras
  36506. */
  36507. export class StereoscopicUniversalCamera extends UniversalCamera {
  36508. /**
  36509. * Creates a new StereoscopicUniversalCamera
  36510. * @param name defines camera name
  36511. * @param position defines initial position
  36512. * @param interaxialDistance defines distance between each color axis
  36513. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36514. * @param scene defines the hosting scene
  36515. */
  36516. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36517. /**
  36518. * Gets camera class name
  36519. * @returns StereoscopicUniversalCamera
  36520. */
  36521. getClassName(): string;
  36522. }
  36523. }
  36524. declare module BABYLON {
  36525. /**
  36526. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  36527. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36528. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36529. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36530. */
  36531. export class VirtualJoysticksCamera extends FreeCamera {
  36532. /**
  36533. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  36534. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36535. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36536. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36537. * @param name Define the name of the camera in the scene
  36538. * @param position Define the start position of the camera in the scene
  36539. * @param scene Define the scene the camera belongs to
  36540. */
  36541. constructor(name: string, position: Vector3, scene: Scene);
  36542. /**
  36543. * Gets the current object class name.
  36544. * @return the class name
  36545. */
  36546. getClassName(): string;
  36547. }
  36548. }
  36549. declare module BABYLON {
  36550. /**
  36551. * This represents all the required metrics to create a VR camera.
  36552. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  36553. */
  36554. export class VRCameraMetrics {
  36555. /**
  36556. * Define the horizontal resolution off the screen.
  36557. */
  36558. hResolution: number;
  36559. /**
  36560. * Define the vertical resolution off the screen.
  36561. */
  36562. vResolution: number;
  36563. /**
  36564. * Define the horizontal screen size.
  36565. */
  36566. hScreenSize: number;
  36567. /**
  36568. * Define the vertical screen size.
  36569. */
  36570. vScreenSize: number;
  36571. /**
  36572. * Define the vertical screen center position.
  36573. */
  36574. vScreenCenter: number;
  36575. /**
  36576. * Define the distance of the eyes to the screen.
  36577. */
  36578. eyeToScreenDistance: number;
  36579. /**
  36580. * Define the distance between both lenses
  36581. */
  36582. lensSeparationDistance: number;
  36583. /**
  36584. * Define the distance between both viewer's eyes.
  36585. */
  36586. interpupillaryDistance: number;
  36587. /**
  36588. * Define the distortion factor of the VR postprocess.
  36589. * Please, touch with care.
  36590. */
  36591. distortionK: number[];
  36592. /**
  36593. * Define the chromatic aberration correction factors for the VR post process.
  36594. */
  36595. chromaAbCorrection: number[];
  36596. /**
  36597. * Define the scale factor of the post process.
  36598. * The smaller the better but the slower.
  36599. */
  36600. postProcessScaleFactor: number;
  36601. /**
  36602. * Define an offset for the lens center.
  36603. */
  36604. lensCenterOffset: number;
  36605. /**
  36606. * Define if the current vr camera should compensate the distortion of the lense or not.
  36607. */
  36608. compensateDistortion: boolean;
  36609. /**
  36610. * Gets the rendering aspect ratio based on the provided resolutions.
  36611. */
  36612. readonly aspectRatio: number;
  36613. /**
  36614. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  36615. */
  36616. readonly aspectRatioFov: number;
  36617. /**
  36618. * @hidden
  36619. */
  36620. readonly leftHMatrix: Matrix;
  36621. /**
  36622. * @hidden
  36623. */
  36624. readonly rightHMatrix: Matrix;
  36625. /**
  36626. * @hidden
  36627. */
  36628. readonly leftPreViewMatrix: Matrix;
  36629. /**
  36630. * @hidden
  36631. */
  36632. readonly rightPreViewMatrix: Matrix;
  36633. /**
  36634. * Get the default VRMetrics based on the most generic setup.
  36635. * @returns the default vr metrics
  36636. */
  36637. static GetDefault(): VRCameraMetrics;
  36638. }
  36639. }
  36640. declare module BABYLON {
  36641. /** @hidden */
  36642. export var vrDistortionCorrectionPixelShader: {
  36643. name: string;
  36644. shader: string;
  36645. };
  36646. }
  36647. declare module BABYLON {
  36648. /**
  36649. * VRDistortionCorrectionPostProcess used for mobile VR
  36650. */
  36651. export class VRDistortionCorrectionPostProcess extends PostProcess {
  36652. private _isRightEye;
  36653. private _distortionFactors;
  36654. private _postProcessScaleFactor;
  36655. private _lensCenterOffset;
  36656. private _scaleIn;
  36657. private _scaleFactor;
  36658. private _lensCenter;
  36659. /**
  36660. * Initializes the VRDistortionCorrectionPostProcess
  36661. * @param name The name of the effect.
  36662. * @param camera The camera to apply the render pass to.
  36663. * @param isRightEye If this is for the right eye distortion
  36664. * @param vrMetrics All the required metrics for the VR camera
  36665. */
  36666. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  36667. }
  36668. }
  36669. declare module BABYLON {
  36670. /**
  36671. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  36672. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36673. */
  36674. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  36675. /**
  36676. * Creates a new VRDeviceOrientationArcRotateCamera
  36677. * @param name defines camera name
  36678. * @param alpha defines the camera rotation along the logitudinal axis
  36679. * @param beta defines the camera rotation along the latitudinal axis
  36680. * @param radius defines the camera distance from its target
  36681. * @param target defines the camera target
  36682. * @param scene defines the scene the camera belongs to
  36683. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36684. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36685. */
  36686. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36687. /**
  36688. * Gets camera class name
  36689. * @returns VRDeviceOrientationArcRotateCamera
  36690. */
  36691. getClassName(): string;
  36692. }
  36693. }
  36694. declare module BABYLON {
  36695. /**
  36696. * Camera used to simulate VR rendering (based on FreeCamera)
  36697. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36698. */
  36699. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  36700. /**
  36701. * Creates a new VRDeviceOrientationFreeCamera
  36702. * @param name defines camera name
  36703. * @param position defines the start position of the camera
  36704. * @param scene defines the scene the camera belongs to
  36705. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36706. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36707. */
  36708. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36709. /**
  36710. * Gets camera class name
  36711. * @returns VRDeviceOrientationFreeCamera
  36712. */
  36713. getClassName(): string;
  36714. }
  36715. }
  36716. declare module BABYLON {
  36717. /**
  36718. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  36719. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36720. */
  36721. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  36722. /**
  36723. * Creates a new VRDeviceOrientationGamepadCamera
  36724. * @param name defines camera name
  36725. * @param position defines the start position of the camera
  36726. * @param scene defines the scene the camera belongs to
  36727. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36728. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36729. */
  36730. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36731. /**
  36732. * Gets camera class name
  36733. * @returns VRDeviceOrientationGamepadCamera
  36734. */
  36735. getClassName(): string;
  36736. }
  36737. }
  36738. declare module BABYLON {
  36739. /**
  36740. * Defines supported buttons for XBox360 compatible gamepads
  36741. */
  36742. export enum Xbox360Button {
  36743. /** A */
  36744. A = 0,
  36745. /** B */
  36746. B = 1,
  36747. /** X */
  36748. X = 2,
  36749. /** Y */
  36750. Y = 3,
  36751. /** Start */
  36752. Start = 4,
  36753. /** Back */
  36754. Back = 5,
  36755. /** Left button */
  36756. LB = 6,
  36757. /** Right button */
  36758. RB = 7,
  36759. /** Left stick */
  36760. LeftStick = 8,
  36761. /** Right stick */
  36762. RightStick = 9
  36763. }
  36764. /** Defines values for XBox360 DPad */
  36765. export enum Xbox360Dpad {
  36766. /** Up */
  36767. Up = 0,
  36768. /** Down */
  36769. Down = 1,
  36770. /** Left */
  36771. Left = 2,
  36772. /** Right */
  36773. Right = 3
  36774. }
  36775. /**
  36776. * Defines a XBox360 gamepad
  36777. */
  36778. export class Xbox360Pad extends Gamepad {
  36779. private _leftTrigger;
  36780. private _rightTrigger;
  36781. private _onlefttriggerchanged;
  36782. private _onrighttriggerchanged;
  36783. private _onbuttondown;
  36784. private _onbuttonup;
  36785. private _ondpaddown;
  36786. private _ondpadup;
  36787. /** Observable raised when a button is pressed */
  36788. onButtonDownObservable: Observable<Xbox360Button>;
  36789. /** Observable raised when a button is released */
  36790. onButtonUpObservable: Observable<Xbox360Button>;
  36791. /** Observable raised when a pad is pressed */
  36792. onPadDownObservable: Observable<Xbox360Dpad>;
  36793. /** Observable raised when a pad is released */
  36794. onPadUpObservable: Observable<Xbox360Dpad>;
  36795. private _buttonA;
  36796. private _buttonB;
  36797. private _buttonX;
  36798. private _buttonY;
  36799. private _buttonBack;
  36800. private _buttonStart;
  36801. private _buttonLB;
  36802. private _buttonRB;
  36803. private _buttonLeftStick;
  36804. private _buttonRightStick;
  36805. private _dPadUp;
  36806. private _dPadDown;
  36807. private _dPadLeft;
  36808. private _dPadRight;
  36809. private _isXboxOnePad;
  36810. /**
  36811. * Creates a new XBox360 gamepad object
  36812. * @param id defines the id of this gamepad
  36813. * @param index defines its index
  36814. * @param gamepad defines the internal HTML gamepad object
  36815. * @param xboxOne defines if it is a XBox One gamepad
  36816. */
  36817. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  36818. /**
  36819. * Defines the callback to call when left trigger is pressed
  36820. * @param callback defines the callback to use
  36821. */
  36822. onlefttriggerchanged(callback: (value: number) => void): void;
  36823. /**
  36824. * Defines the callback to call when right trigger is pressed
  36825. * @param callback defines the callback to use
  36826. */
  36827. onrighttriggerchanged(callback: (value: number) => void): void;
  36828. /**
  36829. * Gets the left trigger value
  36830. */
  36831. /**
  36832. * Sets the left trigger value
  36833. */
  36834. leftTrigger: number;
  36835. /**
  36836. * Gets the right trigger value
  36837. */
  36838. /**
  36839. * Sets the right trigger value
  36840. */
  36841. rightTrigger: number;
  36842. /**
  36843. * Defines the callback to call when a button is pressed
  36844. * @param callback defines the callback to use
  36845. */
  36846. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  36847. /**
  36848. * Defines the callback to call when a button is released
  36849. * @param callback defines the callback to use
  36850. */
  36851. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  36852. /**
  36853. * Defines the callback to call when a pad is pressed
  36854. * @param callback defines the callback to use
  36855. */
  36856. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  36857. /**
  36858. * Defines the callback to call when a pad is released
  36859. * @param callback defines the callback to use
  36860. */
  36861. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  36862. private _setButtonValue;
  36863. private _setDPadValue;
  36864. /**
  36865. * Gets the value of the `A` button
  36866. */
  36867. /**
  36868. * Sets the value of the `A` button
  36869. */
  36870. buttonA: number;
  36871. /**
  36872. * Gets the value of the `B` button
  36873. */
  36874. /**
  36875. * Sets the value of the `B` button
  36876. */
  36877. buttonB: number;
  36878. /**
  36879. * Gets the value of the `X` button
  36880. */
  36881. /**
  36882. * Sets the value of the `X` button
  36883. */
  36884. buttonX: number;
  36885. /**
  36886. * Gets the value of the `Y` button
  36887. */
  36888. /**
  36889. * Sets the value of the `Y` button
  36890. */
  36891. buttonY: number;
  36892. /**
  36893. * Gets the value of the `Start` button
  36894. */
  36895. /**
  36896. * Sets the value of the `Start` button
  36897. */
  36898. buttonStart: number;
  36899. /**
  36900. * Gets the value of the `Back` button
  36901. */
  36902. /**
  36903. * Sets the value of the `Back` button
  36904. */
  36905. buttonBack: number;
  36906. /**
  36907. * Gets the value of the `Left` button
  36908. */
  36909. /**
  36910. * Sets the value of the `Left` button
  36911. */
  36912. buttonLB: number;
  36913. /**
  36914. * Gets the value of the `Right` button
  36915. */
  36916. /**
  36917. * Sets the value of the `Right` button
  36918. */
  36919. buttonRB: number;
  36920. /**
  36921. * Gets the value of the Left joystick
  36922. */
  36923. /**
  36924. * Sets the value of the Left joystick
  36925. */
  36926. buttonLeftStick: number;
  36927. /**
  36928. * Gets the value of the Right joystick
  36929. */
  36930. /**
  36931. * Sets the value of the Right joystick
  36932. */
  36933. buttonRightStick: number;
  36934. /**
  36935. * Gets the value of D-pad up
  36936. */
  36937. /**
  36938. * Sets the value of D-pad up
  36939. */
  36940. dPadUp: number;
  36941. /**
  36942. * Gets the value of D-pad down
  36943. */
  36944. /**
  36945. * Sets the value of D-pad down
  36946. */
  36947. dPadDown: number;
  36948. /**
  36949. * Gets the value of D-pad left
  36950. */
  36951. /**
  36952. * Sets the value of D-pad left
  36953. */
  36954. dPadLeft: number;
  36955. /**
  36956. * Gets the value of D-pad right
  36957. */
  36958. /**
  36959. * Sets the value of D-pad right
  36960. */
  36961. dPadRight: number;
  36962. /**
  36963. * Force the gamepad to synchronize with device values
  36964. */
  36965. update(): void;
  36966. /**
  36967. * Disposes the gamepad
  36968. */
  36969. dispose(): void;
  36970. }
  36971. }
  36972. declare module BABYLON {
  36973. /**
  36974. * Base class of materials working in push mode in babylon JS
  36975. * @hidden
  36976. */
  36977. export class PushMaterial extends Material {
  36978. protected _activeEffect: Effect;
  36979. protected _normalMatrix: Matrix;
  36980. /**
  36981. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  36982. * This means that the material can keep using a previous shader while a new one is being compiled.
  36983. * This is mostly used when shader parallel compilation is supported (true by default)
  36984. */
  36985. allowShaderHotSwapping: boolean;
  36986. constructor(name: string, scene: Scene);
  36987. getEffect(): Effect;
  36988. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  36989. /**
  36990. * Binds the given world matrix to the active effect
  36991. *
  36992. * @param world the matrix to bind
  36993. */
  36994. bindOnlyWorldMatrix(world: Matrix): void;
  36995. /**
  36996. * Binds the given normal matrix to the active effect
  36997. *
  36998. * @param normalMatrix the matrix to bind
  36999. */
  37000. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37001. bind(world: Matrix, mesh?: Mesh): void;
  37002. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37003. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37004. }
  37005. }
  37006. declare module BABYLON {
  37007. /**
  37008. * This groups all the flags used to control the materials channel.
  37009. */
  37010. export class MaterialFlags {
  37011. private static _DiffuseTextureEnabled;
  37012. /**
  37013. * Are diffuse textures enabled in the application.
  37014. */
  37015. static DiffuseTextureEnabled: boolean;
  37016. private static _AmbientTextureEnabled;
  37017. /**
  37018. * Are ambient textures enabled in the application.
  37019. */
  37020. static AmbientTextureEnabled: boolean;
  37021. private static _OpacityTextureEnabled;
  37022. /**
  37023. * Are opacity textures enabled in the application.
  37024. */
  37025. static OpacityTextureEnabled: boolean;
  37026. private static _ReflectionTextureEnabled;
  37027. /**
  37028. * Are reflection textures enabled in the application.
  37029. */
  37030. static ReflectionTextureEnabled: boolean;
  37031. private static _EmissiveTextureEnabled;
  37032. /**
  37033. * Are emissive textures enabled in the application.
  37034. */
  37035. static EmissiveTextureEnabled: boolean;
  37036. private static _SpecularTextureEnabled;
  37037. /**
  37038. * Are specular textures enabled in the application.
  37039. */
  37040. static SpecularTextureEnabled: boolean;
  37041. private static _BumpTextureEnabled;
  37042. /**
  37043. * Are bump textures enabled in the application.
  37044. */
  37045. static BumpTextureEnabled: boolean;
  37046. private static _LightmapTextureEnabled;
  37047. /**
  37048. * Are lightmap textures enabled in the application.
  37049. */
  37050. static LightmapTextureEnabled: boolean;
  37051. private static _RefractionTextureEnabled;
  37052. /**
  37053. * Are refraction textures enabled in the application.
  37054. */
  37055. static RefractionTextureEnabled: boolean;
  37056. private static _ColorGradingTextureEnabled;
  37057. /**
  37058. * Are color grading textures enabled in the application.
  37059. */
  37060. static ColorGradingTextureEnabled: boolean;
  37061. private static _FresnelEnabled;
  37062. /**
  37063. * Are fresnels enabled in the application.
  37064. */
  37065. static FresnelEnabled: boolean;
  37066. }
  37067. }
  37068. declare module BABYLON {
  37069. /** @hidden */
  37070. export var defaultFragmentDeclaration: {
  37071. name: string;
  37072. shader: string;
  37073. };
  37074. }
  37075. declare module BABYLON {
  37076. /** @hidden */
  37077. export var defaultUboDeclaration: {
  37078. name: string;
  37079. shader: string;
  37080. };
  37081. }
  37082. declare module BABYLON {
  37083. /** @hidden */
  37084. export var lightFragmentDeclaration: {
  37085. name: string;
  37086. shader: string;
  37087. };
  37088. }
  37089. declare module BABYLON {
  37090. /** @hidden */
  37091. export var lightUboDeclaration: {
  37092. name: string;
  37093. shader: string;
  37094. };
  37095. }
  37096. declare module BABYLON {
  37097. /** @hidden */
  37098. export var lightsFragmentFunctions: {
  37099. name: string;
  37100. shader: string;
  37101. };
  37102. }
  37103. declare module BABYLON {
  37104. /** @hidden */
  37105. export var shadowsFragmentFunctions: {
  37106. name: string;
  37107. shader: string;
  37108. };
  37109. }
  37110. declare module BABYLON {
  37111. /** @hidden */
  37112. export var fresnelFunction: {
  37113. name: string;
  37114. shader: string;
  37115. };
  37116. }
  37117. declare module BABYLON {
  37118. /** @hidden */
  37119. export var reflectionFunction: {
  37120. name: string;
  37121. shader: string;
  37122. };
  37123. }
  37124. declare module BABYLON {
  37125. /** @hidden */
  37126. export var bumpFragmentFunctions: {
  37127. name: string;
  37128. shader: string;
  37129. };
  37130. }
  37131. declare module BABYLON {
  37132. /** @hidden */
  37133. export var logDepthDeclaration: {
  37134. name: string;
  37135. shader: string;
  37136. };
  37137. }
  37138. declare module BABYLON {
  37139. /** @hidden */
  37140. export var bumpFragment: {
  37141. name: string;
  37142. shader: string;
  37143. };
  37144. }
  37145. declare module BABYLON {
  37146. /** @hidden */
  37147. export var depthPrePass: {
  37148. name: string;
  37149. shader: string;
  37150. };
  37151. }
  37152. declare module BABYLON {
  37153. /** @hidden */
  37154. export var lightFragment: {
  37155. name: string;
  37156. shader: string;
  37157. };
  37158. }
  37159. declare module BABYLON {
  37160. /** @hidden */
  37161. export var logDepthFragment: {
  37162. name: string;
  37163. shader: string;
  37164. };
  37165. }
  37166. declare module BABYLON {
  37167. /** @hidden */
  37168. export var defaultPixelShader: {
  37169. name: string;
  37170. shader: string;
  37171. };
  37172. }
  37173. declare module BABYLON {
  37174. /** @hidden */
  37175. export var defaultVertexDeclaration: {
  37176. name: string;
  37177. shader: string;
  37178. };
  37179. }
  37180. declare module BABYLON {
  37181. /** @hidden */
  37182. export var bumpVertexDeclaration: {
  37183. name: string;
  37184. shader: string;
  37185. };
  37186. }
  37187. declare module BABYLON {
  37188. /** @hidden */
  37189. export var bumpVertex: {
  37190. name: string;
  37191. shader: string;
  37192. };
  37193. }
  37194. declare module BABYLON {
  37195. /** @hidden */
  37196. export var fogVertex: {
  37197. name: string;
  37198. shader: string;
  37199. };
  37200. }
  37201. declare module BABYLON {
  37202. /** @hidden */
  37203. export var shadowsVertex: {
  37204. name: string;
  37205. shader: string;
  37206. };
  37207. }
  37208. declare module BABYLON {
  37209. /** @hidden */
  37210. export var pointCloudVertex: {
  37211. name: string;
  37212. shader: string;
  37213. };
  37214. }
  37215. declare module BABYLON {
  37216. /** @hidden */
  37217. export var logDepthVertex: {
  37218. name: string;
  37219. shader: string;
  37220. };
  37221. }
  37222. declare module BABYLON {
  37223. /** @hidden */
  37224. export var defaultVertexShader: {
  37225. name: string;
  37226. shader: string;
  37227. };
  37228. }
  37229. declare module BABYLON {
  37230. /** @hidden */
  37231. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  37232. MAINUV1: boolean;
  37233. MAINUV2: boolean;
  37234. DIFFUSE: boolean;
  37235. DIFFUSEDIRECTUV: number;
  37236. AMBIENT: boolean;
  37237. AMBIENTDIRECTUV: number;
  37238. OPACITY: boolean;
  37239. OPACITYDIRECTUV: number;
  37240. OPACITYRGB: boolean;
  37241. REFLECTION: boolean;
  37242. EMISSIVE: boolean;
  37243. EMISSIVEDIRECTUV: number;
  37244. SPECULAR: boolean;
  37245. SPECULARDIRECTUV: number;
  37246. BUMP: boolean;
  37247. BUMPDIRECTUV: number;
  37248. PARALLAX: boolean;
  37249. PARALLAXOCCLUSION: boolean;
  37250. SPECULAROVERALPHA: boolean;
  37251. CLIPPLANE: boolean;
  37252. CLIPPLANE2: boolean;
  37253. CLIPPLANE3: boolean;
  37254. CLIPPLANE4: boolean;
  37255. ALPHATEST: boolean;
  37256. DEPTHPREPASS: boolean;
  37257. ALPHAFROMDIFFUSE: boolean;
  37258. POINTSIZE: boolean;
  37259. FOG: boolean;
  37260. SPECULARTERM: boolean;
  37261. DIFFUSEFRESNEL: boolean;
  37262. OPACITYFRESNEL: boolean;
  37263. REFLECTIONFRESNEL: boolean;
  37264. REFRACTIONFRESNEL: boolean;
  37265. EMISSIVEFRESNEL: boolean;
  37266. FRESNEL: boolean;
  37267. NORMAL: boolean;
  37268. UV1: boolean;
  37269. UV2: boolean;
  37270. VERTEXCOLOR: boolean;
  37271. VERTEXALPHA: boolean;
  37272. NUM_BONE_INFLUENCERS: number;
  37273. BonesPerMesh: number;
  37274. BONETEXTURE: boolean;
  37275. INSTANCES: boolean;
  37276. GLOSSINESS: boolean;
  37277. ROUGHNESS: boolean;
  37278. EMISSIVEASILLUMINATION: boolean;
  37279. LINKEMISSIVEWITHDIFFUSE: boolean;
  37280. REFLECTIONFRESNELFROMSPECULAR: boolean;
  37281. LIGHTMAP: boolean;
  37282. LIGHTMAPDIRECTUV: number;
  37283. OBJECTSPACE_NORMALMAP: boolean;
  37284. USELIGHTMAPASSHADOWMAP: boolean;
  37285. REFLECTIONMAP_3D: boolean;
  37286. REFLECTIONMAP_SPHERICAL: boolean;
  37287. REFLECTIONMAP_PLANAR: boolean;
  37288. REFLECTIONMAP_CUBIC: boolean;
  37289. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  37290. REFLECTIONMAP_PROJECTION: boolean;
  37291. REFLECTIONMAP_SKYBOX: boolean;
  37292. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  37293. REFLECTIONMAP_EXPLICIT: boolean;
  37294. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  37295. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  37296. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  37297. INVERTCUBICMAP: boolean;
  37298. LOGARITHMICDEPTH: boolean;
  37299. REFRACTION: boolean;
  37300. REFRACTIONMAP_3D: boolean;
  37301. REFLECTIONOVERALPHA: boolean;
  37302. TWOSIDEDLIGHTING: boolean;
  37303. SHADOWFLOAT: boolean;
  37304. MORPHTARGETS: boolean;
  37305. MORPHTARGETS_NORMAL: boolean;
  37306. MORPHTARGETS_TANGENT: boolean;
  37307. NUM_MORPH_INFLUENCERS: number;
  37308. NONUNIFORMSCALING: boolean;
  37309. PREMULTIPLYALPHA: boolean;
  37310. IMAGEPROCESSING: boolean;
  37311. VIGNETTE: boolean;
  37312. VIGNETTEBLENDMODEMULTIPLY: boolean;
  37313. VIGNETTEBLENDMODEOPAQUE: boolean;
  37314. TONEMAPPING: boolean;
  37315. TONEMAPPING_ACES: boolean;
  37316. CONTRAST: boolean;
  37317. COLORCURVES: boolean;
  37318. COLORGRADING: boolean;
  37319. COLORGRADING3D: boolean;
  37320. SAMPLER3DGREENDEPTH: boolean;
  37321. SAMPLER3DBGRMAP: boolean;
  37322. IMAGEPROCESSINGPOSTPROCESS: boolean;
  37323. /**
  37324. * If the reflection texture on this material is in linear color space
  37325. * @hidden
  37326. */
  37327. IS_REFLECTION_LINEAR: boolean;
  37328. /**
  37329. * If the refraction texture on this material is in linear color space
  37330. * @hidden
  37331. */
  37332. IS_REFRACTION_LINEAR: boolean;
  37333. EXPOSURE: boolean;
  37334. constructor();
  37335. setReflectionMode(modeToEnable: string): void;
  37336. }
  37337. /**
  37338. * This is the default material used in Babylon. It is the best trade off between quality
  37339. * and performances.
  37340. * @see http://doc.babylonjs.com/babylon101/materials
  37341. */
  37342. export class StandardMaterial extends PushMaterial {
  37343. private _diffuseTexture;
  37344. /**
  37345. * The basic texture of the material as viewed under a light.
  37346. */
  37347. diffuseTexture: Nullable<BaseTexture>;
  37348. private _ambientTexture;
  37349. /**
  37350. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  37351. */
  37352. ambientTexture: Nullable<BaseTexture>;
  37353. private _opacityTexture;
  37354. /**
  37355. * Define the transparency of the material from a texture.
  37356. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  37357. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  37358. */
  37359. opacityTexture: Nullable<BaseTexture>;
  37360. private _reflectionTexture;
  37361. /**
  37362. * Define the texture used to display the reflection.
  37363. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37364. */
  37365. reflectionTexture: Nullable<BaseTexture>;
  37366. private _emissiveTexture;
  37367. /**
  37368. * Define texture of the material as if self lit.
  37369. * This will be mixed in the final result even in the absence of light.
  37370. */
  37371. emissiveTexture: Nullable<BaseTexture>;
  37372. private _specularTexture;
  37373. /**
  37374. * Define how the color and intensity of the highlight given by the light in the material.
  37375. */
  37376. specularTexture: Nullable<BaseTexture>;
  37377. private _bumpTexture;
  37378. /**
  37379. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  37380. * 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.
  37381. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  37382. */
  37383. bumpTexture: Nullable<BaseTexture>;
  37384. private _lightmapTexture;
  37385. /**
  37386. * Complex lighting can be computationally expensive to compute at runtime.
  37387. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  37388. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  37389. */
  37390. lightmapTexture: Nullable<BaseTexture>;
  37391. private _refractionTexture;
  37392. /**
  37393. * Define the texture used to display the refraction.
  37394. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37395. */
  37396. refractionTexture: Nullable<BaseTexture>;
  37397. /**
  37398. * The color of the material lit by the environmental background lighting.
  37399. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  37400. */
  37401. ambientColor: Color3;
  37402. /**
  37403. * The basic color of the material as viewed under a light.
  37404. */
  37405. diffuseColor: Color3;
  37406. /**
  37407. * Define how the color and intensity of the highlight given by the light in the material.
  37408. */
  37409. specularColor: Color3;
  37410. /**
  37411. * Define the color of the material as if self lit.
  37412. * This will be mixed in the final result even in the absence of light.
  37413. */
  37414. emissiveColor: Color3;
  37415. /**
  37416. * Defines how sharp are the highlights in the material.
  37417. * The bigger the value the sharper giving a more glossy feeling to the result.
  37418. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  37419. */
  37420. specularPower: number;
  37421. private _useAlphaFromDiffuseTexture;
  37422. /**
  37423. * Does the transparency come from the diffuse texture alpha channel.
  37424. */
  37425. useAlphaFromDiffuseTexture: boolean;
  37426. private _useEmissiveAsIllumination;
  37427. /**
  37428. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  37429. */
  37430. useEmissiveAsIllumination: boolean;
  37431. private _linkEmissiveWithDiffuse;
  37432. /**
  37433. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  37434. * the emissive level when the final color is close to one.
  37435. */
  37436. linkEmissiveWithDiffuse: boolean;
  37437. private _useSpecularOverAlpha;
  37438. /**
  37439. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  37440. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  37441. */
  37442. useSpecularOverAlpha: boolean;
  37443. private _useReflectionOverAlpha;
  37444. /**
  37445. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  37446. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  37447. */
  37448. useReflectionOverAlpha: boolean;
  37449. private _disableLighting;
  37450. /**
  37451. * Does lights from the scene impacts this material.
  37452. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  37453. */
  37454. disableLighting: boolean;
  37455. private _useObjectSpaceNormalMap;
  37456. /**
  37457. * Allows using an object space normal map (instead of tangent space).
  37458. */
  37459. useObjectSpaceNormalMap: boolean;
  37460. private _useParallax;
  37461. /**
  37462. * Is parallax enabled or not.
  37463. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37464. */
  37465. useParallax: boolean;
  37466. private _useParallaxOcclusion;
  37467. /**
  37468. * Is parallax occlusion enabled or not.
  37469. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  37470. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37471. */
  37472. useParallaxOcclusion: boolean;
  37473. /**
  37474. * 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.
  37475. */
  37476. parallaxScaleBias: number;
  37477. private _roughness;
  37478. /**
  37479. * Helps to define how blurry the reflections should appears in the material.
  37480. */
  37481. roughness: number;
  37482. /**
  37483. * In case of refraction, define the value of the indice of refraction.
  37484. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37485. */
  37486. indexOfRefraction: number;
  37487. /**
  37488. * Invert the refraction texture alongside the y axis.
  37489. * It can be useful with procedural textures or probe for instance.
  37490. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37491. */
  37492. invertRefractionY: boolean;
  37493. /**
  37494. * Defines the alpha limits in alpha test mode.
  37495. */
  37496. alphaCutOff: number;
  37497. private _useLightmapAsShadowmap;
  37498. /**
  37499. * In case of light mapping, define whether the map contains light or shadow informations.
  37500. */
  37501. useLightmapAsShadowmap: boolean;
  37502. private _diffuseFresnelParameters;
  37503. /**
  37504. * Define the diffuse fresnel parameters of the material.
  37505. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37506. */
  37507. diffuseFresnelParameters: FresnelParameters;
  37508. private _opacityFresnelParameters;
  37509. /**
  37510. * Define the opacity fresnel parameters of the material.
  37511. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37512. */
  37513. opacityFresnelParameters: FresnelParameters;
  37514. private _reflectionFresnelParameters;
  37515. /**
  37516. * Define the reflection fresnel parameters of the material.
  37517. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37518. */
  37519. reflectionFresnelParameters: FresnelParameters;
  37520. private _refractionFresnelParameters;
  37521. /**
  37522. * Define the refraction fresnel parameters of the material.
  37523. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37524. */
  37525. refractionFresnelParameters: FresnelParameters;
  37526. private _emissiveFresnelParameters;
  37527. /**
  37528. * Define the emissive fresnel parameters of the material.
  37529. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37530. */
  37531. emissiveFresnelParameters: FresnelParameters;
  37532. private _useReflectionFresnelFromSpecular;
  37533. /**
  37534. * If true automatically deducts the fresnels values from the material specularity.
  37535. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37536. */
  37537. useReflectionFresnelFromSpecular: boolean;
  37538. private _useGlossinessFromSpecularMapAlpha;
  37539. /**
  37540. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  37541. */
  37542. useGlossinessFromSpecularMapAlpha: boolean;
  37543. private _maxSimultaneousLights;
  37544. /**
  37545. * Defines the maximum number of lights that can be used in the material
  37546. */
  37547. maxSimultaneousLights: number;
  37548. private _invertNormalMapX;
  37549. /**
  37550. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  37551. */
  37552. invertNormalMapX: boolean;
  37553. private _invertNormalMapY;
  37554. /**
  37555. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  37556. */
  37557. invertNormalMapY: boolean;
  37558. private _twoSidedLighting;
  37559. /**
  37560. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  37561. */
  37562. twoSidedLighting: boolean;
  37563. /**
  37564. * Default configuration related to image processing available in the standard Material.
  37565. */
  37566. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  37567. /**
  37568. * Gets the image processing configuration used either in this material.
  37569. */
  37570. /**
  37571. * Sets the Default image processing configuration used either in the this material.
  37572. *
  37573. * If sets to null, the scene one is in use.
  37574. */
  37575. imageProcessingConfiguration: ImageProcessingConfiguration;
  37576. /**
  37577. * Keep track of the image processing observer to allow dispose and replace.
  37578. */
  37579. private _imageProcessingObserver;
  37580. /**
  37581. * Attaches a new image processing configuration to the Standard Material.
  37582. * @param configuration
  37583. */
  37584. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  37585. /**
  37586. * Gets wether the color curves effect is enabled.
  37587. */
  37588. /**
  37589. * Sets wether the color curves effect is enabled.
  37590. */
  37591. cameraColorCurvesEnabled: boolean;
  37592. /**
  37593. * Gets wether the color grading effect is enabled.
  37594. */
  37595. /**
  37596. * Gets wether the color grading effect is enabled.
  37597. */
  37598. cameraColorGradingEnabled: boolean;
  37599. /**
  37600. * Gets wether tonemapping is enabled or not.
  37601. */
  37602. /**
  37603. * Sets wether tonemapping is enabled or not
  37604. */
  37605. cameraToneMappingEnabled: boolean;
  37606. /**
  37607. * The camera exposure used on this material.
  37608. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37609. * This corresponds to a photographic exposure.
  37610. */
  37611. /**
  37612. * The camera exposure used on this material.
  37613. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37614. * This corresponds to a photographic exposure.
  37615. */
  37616. cameraExposure: number;
  37617. /**
  37618. * Gets The camera contrast used on this material.
  37619. */
  37620. /**
  37621. * Sets The camera contrast used on this material.
  37622. */
  37623. cameraContrast: number;
  37624. /**
  37625. * Gets the Color Grading 2D Lookup Texture.
  37626. */
  37627. /**
  37628. * Sets the Color Grading 2D Lookup Texture.
  37629. */
  37630. cameraColorGradingTexture: Nullable<BaseTexture>;
  37631. /**
  37632. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37633. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37634. * 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;
  37635. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37636. */
  37637. /**
  37638. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37639. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37640. * 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;
  37641. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37642. */
  37643. cameraColorCurves: Nullable<ColorCurves>;
  37644. /**
  37645. * Custom callback helping to override the default shader used in the material.
  37646. */
  37647. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  37648. protected _renderTargets: SmartArray<RenderTargetTexture>;
  37649. protected _worldViewProjectionMatrix: Matrix;
  37650. protected _globalAmbientColor: Color3;
  37651. protected _useLogarithmicDepth: boolean;
  37652. /**
  37653. * Instantiates a new standard material.
  37654. * This is the default material used in Babylon. It is the best trade off between quality
  37655. * and performances.
  37656. * @see http://doc.babylonjs.com/babylon101/materials
  37657. * @param name Define the name of the material in the scene
  37658. * @param scene Define the scene the material belong to
  37659. */
  37660. constructor(name: string, scene: Scene);
  37661. /**
  37662. * Gets a boolean indicating that current material needs to register RTT
  37663. */
  37664. readonly hasRenderTargetTextures: boolean;
  37665. /**
  37666. * Gets the current class name of the material e.g. "StandardMaterial"
  37667. * Mainly use in serialization.
  37668. * @returns the class name
  37669. */
  37670. getClassName(): string;
  37671. /**
  37672. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  37673. * You can try switching to logarithmic depth.
  37674. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  37675. */
  37676. useLogarithmicDepth: boolean;
  37677. /**
  37678. * Specifies if the material will require alpha blending
  37679. * @returns a boolean specifying if alpha blending is needed
  37680. */
  37681. needAlphaBlending(): boolean;
  37682. /**
  37683. * Specifies if this material should be rendered in alpha test mode
  37684. * @returns a boolean specifying if an alpha test is needed.
  37685. */
  37686. needAlphaTesting(): boolean;
  37687. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  37688. /**
  37689. * Get the texture used for alpha test purpose.
  37690. * @returns the diffuse texture in case of the standard material.
  37691. */
  37692. getAlphaTestTexture(): Nullable<BaseTexture>;
  37693. /**
  37694. * Get if the submesh is ready to be used and all its information available.
  37695. * Child classes can use it to update shaders
  37696. * @param mesh defines the mesh to check
  37697. * @param subMesh defines which submesh to check
  37698. * @param useInstances specifies that instances should be used
  37699. * @returns a boolean indicating that the submesh is ready or not
  37700. */
  37701. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  37702. /**
  37703. * Builds the material UBO layouts.
  37704. * Used internally during the effect preparation.
  37705. */
  37706. buildUniformLayout(): void;
  37707. /**
  37708. * Unbinds the material from the mesh
  37709. */
  37710. unbind(): void;
  37711. /**
  37712. * Binds the submesh to this material by preparing the effect and shader to draw
  37713. * @param world defines the world transformation matrix
  37714. * @param mesh defines the mesh containing the submesh
  37715. * @param subMesh defines the submesh to bind the material to
  37716. */
  37717. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  37718. /**
  37719. * Get the list of animatables in the material.
  37720. * @returns the list of animatables object used in the material
  37721. */
  37722. getAnimatables(): IAnimatable[];
  37723. /**
  37724. * Gets the active textures from the material
  37725. * @returns an array of textures
  37726. */
  37727. getActiveTextures(): BaseTexture[];
  37728. /**
  37729. * Specifies if the material uses a texture
  37730. * @param texture defines the texture to check against the material
  37731. * @returns a boolean specifying if the material uses the texture
  37732. */
  37733. hasTexture(texture: BaseTexture): boolean;
  37734. /**
  37735. * Disposes the material
  37736. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  37737. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  37738. */
  37739. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  37740. /**
  37741. * Makes a duplicate of the material, and gives it a new name
  37742. * @param name defines the new name for the duplicated material
  37743. * @returns the cloned material
  37744. */
  37745. clone(name: string): StandardMaterial;
  37746. /**
  37747. * Serializes this material in a JSON representation
  37748. * @returns the serialized material object
  37749. */
  37750. serialize(): any;
  37751. /**
  37752. * Creates a standard material from parsed material data
  37753. * @param source defines the JSON representation of the material
  37754. * @param scene defines the hosting scene
  37755. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  37756. * @returns a new standard material
  37757. */
  37758. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  37759. /**
  37760. * Are diffuse textures enabled in the application.
  37761. */
  37762. static DiffuseTextureEnabled: boolean;
  37763. /**
  37764. * Are ambient textures enabled in the application.
  37765. */
  37766. static AmbientTextureEnabled: boolean;
  37767. /**
  37768. * Are opacity textures enabled in the application.
  37769. */
  37770. static OpacityTextureEnabled: boolean;
  37771. /**
  37772. * Are reflection textures enabled in the application.
  37773. */
  37774. static ReflectionTextureEnabled: boolean;
  37775. /**
  37776. * Are emissive textures enabled in the application.
  37777. */
  37778. static EmissiveTextureEnabled: boolean;
  37779. /**
  37780. * Are specular textures enabled in the application.
  37781. */
  37782. static SpecularTextureEnabled: boolean;
  37783. /**
  37784. * Are bump textures enabled in the application.
  37785. */
  37786. static BumpTextureEnabled: boolean;
  37787. /**
  37788. * Are lightmap textures enabled in the application.
  37789. */
  37790. static LightmapTextureEnabled: boolean;
  37791. /**
  37792. * Are refraction textures enabled in the application.
  37793. */
  37794. static RefractionTextureEnabled: boolean;
  37795. /**
  37796. * Are color grading textures enabled in the application.
  37797. */
  37798. static ColorGradingTextureEnabled: boolean;
  37799. /**
  37800. * Are fresnels enabled in the application.
  37801. */
  37802. static FresnelEnabled: boolean;
  37803. }
  37804. }
  37805. declare module BABYLON {
  37806. /**
  37807. * A class extending Texture allowing drawing on a texture
  37808. * @see http://doc.babylonjs.com/how_to/dynamictexture
  37809. */
  37810. export class DynamicTexture extends Texture {
  37811. private _generateMipMaps;
  37812. private _canvas;
  37813. private _context;
  37814. private _engine;
  37815. /**
  37816. * Creates a DynamicTexture
  37817. * @param name defines the name of the texture
  37818. * @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
  37819. * @param scene defines the scene where you want the texture
  37820. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  37821. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  37822. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  37823. */
  37824. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  37825. /**
  37826. * Get the current class name of the texture useful for serialization or dynamic coding.
  37827. * @returns "DynamicTexture"
  37828. */
  37829. getClassName(): string;
  37830. /**
  37831. * Gets the current state of canRescale
  37832. */
  37833. readonly canRescale: boolean;
  37834. private _recreate;
  37835. /**
  37836. * Scales the texture
  37837. * @param ratio the scale factor to apply to both width and height
  37838. */
  37839. scale(ratio: number): void;
  37840. /**
  37841. * Resizes the texture
  37842. * @param width the new width
  37843. * @param height the new height
  37844. */
  37845. scaleTo(width: number, height: number): void;
  37846. /**
  37847. * Gets the context of the canvas used by the texture
  37848. * @returns the canvas context of the dynamic texture
  37849. */
  37850. getContext(): CanvasRenderingContext2D;
  37851. /**
  37852. * Clears the texture
  37853. */
  37854. clear(): void;
  37855. /**
  37856. * Updates the texture
  37857. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37858. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  37859. */
  37860. update(invertY?: boolean, premulAlpha?: boolean): void;
  37861. /**
  37862. * Draws text onto the texture
  37863. * @param text defines the text to be drawn
  37864. * @param x defines the placement of the text from the left
  37865. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  37866. * @param font defines the font to be used with font-style, font-size, font-name
  37867. * @param color defines the color used for the text
  37868. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  37869. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37870. * @param update defines whether texture is immediately update (default is true)
  37871. */
  37872. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  37873. /**
  37874. * Clones the texture
  37875. * @returns the clone of the texture.
  37876. */
  37877. clone(): DynamicTexture;
  37878. /**
  37879. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  37880. * @returns a serialized dynamic texture object
  37881. */
  37882. serialize(): any;
  37883. /** @hidden */
  37884. _rebuild(): void;
  37885. }
  37886. }
  37887. declare module BABYLON {
  37888. /** @hidden */
  37889. export var imageProcessingPixelShader: {
  37890. name: string;
  37891. shader: string;
  37892. };
  37893. }
  37894. declare module BABYLON {
  37895. /**
  37896. * ImageProcessingPostProcess
  37897. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  37898. */
  37899. export class ImageProcessingPostProcess extends PostProcess {
  37900. /**
  37901. * Default configuration related to image processing available in the PBR Material.
  37902. */
  37903. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  37904. /**
  37905. * Gets the image processing configuration used either in this material.
  37906. */
  37907. /**
  37908. * Sets the Default image processing configuration used either in the this material.
  37909. *
  37910. * If sets to null, the scene one is in use.
  37911. */
  37912. imageProcessingConfiguration: ImageProcessingConfiguration;
  37913. /**
  37914. * Keep track of the image processing observer to allow dispose and replace.
  37915. */
  37916. private _imageProcessingObserver;
  37917. /**
  37918. * Attaches a new image processing configuration to the PBR Material.
  37919. * @param configuration
  37920. */
  37921. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  37922. /**
  37923. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  37924. */
  37925. /**
  37926. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  37927. */
  37928. colorCurves: Nullable<ColorCurves>;
  37929. /**
  37930. * Gets wether the color curves effect is enabled.
  37931. */
  37932. /**
  37933. * Sets wether the color curves effect is enabled.
  37934. */
  37935. colorCurvesEnabled: boolean;
  37936. /**
  37937. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  37938. */
  37939. /**
  37940. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  37941. */
  37942. colorGradingTexture: Nullable<BaseTexture>;
  37943. /**
  37944. * Gets wether the color grading effect is enabled.
  37945. */
  37946. /**
  37947. * Gets wether the color grading effect is enabled.
  37948. */
  37949. colorGradingEnabled: boolean;
  37950. /**
  37951. * Gets exposure used in the effect.
  37952. */
  37953. /**
  37954. * Sets exposure used in the effect.
  37955. */
  37956. exposure: number;
  37957. /**
  37958. * Gets wether tonemapping is enabled or not.
  37959. */
  37960. /**
  37961. * Sets wether tonemapping is enabled or not
  37962. */
  37963. toneMappingEnabled: boolean;
  37964. /**
  37965. * Gets contrast used in the effect.
  37966. */
  37967. /**
  37968. * Sets contrast used in the effect.
  37969. */
  37970. contrast: number;
  37971. /**
  37972. * Gets Vignette stretch size.
  37973. */
  37974. /**
  37975. * Sets Vignette stretch size.
  37976. */
  37977. vignetteStretch: number;
  37978. /**
  37979. * Gets Vignette centre X Offset.
  37980. */
  37981. /**
  37982. * Sets Vignette centre X Offset.
  37983. */
  37984. vignetteCentreX: number;
  37985. /**
  37986. * Gets Vignette centre Y Offset.
  37987. */
  37988. /**
  37989. * Sets Vignette centre Y Offset.
  37990. */
  37991. vignetteCentreY: number;
  37992. /**
  37993. * Gets Vignette weight or intensity of the vignette effect.
  37994. */
  37995. /**
  37996. * Sets Vignette weight or intensity of the vignette effect.
  37997. */
  37998. vignetteWeight: number;
  37999. /**
  38000. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38001. * if vignetteEnabled is set to true.
  38002. */
  38003. /**
  38004. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38005. * if vignetteEnabled is set to true.
  38006. */
  38007. vignetteColor: Color4;
  38008. /**
  38009. * Gets Camera field of view used by the Vignette effect.
  38010. */
  38011. /**
  38012. * Sets Camera field of view used by the Vignette effect.
  38013. */
  38014. vignetteCameraFov: number;
  38015. /**
  38016. * Gets the vignette blend mode allowing different kind of effect.
  38017. */
  38018. /**
  38019. * Sets the vignette blend mode allowing different kind of effect.
  38020. */
  38021. vignetteBlendMode: number;
  38022. /**
  38023. * Gets wether the vignette effect is enabled.
  38024. */
  38025. /**
  38026. * Sets wether the vignette effect is enabled.
  38027. */
  38028. vignetteEnabled: boolean;
  38029. private _fromLinearSpace;
  38030. /**
  38031. * Gets wether the input of the processing is in Gamma or Linear Space.
  38032. */
  38033. /**
  38034. * Sets wether the input of the processing is in Gamma or Linear Space.
  38035. */
  38036. fromLinearSpace: boolean;
  38037. /**
  38038. * Defines cache preventing GC.
  38039. */
  38040. private _defines;
  38041. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38042. /**
  38043. * "ImageProcessingPostProcess"
  38044. * @returns "ImageProcessingPostProcess"
  38045. */
  38046. getClassName(): string;
  38047. protected _updateParameters(): void;
  38048. dispose(camera?: Camera): void;
  38049. }
  38050. }
  38051. declare module BABYLON {
  38052. /**
  38053. * Class containing static functions to help procedurally build meshes
  38054. */
  38055. export class GroundBuilder {
  38056. /**
  38057. * Creates a ground mesh
  38058. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38059. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38061. * @param name defines the name of the mesh
  38062. * @param options defines the options used to create the mesh
  38063. * @param scene defines the hosting scene
  38064. * @returns the ground mesh
  38065. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38066. */
  38067. static CreateGround(name: string, options: {
  38068. width?: number;
  38069. height?: number;
  38070. subdivisions?: number;
  38071. subdivisionsX?: number;
  38072. subdivisionsY?: number;
  38073. updatable?: boolean;
  38074. }, scene: any): Mesh;
  38075. /**
  38076. * Creates a tiled ground mesh
  38077. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38078. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38079. * * 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
  38080. * * 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
  38081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38082. * @param name defines the name of the mesh
  38083. * @param options defines the options used to create the mesh
  38084. * @param scene defines the hosting scene
  38085. * @returns the tiled ground mesh
  38086. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38087. */
  38088. static CreateTiledGround(name: string, options: {
  38089. xmin: number;
  38090. zmin: number;
  38091. xmax: number;
  38092. zmax: number;
  38093. subdivisions?: {
  38094. w: number;
  38095. h: number;
  38096. };
  38097. precision?: {
  38098. w: number;
  38099. h: number;
  38100. };
  38101. updatable?: boolean;
  38102. }, scene: Scene): Mesh;
  38103. /**
  38104. * Creates a ground mesh from a height map
  38105. * * The parameter `url` sets the URL of the height map image resource.
  38106. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38107. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38108. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38109. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38110. * * 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.
  38111. * * 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).
  38112. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38114. * @param name defines the name of the mesh
  38115. * @param url defines the url to the height map
  38116. * @param options defines the options used to create the mesh
  38117. * @param scene defines the hosting scene
  38118. * @returns the ground mesh
  38119. * @see https://doc.babylonjs.com/babylon101/height_map
  38120. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38121. */
  38122. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38123. width?: number;
  38124. height?: number;
  38125. subdivisions?: number;
  38126. minHeight?: number;
  38127. maxHeight?: number;
  38128. colorFilter?: Color3;
  38129. alphaFilter?: number;
  38130. updatable?: boolean;
  38131. onReady?: (mesh: GroundMesh) => void;
  38132. }, scene: Scene): GroundMesh;
  38133. }
  38134. }
  38135. declare module BABYLON {
  38136. /**
  38137. * Class containing static functions to help procedurally build meshes
  38138. */
  38139. export class TorusBuilder {
  38140. /**
  38141. * Creates a torus mesh
  38142. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38143. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38144. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38145. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38146. * * 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
  38147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38148. * @param name defines the name of the mesh
  38149. * @param options defines the options used to create the mesh
  38150. * @param scene defines the hosting scene
  38151. * @returns the torus mesh
  38152. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38153. */
  38154. static CreateTorus(name: string, options: {
  38155. diameter?: number;
  38156. thickness?: number;
  38157. tessellation?: number;
  38158. updatable?: boolean;
  38159. sideOrientation?: number;
  38160. frontUVs?: Vector4;
  38161. backUVs?: Vector4;
  38162. }, scene: any): Mesh;
  38163. }
  38164. }
  38165. declare module BABYLON {
  38166. /**
  38167. * Class containing static functions to help procedurally build meshes
  38168. */
  38169. export class CylinderBuilder {
  38170. /**
  38171. * Creates a cylinder or a cone mesh
  38172. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38173. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38174. * * 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.
  38175. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38176. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38177. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38178. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38179. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38180. * * 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).
  38181. * * 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
  38182. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38183. * * 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
  38184. * * 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.
  38185. * * If `enclose` is false, a ring surface is one element.
  38186. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38187. * * 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
  38188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38189. * * 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
  38190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38191. * @param name defines the name of the mesh
  38192. * @param options defines the options used to create the mesh
  38193. * @param scene defines the hosting scene
  38194. * @returns the cylinder mesh
  38195. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38196. */
  38197. static CreateCylinder(name: string, options: {
  38198. height?: number;
  38199. diameterTop?: number;
  38200. diameterBottom?: number;
  38201. diameter?: number;
  38202. tessellation?: number;
  38203. subdivisions?: number;
  38204. arc?: number;
  38205. faceColors?: Color4[];
  38206. faceUV?: Vector4[];
  38207. updatable?: boolean;
  38208. hasRings?: boolean;
  38209. enclose?: boolean;
  38210. sideOrientation?: number;
  38211. frontUVs?: Vector4;
  38212. backUVs?: Vector4;
  38213. }, scene: any): Mesh;
  38214. }
  38215. }
  38216. declare module BABYLON {
  38217. /**
  38218. * Manager for handling gamepads
  38219. */
  38220. export class GamepadManager {
  38221. private _scene?;
  38222. private _babylonGamepads;
  38223. private _oneGamepadConnected;
  38224. /** @hidden */
  38225. _isMonitoring: boolean;
  38226. private _gamepadEventSupported;
  38227. private _gamepadSupport;
  38228. /**
  38229. * observable to be triggered when the gamepad controller has been connected
  38230. */
  38231. onGamepadConnectedObservable: Observable<Gamepad>;
  38232. /**
  38233. * observable to be triggered when the gamepad controller has been disconnected
  38234. */
  38235. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38236. private _onGamepadConnectedEvent;
  38237. private _onGamepadDisconnectedEvent;
  38238. /**
  38239. * Initializes the gamepad manager
  38240. * @param _scene BabylonJS scene
  38241. */
  38242. constructor(_scene?: Scene | undefined);
  38243. /**
  38244. * The gamepads in the game pad manager
  38245. */
  38246. readonly gamepads: Gamepad[];
  38247. /**
  38248. * Get the gamepad controllers based on type
  38249. * @param type The type of gamepad controller
  38250. * @returns Nullable gamepad
  38251. */
  38252. getGamepadByType(type?: number): Nullable<Gamepad>;
  38253. /**
  38254. * Disposes the gamepad manager
  38255. */
  38256. dispose(): void;
  38257. private _addNewGamepad;
  38258. private _startMonitoringGamepads;
  38259. private _stopMonitoringGamepads;
  38260. /** @hidden */
  38261. _checkGamepadsStatus(): void;
  38262. private _updateGamepadObjects;
  38263. }
  38264. }
  38265. declare module BABYLON {
  38266. interface Scene {
  38267. /** @hidden */
  38268. _gamepadManager: Nullable<GamepadManager>;
  38269. /**
  38270. * Gets the gamepad manager associated with the scene
  38271. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38272. */
  38273. gamepadManager: GamepadManager;
  38274. }
  38275. /**
  38276. * Interface representing a free camera inputs manager
  38277. */
  38278. interface FreeCameraInputsManager {
  38279. /**
  38280. * Adds gamepad input support to the FreeCameraInputsManager.
  38281. * @returns the FreeCameraInputsManager
  38282. */
  38283. addGamepad(): FreeCameraInputsManager;
  38284. }
  38285. /**
  38286. * Interface representing an arc rotate camera inputs manager
  38287. */
  38288. interface ArcRotateCameraInputsManager {
  38289. /**
  38290. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38291. * @returns the camera inputs manager
  38292. */
  38293. addGamepad(): ArcRotateCameraInputsManager;
  38294. }
  38295. /**
  38296. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38297. */
  38298. export class GamepadSystemSceneComponent implements ISceneComponent {
  38299. /**
  38300. * The component name helpfull to identify the component in the list of scene components.
  38301. */
  38302. readonly name: string;
  38303. /**
  38304. * The scene the component belongs to.
  38305. */
  38306. scene: Scene;
  38307. /**
  38308. * Creates a new instance of the component for the given scene
  38309. * @param scene Defines the scene to register the component in
  38310. */
  38311. constructor(scene: Scene);
  38312. /**
  38313. * Registers the component in a given scene
  38314. */
  38315. register(): void;
  38316. /**
  38317. * Rebuilds the elements related to this component in case of
  38318. * context lost for instance.
  38319. */
  38320. rebuild(): void;
  38321. /**
  38322. * Disposes the component and the associated ressources
  38323. */
  38324. dispose(): void;
  38325. private _beforeCameraUpdate;
  38326. }
  38327. }
  38328. declare module BABYLON {
  38329. /**
  38330. * Options to modify the vr teleportation behavior.
  38331. */
  38332. export interface VRTeleportationOptions {
  38333. /**
  38334. * The name of the mesh which should be used as the teleportation floor. (default: null)
  38335. */
  38336. floorMeshName?: string;
  38337. /**
  38338. * A list of meshes to be used as the teleportation floor. (default: empty)
  38339. */
  38340. floorMeshes?: Mesh[];
  38341. }
  38342. /**
  38343. * Options to modify the vr experience helper's behavior.
  38344. */
  38345. export interface VRExperienceHelperOptions extends WebVROptions {
  38346. /**
  38347. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  38348. */
  38349. createDeviceOrientationCamera?: boolean;
  38350. /**
  38351. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  38352. */
  38353. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  38354. /**
  38355. * Uses the main button on the controller to toggle the laser casted. (default: true)
  38356. */
  38357. laserToggle?: boolean;
  38358. /**
  38359. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  38360. */
  38361. floorMeshes?: Mesh[];
  38362. /**
  38363. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  38364. */
  38365. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  38366. }
  38367. /**
  38368. * Helps to quickly add VR support to an existing scene.
  38369. * See http://doc.babylonjs.com/how_to/webvr_helper
  38370. */
  38371. export class VRExperienceHelper {
  38372. /** Options to modify the vr experience helper's behavior. */
  38373. webVROptions: VRExperienceHelperOptions;
  38374. private _scene;
  38375. private _position;
  38376. private _btnVR;
  38377. private _btnVRDisplayed;
  38378. private _webVRsupported;
  38379. private _webVRready;
  38380. private _webVRrequesting;
  38381. private _webVRpresenting;
  38382. private _hasEnteredVR;
  38383. private _fullscreenVRpresenting;
  38384. private _canvas;
  38385. private _webVRCamera;
  38386. private _vrDeviceOrientationCamera;
  38387. private _deviceOrientationCamera;
  38388. private _existingCamera;
  38389. private _onKeyDown;
  38390. private _onVrDisplayPresentChange;
  38391. private _onVRDisplayChanged;
  38392. private _onVRRequestPresentStart;
  38393. private _onVRRequestPresentComplete;
  38394. /**
  38395. * Observable raised when entering VR.
  38396. */
  38397. onEnteringVRObservable: Observable<VRExperienceHelper>;
  38398. /**
  38399. * Observable raised when exiting VR.
  38400. */
  38401. onExitingVRObservable: Observable<VRExperienceHelper>;
  38402. /**
  38403. * Observable raised when controller mesh is loaded.
  38404. */
  38405. onControllerMeshLoadedObservable: Observable<WebVRController>;
  38406. /** Return this.onEnteringVRObservable
  38407. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  38408. */
  38409. readonly onEnteringVR: Observable<VRExperienceHelper>;
  38410. /** Return this.onExitingVRObservable
  38411. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  38412. */
  38413. readonly onExitingVR: Observable<VRExperienceHelper>;
  38414. /** Return this.onControllerMeshLoadedObservable
  38415. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  38416. */
  38417. readonly onControllerMeshLoaded: Observable<WebVRController>;
  38418. private _rayLength;
  38419. private _useCustomVRButton;
  38420. private _teleportationRequested;
  38421. private _teleportActive;
  38422. private _floorMeshName;
  38423. private _floorMeshesCollection;
  38424. private _rotationAllowed;
  38425. private _teleportBackwardsVector;
  38426. private _teleportationTarget;
  38427. private _isDefaultTeleportationTarget;
  38428. private _postProcessMove;
  38429. private _teleportationFillColor;
  38430. private _teleportationBorderColor;
  38431. private _rotationAngle;
  38432. private _haloCenter;
  38433. private _cameraGazer;
  38434. private _padSensibilityUp;
  38435. private _padSensibilityDown;
  38436. private _leftController;
  38437. private _rightController;
  38438. /**
  38439. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  38440. */
  38441. onNewMeshSelected: Observable<AbstractMesh>;
  38442. /**
  38443. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  38444. */
  38445. onNewMeshPicked: Observable<PickingInfo>;
  38446. private _circleEase;
  38447. /**
  38448. * Observable raised before camera teleportation
  38449. */
  38450. onBeforeCameraTeleport: Observable<Vector3>;
  38451. /**
  38452. * Observable raised after camera teleportation
  38453. */
  38454. onAfterCameraTeleport: Observable<Vector3>;
  38455. /**
  38456. * Observable raised when current selected mesh gets unselected
  38457. */
  38458. onSelectedMeshUnselected: Observable<AbstractMesh>;
  38459. private _raySelectionPredicate;
  38460. /**
  38461. * To be optionaly changed by user to define custom ray selection
  38462. */
  38463. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  38464. /**
  38465. * To be optionaly changed by user to define custom selection logic (after ray selection)
  38466. */
  38467. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  38468. /**
  38469. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  38470. */
  38471. teleportationEnabled: boolean;
  38472. private _defaultHeight;
  38473. private _teleportationInitialized;
  38474. private _interactionsEnabled;
  38475. private _interactionsRequested;
  38476. private _displayGaze;
  38477. private _displayLaserPointer;
  38478. /**
  38479. * The mesh used to display where the user is going to teleport.
  38480. */
  38481. /**
  38482. * Sets the mesh to be used to display where the user is going to teleport.
  38483. */
  38484. teleportationTarget: Mesh;
  38485. /**
  38486. * 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
  38487. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  38488. * See http://doc.babylonjs.com/resources/baking_transformations
  38489. */
  38490. gazeTrackerMesh: Mesh;
  38491. /**
  38492. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  38493. */
  38494. updateGazeTrackerScale: boolean;
  38495. /**
  38496. * If the gaze trackers color should be updated when selecting meshes
  38497. */
  38498. updateGazeTrackerColor: boolean;
  38499. /**
  38500. * The gaze tracking mesh corresponding to the left controller
  38501. */
  38502. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  38503. /**
  38504. * The gaze tracking mesh corresponding to the right controller
  38505. */
  38506. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  38507. /**
  38508. * If the ray of the gaze should be displayed.
  38509. */
  38510. /**
  38511. * Sets if the ray of the gaze should be displayed.
  38512. */
  38513. displayGaze: boolean;
  38514. /**
  38515. * If the ray of the LaserPointer should be displayed.
  38516. */
  38517. /**
  38518. * Sets if the ray of the LaserPointer should be displayed.
  38519. */
  38520. displayLaserPointer: boolean;
  38521. /**
  38522. * The deviceOrientationCamera used as the camera when not in VR.
  38523. */
  38524. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  38525. /**
  38526. * Based on the current WebVR support, returns the current VR camera used.
  38527. */
  38528. readonly currentVRCamera: Nullable<Camera>;
  38529. /**
  38530. * The webVRCamera which is used when in VR.
  38531. */
  38532. readonly webVRCamera: WebVRFreeCamera;
  38533. /**
  38534. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  38535. */
  38536. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  38537. private readonly _teleportationRequestInitiated;
  38538. /**
  38539. * Defines wether or not Pointer lock should be requested when switching to
  38540. * full screen.
  38541. */
  38542. requestPointerLockOnFullScreen: boolean;
  38543. /**
  38544. * Instantiates a VRExperienceHelper.
  38545. * Helps to quickly add VR support to an existing scene.
  38546. * @param scene The scene the VRExperienceHelper belongs to.
  38547. * @param webVROptions Options to modify the vr experience helper's behavior.
  38548. */
  38549. constructor(scene: Scene,
  38550. /** Options to modify the vr experience helper's behavior. */
  38551. webVROptions?: VRExperienceHelperOptions);
  38552. private _onDefaultMeshLoaded;
  38553. private _onResize;
  38554. private _onFullscreenChange;
  38555. /**
  38556. * Gets a value indicating if we are currently in VR mode.
  38557. */
  38558. readonly isInVRMode: boolean;
  38559. private onVrDisplayPresentChange;
  38560. private onVRDisplayChanged;
  38561. private moveButtonToBottomRight;
  38562. private displayVRButton;
  38563. private updateButtonVisibility;
  38564. private _cachedAngularSensibility;
  38565. /**
  38566. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  38567. * Otherwise, will use the fullscreen API.
  38568. */
  38569. enterVR(): void;
  38570. /**
  38571. * Attempt to exit VR, or fullscreen.
  38572. */
  38573. exitVR(): void;
  38574. /**
  38575. * The position of the vr experience helper.
  38576. */
  38577. /**
  38578. * Sets the position of the vr experience helper.
  38579. */
  38580. position: Vector3;
  38581. /**
  38582. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  38583. */
  38584. enableInteractions(): void;
  38585. private readonly _noControllerIsActive;
  38586. private beforeRender;
  38587. private _isTeleportationFloor;
  38588. /**
  38589. * Adds a floor mesh to be used for teleportation.
  38590. * @param floorMesh the mesh to be used for teleportation.
  38591. */
  38592. addFloorMesh(floorMesh: Mesh): void;
  38593. /**
  38594. * Removes a floor mesh from being used for teleportation.
  38595. * @param floorMesh the mesh to be removed.
  38596. */
  38597. removeFloorMesh(floorMesh: Mesh): void;
  38598. /**
  38599. * Enables interactions and teleportation using the VR controllers and gaze.
  38600. * @param vrTeleportationOptions options to modify teleportation behavior.
  38601. */
  38602. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  38603. private _onNewGamepadConnected;
  38604. private _tryEnableInteractionOnController;
  38605. private _onNewGamepadDisconnected;
  38606. private _enableInteractionOnController;
  38607. private _checkTeleportWithRay;
  38608. private _checkRotate;
  38609. private _checkTeleportBackwards;
  38610. private _enableTeleportationOnController;
  38611. private _createTeleportationCircles;
  38612. private _displayTeleportationTarget;
  38613. private _hideTeleportationTarget;
  38614. private _rotateCamera;
  38615. private _moveTeleportationSelectorTo;
  38616. private _workingVector;
  38617. private _workingQuaternion;
  38618. private _workingMatrix;
  38619. /**
  38620. * Teleports the users feet to the desired location
  38621. * @param location The location where the user's feet should be placed
  38622. */
  38623. teleportCamera(location: Vector3): void;
  38624. private _convertNormalToDirectionOfRay;
  38625. private _castRayAndSelectObject;
  38626. private _notifySelectedMeshUnselected;
  38627. /**
  38628. * Sets the color of the laser ray from the vr controllers.
  38629. * @param color new color for the ray.
  38630. */
  38631. changeLaserColor(color: Color3): void;
  38632. /**
  38633. * Sets the color of the ray from the vr headsets gaze.
  38634. * @param color new color for the ray.
  38635. */
  38636. changeGazeColor(color: Color3): void;
  38637. /**
  38638. * Exits VR and disposes of the vr experience helper
  38639. */
  38640. dispose(): void;
  38641. /**
  38642. * Gets the name of the VRExperienceHelper class
  38643. * @returns "VRExperienceHelper"
  38644. */
  38645. getClassName(): string;
  38646. }
  38647. }
  38648. declare module BABYLON {
  38649. /**
  38650. * Manages an XRSession
  38651. * @see https://doc.babylonjs.com/how_to/webxr
  38652. */
  38653. export class WebXRSessionManager implements IDisposable {
  38654. private scene;
  38655. /**
  38656. * Fires every time a new xrFrame arrives which can be used to update the camera
  38657. */
  38658. onXRFrameObservable: Observable<any>;
  38659. /**
  38660. * Fires when the xr session is ended either by the device or manually done
  38661. */
  38662. onXRSessionEnded: Observable<any>;
  38663. /** @hidden */
  38664. _xrSession: XRSession;
  38665. /** @hidden */
  38666. _frameOfReference: XRFrameOfReference;
  38667. /** @hidden */
  38668. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  38669. /** @hidden */
  38670. _currentXRFrame: Nullable<XRFrame>;
  38671. private _xrNavigator;
  38672. private _xrDevice;
  38673. private _tmpMatrix;
  38674. /**
  38675. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  38676. * @param scene The scene which the session should be created for
  38677. */
  38678. constructor(scene: Scene);
  38679. /**
  38680. * Initializes the manager
  38681. * After initialization enterXR can be called to start an XR session
  38682. * @returns Promise which resolves after it is initialized
  38683. */
  38684. initializeAsync(): Promise<void>;
  38685. /**
  38686. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  38687. * @param sessionCreationOptions xr options to create the session with
  38688. * @param frameOfReferenceType option to configure how the xr pose is expressed
  38689. * @returns Promise which resolves after it enters XR
  38690. */
  38691. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  38692. /**
  38693. * Stops the xrSession and restores the renderloop
  38694. * @returns Promise which resolves after it exits XR
  38695. */
  38696. exitXRAsync(): Promise<void>;
  38697. /**
  38698. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  38699. * @param ray ray to cast into the environment
  38700. * @returns Promise which resolves with a collision point in the environment if it exists
  38701. */
  38702. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  38703. /**
  38704. * Checks if a session would be supported for the creation options specified
  38705. * @param options creation options to check if they are supported
  38706. * @returns true if supported
  38707. */
  38708. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  38709. /**
  38710. * @hidden
  38711. * Converts the render layer of xrSession to a render target
  38712. * @param session session to create render target for
  38713. * @param scene scene the new render target should be created for
  38714. */
  38715. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  38716. /**
  38717. * Disposes of the session manager
  38718. */
  38719. dispose(): void;
  38720. }
  38721. }
  38722. declare module BABYLON {
  38723. /**
  38724. * WebXR Camera which holds the views for the xrSession
  38725. * @see https://doc.babylonjs.com/how_to/webxr
  38726. */
  38727. export class WebXRCamera extends FreeCamera {
  38728. private static _TmpMatrix;
  38729. /**
  38730. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  38731. * @param name the name of the camera
  38732. * @param scene the scene to add the camera to
  38733. */
  38734. constructor(name: string, scene: Scene);
  38735. private _updateNumberOfRigCameras;
  38736. /** @hidden */
  38737. _updateForDualEyeDebugging(pupilDistance?: number): void;
  38738. /**
  38739. * Updates the cameras position from the current pose information of the XR session
  38740. * @param xrSessionManager the session containing pose information
  38741. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  38742. */
  38743. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  38744. }
  38745. }
  38746. declare module BABYLON {
  38747. /**
  38748. * States of the webXR experience
  38749. */
  38750. export enum WebXRState {
  38751. /**
  38752. * Transitioning to being in XR mode
  38753. */
  38754. ENTERING_XR = 0,
  38755. /**
  38756. * Transitioning to non XR mode
  38757. */
  38758. EXITING_XR = 1,
  38759. /**
  38760. * In XR mode and presenting
  38761. */
  38762. IN_XR = 2,
  38763. /**
  38764. * Not entered XR mode
  38765. */
  38766. NOT_IN_XR = 3
  38767. }
  38768. /**
  38769. * Helper class used to enable XR
  38770. * @see https://doc.babylonjs.com/how_to/webxr
  38771. */
  38772. export class WebXRExperienceHelper implements IDisposable {
  38773. private scene;
  38774. /**
  38775. * 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
  38776. */
  38777. container: AbstractMesh;
  38778. /**
  38779. * Camera used to render xr content
  38780. */
  38781. camera: WebXRCamera;
  38782. /**
  38783. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  38784. */
  38785. state: WebXRState;
  38786. private _setState;
  38787. private static _TmpVector;
  38788. /**
  38789. * Fires when the state of the experience helper has changed
  38790. */
  38791. onStateChangedObservable: Observable<WebXRState>;
  38792. /** @hidden */
  38793. _sessionManager: WebXRSessionManager;
  38794. private _nonVRCamera;
  38795. private _originalSceneAutoClear;
  38796. private _supported;
  38797. /**
  38798. * Creates the experience helper
  38799. * @param scene the scene to attach the experience helper to
  38800. * @returns a promise for the experience helper
  38801. */
  38802. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  38803. /**
  38804. * Creates a WebXRExperienceHelper
  38805. * @param scene The scene the helper should be created in
  38806. */
  38807. private constructor();
  38808. /**
  38809. * Exits XR mode and returns the scene to its original state
  38810. * @returns promise that resolves after xr mode has exited
  38811. */
  38812. exitXRAsync(): Promise<void>;
  38813. /**
  38814. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  38815. * @param sessionCreationOptions options for the XR session
  38816. * @param frameOfReference frame of reference of the XR session
  38817. * @returns promise that resolves after xr mode has entered
  38818. */
  38819. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  38820. /**
  38821. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  38822. * @param ray ray to cast into the environment
  38823. * @returns Promise which resolves with a collision point in the environment if it exists
  38824. */
  38825. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  38826. /**
  38827. * Updates the global position of the camera by moving the camera's container
  38828. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  38829. * @param position The desired global position of the camera
  38830. */
  38831. setPositionOfCameraUsingContainer(position: Vector3): void;
  38832. /**
  38833. * Rotates the xr camera by rotating the camera's container around the camera's position
  38834. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  38835. * @param rotation the desired quaternion rotation to apply to the camera
  38836. */
  38837. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  38838. /**
  38839. * Checks if the creation options are supported by the xr session
  38840. * @param options creation options
  38841. * @returns true if supported
  38842. */
  38843. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  38844. /**
  38845. * Disposes of the experience helper
  38846. */
  38847. dispose(): void;
  38848. }
  38849. }
  38850. declare module BABYLON {
  38851. /**
  38852. * Button which can be used to enter a different mode of XR
  38853. */
  38854. export class WebXREnterExitUIButton {
  38855. /** button element */
  38856. element: HTMLElement;
  38857. /** XR initialization options for the button */
  38858. initializationOptions: XRSessionCreationOptions;
  38859. /**
  38860. * Creates a WebXREnterExitUIButton
  38861. * @param element button element
  38862. * @param initializationOptions XR initialization options for the button
  38863. */
  38864. constructor(
  38865. /** button element */
  38866. element: HTMLElement,
  38867. /** XR initialization options for the button */
  38868. initializationOptions: XRSessionCreationOptions);
  38869. /**
  38870. * Overwritable function which can be used to update the button's visuals when the state changes
  38871. * @param activeButton the current active button in the UI
  38872. */
  38873. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  38874. }
  38875. /**
  38876. * Options to create the webXR UI
  38877. */
  38878. export class WebXREnterExitUIOptions {
  38879. /**
  38880. * Context to enter xr with
  38881. */
  38882. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  38883. /**
  38884. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  38885. */
  38886. customButtons?: Array<WebXREnterExitUIButton>;
  38887. }
  38888. /**
  38889. * UI to allow the user to enter/exit XR mode
  38890. */
  38891. export class WebXREnterExitUI implements IDisposable {
  38892. private scene;
  38893. private _overlay;
  38894. private _buttons;
  38895. private _activeButton;
  38896. /**
  38897. * Fired every time the active button is changed.
  38898. *
  38899. * When xr is entered via a button that launches xr that button will be the callback parameter
  38900. *
  38901. * When exiting xr the callback parameter will be null)
  38902. */
  38903. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  38904. /**
  38905. * Creates UI to allow the user to enter/exit XR mode
  38906. * @param scene the scene to add the ui to
  38907. * @param helper the xr experience helper to enter/exit xr with
  38908. * @param options options to configure the UI
  38909. * @returns the created ui
  38910. */
  38911. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  38912. private constructor();
  38913. private _updateButtons;
  38914. /**
  38915. * Disposes of the object
  38916. */
  38917. dispose(): void;
  38918. }
  38919. }
  38920. declare module BABYLON {
  38921. /**
  38922. * Represents an XR input
  38923. */
  38924. export class WebXRController {
  38925. /**
  38926. * 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
  38927. */
  38928. grip?: AbstractMesh;
  38929. /**
  38930. * Pointer which can be used to select objects or attach a visible laser to
  38931. */
  38932. pointer: AbstractMesh;
  38933. /**
  38934. * Creates the controller
  38935. * @see https://doc.babylonjs.com/how_to/webxr
  38936. * @param scene the scene which the controller should be associated to
  38937. */
  38938. constructor(scene: Scene);
  38939. /**
  38940. * Disposes of the object
  38941. */
  38942. dispose(): void;
  38943. }
  38944. /**
  38945. * XR input used to track XR inputs such as controllers/rays
  38946. */
  38947. export class WebXRInput implements IDisposable {
  38948. private helper;
  38949. /**
  38950. * XR controllers being tracked
  38951. */
  38952. controllers: Array<WebXRController>;
  38953. private _tmpMatrix;
  38954. private _frameObserver;
  38955. /**
  38956. * Initializes the WebXRInput
  38957. * @param helper experience helper which the input should be created for
  38958. */
  38959. constructor(helper: WebXRExperienceHelper);
  38960. /**
  38961. * Disposes of the object
  38962. */
  38963. dispose(): void;
  38964. }
  38965. }
  38966. declare module BABYLON {
  38967. /**
  38968. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  38969. */
  38970. export class WebXRManagedOutputCanvas implements IDisposable {
  38971. private _canvas;
  38972. /**
  38973. * xrpresent context of the canvas which can be used to display/mirror xr content
  38974. */
  38975. canvasContext: Nullable<WebGLRenderingContext>;
  38976. /**
  38977. * Initializes the canvas to be added/removed upon entering/exiting xr
  38978. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  38979. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  38980. */
  38981. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  38982. /**
  38983. * Disposes of the object
  38984. */
  38985. dispose(): void;
  38986. private _setManagedOutputCanvas;
  38987. private _addCanvas;
  38988. private _removeCanvas;
  38989. }
  38990. }
  38991. declare module BABYLON {
  38992. /**
  38993. * Contains an array of blocks representing the octree
  38994. */
  38995. export interface IOctreeContainer<T> {
  38996. /**
  38997. * Blocks within the octree
  38998. */
  38999. blocks: Array<OctreeBlock<T>>;
  39000. }
  39001. /**
  39002. * Class used to store a cell in an octree
  39003. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39004. */
  39005. export class OctreeBlock<T> {
  39006. /**
  39007. * Gets the content of the current block
  39008. */
  39009. entries: T[];
  39010. /**
  39011. * Gets the list of block children
  39012. */
  39013. blocks: Array<OctreeBlock<T>>;
  39014. private _depth;
  39015. private _maxDepth;
  39016. private _capacity;
  39017. private _minPoint;
  39018. private _maxPoint;
  39019. private _boundingVectors;
  39020. private _creationFunc;
  39021. /**
  39022. * Creates a new block
  39023. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39024. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39025. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39026. * @param depth defines the current depth of this block in the octree
  39027. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39028. * @param creationFunc defines a callback to call when an element is added to the block
  39029. */
  39030. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39031. /**
  39032. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39033. */
  39034. readonly capacity: number;
  39035. /**
  39036. * Gets the minimum vector (in world space) of the block's bounding box
  39037. */
  39038. readonly minPoint: Vector3;
  39039. /**
  39040. * Gets the maximum vector (in world space) of the block's bounding box
  39041. */
  39042. readonly maxPoint: Vector3;
  39043. /**
  39044. * Add a new element to this block
  39045. * @param entry defines the element to add
  39046. */
  39047. addEntry(entry: T): void;
  39048. /**
  39049. * Remove an element from this block
  39050. * @param entry defines the element to remove
  39051. */
  39052. removeEntry(entry: T): void;
  39053. /**
  39054. * Add an array of elements to this block
  39055. * @param entries defines the array of elements to add
  39056. */
  39057. addEntries(entries: T[]): void;
  39058. /**
  39059. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39060. * @param frustumPlanes defines the frustum planes to test
  39061. * @param selection defines the array to store current content if selection is positive
  39062. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39063. */
  39064. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39065. /**
  39066. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39067. * @param sphereCenter defines the bounding sphere center
  39068. * @param sphereRadius defines the bounding sphere radius
  39069. * @param selection defines the array to store current content if selection is positive
  39070. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39071. */
  39072. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39073. /**
  39074. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39075. * @param ray defines the ray to test with
  39076. * @param selection defines the array to store current content if selection is positive
  39077. */
  39078. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39079. /**
  39080. * Subdivide the content into child blocks (this block will then be empty)
  39081. */
  39082. createInnerBlocks(): void;
  39083. /**
  39084. * @hidden
  39085. */
  39086. 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;
  39087. }
  39088. }
  39089. declare module BABYLON {
  39090. /**
  39091. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39092. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39093. */
  39094. export class Octree<T> {
  39095. /** 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.) */
  39096. maxDepth: number;
  39097. /**
  39098. * Blocks within the octree containing objects
  39099. */
  39100. blocks: Array<OctreeBlock<T>>;
  39101. /**
  39102. * Content stored in the octree
  39103. */
  39104. dynamicContent: T[];
  39105. private _maxBlockCapacity;
  39106. private _selectionContent;
  39107. private _creationFunc;
  39108. /**
  39109. * Creates a octree
  39110. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39111. * @param creationFunc function to be used to instatiate the octree
  39112. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39113. * @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.)
  39114. */
  39115. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39116. /** 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.) */
  39117. maxDepth?: number);
  39118. /**
  39119. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39120. * @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);
  39121. * @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);
  39122. * @param entries meshes to be added to the octree blocks
  39123. */
  39124. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39125. /**
  39126. * Adds a mesh to the octree
  39127. * @param entry Mesh to add to the octree
  39128. */
  39129. addMesh(entry: T): void;
  39130. /**
  39131. * Remove an element from the octree
  39132. * @param entry defines the element to remove
  39133. */
  39134. removeMesh(entry: T): void;
  39135. /**
  39136. * Selects an array of meshes within the frustum
  39137. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39138. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39139. * @returns array of meshes within the frustum
  39140. */
  39141. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39142. /**
  39143. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39144. * @param sphereCenter defines the bounding sphere center
  39145. * @param sphereRadius defines the bounding sphere radius
  39146. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39147. * @returns an array of objects that intersect the sphere
  39148. */
  39149. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39150. /**
  39151. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39152. * @param ray defines the ray to test with
  39153. * @returns array of intersected objects
  39154. */
  39155. intersectsRay(ray: Ray): SmartArray<T>;
  39156. /**
  39157. * Adds a mesh into the octree block if it intersects the block
  39158. */
  39159. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39160. /**
  39161. * Adds a submesh into the octree block if it intersects the block
  39162. */
  39163. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39164. }
  39165. }
  39166. declare module BABYLON {
  39167. interface Scene {
  39168. /**
  39169. * @hidden
  39170. * Backing Filed
  39171. */
  39172. _selectionOctree: Octree<AbstractMesh>;
  39173. /**
  39174. * Gets the octree used to boost mesh selection (picking)
  39175. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39176. */
  39177. selectionOctree: Octree<AbstractMesh>;
  39178. /**
  39179. * Creates or updates the octree used to boost selection (picking)
  39180. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39181. * @param maxCapacity defines the maximum capacity per leaf
  39182. * @param maxDepth defines the maximum depth of the octree
  39183. * @returns an octree of AbstractMesh
  39184. */
  39185. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39186. }
  39187. interface AbstractMesh {
  39188. /**
  39189. * @hidden
  39190. * Backing Field
  39191. */
  39192. _submeshesOctree: Octree<SubMesh>;
  39193. /**
  39194. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39195. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39196. * @param maxCapacity defines the maximum size of each block (64 by default)
  39197. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39198. * @returns the new octree
  39199. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39200. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39201. */
  39202. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39203. }
  39204. /**
  39205. * Defines the octree scene component responsible to manage any octrees
  39206. * in a given scene.
  39207. */
  39208. export class OctreeSceneComponent {
  39209. /**
  39210. * The component name helpfull to identify the component in the list of scene components.
  39211. */
  39212. readonly name: string;
  39213. /**
  39214. * The scene the component belongs to.
  39215. */
  39216. scene: Scene;
  39217. /**
  39218. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39219. */
  39220. readonly checksIsEnabled: boolean;
  39221. /**
  39222. * Creates a new instance of the component for the given scene
  39223. * @param scene Defines the scene to register the component in
  39224. */
  39225. constructor(scene: Scene);
  39226. /**
  39227. * Registers the component in a given scene
  39228. */
  39229. register(): void;
  39230. /**
  39231. * Return the list of active meshes
  39232. * @returns the list of active meshes
  39233. */
  39234. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39235. /**
  39236. * Return the list of active sub meshes
  39237. * @param mesh The mesh to get the candidates sub meshes from
  39238. * @returns the list of active sub meshes
  39239. */
  39240. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39241. private _tempRay;
  39242. /**
  39243. * Return the list of sub meshes intersecting with a given local ray
  39244. * @param mesh defines the mesh to find the submesh for
  39245. * @param localRay defines the ray in local space
  39246. * @returns the list of intersecting sub meshes
  39247. */
  39248. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39249. /**
  39250. * Return the list of sub meshes colliding with a collider
  39251. * @param mesh defines the mesh to find the submesh for
  39252. * @param collider defines the collider to evaluate the collision against
  39253. * @returns the list of colliding sub meshes
  39254. */
  39255. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39256. /**
  39257. * Rebuilds the elements related to this component in case of
  39258. * context lost for instance.
  39259. */
  39260. rebuild(): void;
  39261. /**
  39262. * Disposes the component and the associated ressources.
  39263. */
  39264. dispose(): void;
  39265. }
  39266. }
  39267. declare module BABYLON {
  39268. /**
  39269. * Class containing static functions to help procedurally build meshes
  39270. */
  39271. export class LinesBuilder {
  39272. /**
  39273. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  39274. * * 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
  39275. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  39276. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  39277. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  39278. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  39279. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  39280. * * 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
  39281. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  39282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39283. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  39284. * @param name defines the name of the new line system
  39285. * @param options defines the options used to create the line system
  39286. * @param scene defines the hosting scene
  39287. * @returns a new line system mesh
  39288. */
  39289. static CreateLineSystem(name: string, options: {
  39290. lines: Vector3[][];
  39291. updatable?: boolean;
  39292. instance?: Nullable<LinesMesh>;
  39293. colors?: Nullable<Color4[][]>;
  39294. useVertexAlpha?: boolean;
  39295. }, scene: Nullable<Scene>): LinesMesh;
  39296. /**
  39297. * Creates a line mesh
  39298. * 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
  39299. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  39300. * * The parameter `points` is an array successive Vector3
  39301. * * 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
  39302. * * The optional parameter `colors` is an array of successive Color4, one per line point
  39303. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  39304. * * When updating an instance, remember that only point positions can change, not the number of points
  39305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39306. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  39307. * @param name defines the name of the new line system
  39308. * @param options defines the options used to create the line system
  39309. * @param scene defines the hosting scene
  39310. * @returns a new line mesh
  39311. */
  39312. static CreateLines(name: string, options: {
  39313. points: Vector3[];
  39314. updatable?: boolean;
  39315. instance?: Nullable<LinesMesh>;
  39316. colors?: Color4[];
  39317. useVertexAlpha?: boolean;
  39318. }, scene?: Nullable<Scene>): LinesMesh;
  39319. /**
  39320. * Creates a dashed line mesh
  39321. * * 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
  39322. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  39323. * * The parameter `points` is an array successive Vector3
  39324. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  39325. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  39326. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  39327. * * 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
  39328. * * When updating an instance, remember that only point positions can change, not the number of points
  39329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39330. * @param name defines the name of the mesh
  39331. * @param options defines the options used to create the mesh
  39332. * @param scene defines the hosting scene
  39333. * @returns the dashed line mesh
  39334. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  39335. */
  39336. static CreateDashedLines(name: string, options: {
  39337. points: Vector3[];
  39338. dashSize?: number;
  39339. gapSize?: number;
  39340. dashNb?: number;
  39341. updatable?: boolean;
  39342. instance?: LinesMesh;
  39343. }, scene?: Nullable<Scene>): LinesMesh;
  39344. }
  39345. }
  39346. declare module BABYLON {
  39347. /**
  39348. * Renders a layer on top of an existing scene
  39349. */
  39350. export class UtilityLayerRenderer implements IDisposable {
  39351. /** the original scene that will be rendered on top of */
  39352. originalScene: Scene;
  39353. private _pointerCaptures;
  39354. private _lastPointerEvents;
  39355. private static _DefaultUtilityLayer;
  39356. private static _DefaultKeepDepthUtilityLayer;
  39357. /**
  39358. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39359. */
  39360. pickUtilitySceneFirst: boolean;
  39361. /**
  39362. * 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)
  39363. */
  39364. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39365. /**
  39366. * 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)
  39367. */
  39368. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39369. /**
  39370. * The scene that is rendered on top of the original scene
  39371. */
  39372. utilityLayerScene: Scene;
  39373. /**
  39374. * If the utility layer should automatically be rendered on top of existing scene
  39375. */
  39376. shouldRender: boolean;
  39377. /**
  39378. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39379. */
  39380. onlyCheckPointerDownEvents: boolean;
  39381. /**
  39382. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39383. */
  39384. processAllEvents: boolean;
  39385. /**
  39386. * Observable raised when the pointer move from the utility layer scene to the main scene
  39387. */
  39388. onPointerOutObservable: Observable<number>;
  39389. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  39390. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  39391. private _afterRenderObserver;
  39392. private _sceneDisposeObserver;
  39393. private _originalPointerObserver;
  39394. /**
  39395. * Instantiates a UtilityLayerRenderer
  39396. * @param originalScene the original scene that will be rendered on top of
  39397. * @param handleEvents boolean indicating if the utility layer should handle events
  39398. */
  39399. constructor(
  39400. /** the original scene that will be rendered on top of */
  39401. originalScene: Scene, handleEvents?: boolean);
  39402. private _notifyObservers;
  39403. /**
  39404. * Renders the utility layers scene on top of the original scene
  39405. */
  39406. render(): void;
  39407. /**
  39408. * Disposes of the renderer
  39409. */
  39410. dispose(): void;
  39411. private _updateCamera;
  39412. }
  39413. }
  39414. declare module BABYLON {
  39415. /**
  39416. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39417. */
  39418. export class Gizmo implements IDisposable {
  39419. /** The utility layer the gizmo will be added to */
  39420. gizmoLayer: UtilityLayerRenderer;
  39421. /**
  39422. * The root mesh of the gizmo
  39423. */
  39424. protected _rootMesh: Mesh;
  39425. private _attachedMesh;
  39426. /**
  39427. * Ratio for the scale of the gizmo (Default: 1)
  39428. */
  39429. scaleRatio: number;
  39430. private _tmpMatrix;
  39431. /**
  39432. * If a custom mesh has been set (Default: false)
  39433. */
  39434. protected _customMeshSet: boolean;
  39435. /**
  39436. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39437. * * When set, interactions will be enabled
  39438. */
  39439. attachedMesh: Nullable<AbstractMesh>;
  39440. /**
  39441. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39442. * @param mesh The mesh to replace the default mesh of the gizmo
  39443. */
  39444. setCustomMesh(mesh: Mesh): void;
  39445. /**
  39446. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39447. */
  39448. updateGizmoRotationToMatchAttachedMesh: boolean;
  39449. /**
  39450. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39451. */
  39452. updateGizmoPositionToMatchAttachedMesh: boolean;
  39453. /**
  39454. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39455. */
  39456. protected _updateScale: boolean;
  39457. protected _interactionsEnabled: boolean;
  39458. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39459. private _beforeRenderObserver;
  39460. /**
  39461. * Creates a gizmo
  39462. * @param gizmoLayer The utility layer the gizmo will be added to
  39463. */
  39464. constructor(
  39465. /** The utility layer the gizmo will be added to */
  39466. gizmoLayer?: UtilityLayerRenderer);
  39467. private _tempVector;
  39468. /**
  39469. * @hidden
  39470. * Updates the gizmo to match the attached mesh's position/rotation
  39471. */
  39472. protected _update(): void;
  39473. /**
  39474. * Disposes of the gizmo
  39475. */
  39476. dispose(): void;
  39477. }
  39478. }
  39479. declare module BABYLON {
  39480. /**
  39481. * Single axis drag gizmo
  39482. */
  39483. export class AxisDragGizmo extends Gizmo {
  39484. /**
  39485. * Drag behavior responsible for the gizmos dragging interactions
  39486. */
  39487. dragBehavior: PointerDragBehavior;
  39488. private _pointerObserver;
  39489. /**
  39490. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39491. */
  39492. snapDistance: number;
  39493. /**
  39494. * Event that fires each time the gizmo snaps to a new location.
  39495. * * snapDistance is the the change in distance
  39496. */
  39497. onSnapObservable: Observable<{
  39498. snapDistance: number;
  39499. }>;
  39500. /** @hidden */
  39501. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  39502. /** @hidden */
  39503. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  39504. /**
  39505. * Creates an AxisDragGizmo
  39506. * @param gizmoLayer The utility layer the gizmo will be added to
  39507. * @param dragAxis The axis which the gizmo will be able to drag on
  39508. * @param color The color of the gizmo
  39509. */
  39510. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  39511. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39512. /**
  39513. * Disposes of the gizmo
  39514. */
  39515. dispose(): void;
  39516. }
  39517. }
  39518. declare module BABYLON.Debug {
  39519. /**
  39520. * The Axes viewer will show 3 axes in a specific point in space
  39521. */
  39522. export class AxesViewer {
  39523. private _xAxis;
  39524. private _yAxis;
  39525. private _zAxis;
  39526. private _scaleLinesFactor;
  39527. private _instanced;
  39528. /**
  39529. * Gets the hosting scene
  39530. */
  39531. scene: Scene;
  39532. /**
  39533. * Gets or sets a number used to scale line length
  39534. */
  39535. scaleLines: number;
  39536. /** Gets the node hierarchy used to render x-axis */
  39537. readonly xAxis: TransformNode;
  39538. /** Gets the node hierarchy used to render y-axis */
  39539. readonly yAxis: TransformNode;
  39540. /** Gets the node hierarchy used to render z-axis */
  39541. readonly zAxis: TransformNode;
  39542. /**
  39543. * Creates a new AxesViewer
  39544. * @param scene defines the hosting scene
  39545. * @param scaleLines defines a number used to scale line length (1 by default)
  39546. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  39547. * @param xAxis defines the node hierarchy used to render the x-axis
  39548. * @param yAxis defines the node hierarchy used to render the y-axis
  39549. * @param zAxis defines the node hierarchy used to render the z-axis
  39550. */
  39551. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  39552. /**
  39553. * Force the viewer to update
  39554. * @param position defines the position of the viewer
  39555. * @param xaxis defines the x axis of the viewer
  39556. * @param yaxis defines the y axis of the viewer
  39557. * @param zaxis defines the z axis of the viewer
  39558. */
  39559. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  39560. /**
  39561. * Creates an instance of this axes viewer.
  39562. * @returns a new axes viewer with instanced meshes
  39563. */
  39564. createInstance(): AxesViewer;
  39565. /** Releases resources */
  39566. dispose(): void;
  39567. private static _SetRenderingGroupId;
  39568. }
  39569. }
  39570. declare module BABYLON.Debug {
  39571. /**
  39572. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  39573. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  39574. */
  39575. export class BoneAxesViewer extends AxesViewer {
  39576. /**
  39577. * Gets or sets the target mesh where to display the axes viewer
  39578. */
  39579. mesh: Nullable<Mesh>;
  39580. /**
  39581. * Gets or sets the target bone where to display the axes viewer
  39582. */
  39583. bone: Nullable<Bone>;
  39584. /** Gets current position */
  39585. pos: Vector3;
  39586. /** Gets direction of X axis */
  39587. xaxis: Vector3;
  39588. /** Gets direction of Y axis */
  39589. yaxis: Vector3;
  39590. /** Gets direction of Z axis */
  39591. zaxis: Vector3;
  39592. /**
  39593. * Creates a new BoneAxesViewer
  39594. * @param scene defines the hosting scene
  39595. * @param bone defines the target bone
  39596. * @param mesh defines the target mesh
  39597. * @param scaleLines defines a scaling factor for line length (1 by default)
  39598. */
  39599. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  39600. /**
  39601. * Force the viewer to update
  39602. */
  39603. update(): void;
  39604. /** Releases resources */
  39605. dispose(): void;
  39606. }
  39607. }
  39608. declare module BABYLON {
  39609. /**
  39610. * Interface used to define scene explorer extensibility option
  39611. */
  39612. export interface IExplorerExtensibilityOption {
  39613. /**
  39614. * Define the option label
  39615. */
  39616. label: string;
  39617. /**
  39618. * Defines the action to execute on click
  39619. */
  39620. action: (entity: any) => void;
  39621. }
  39622. /**
  39623. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  39624. */
  39625. export interface IExplorerExtensibilityGroup {
  39626. /**
  39627. * Defines a predicate to test if a given type mut be extended
  39628. */
  39629. predicate: (entity: any) => boolean;
  39630. /**
  39631. * Gets the list of options added to a type
  39632. */
  39633. entries: IExplorerExtensibilityOption[];
  39634. }
  39635. /**
  39636. * Interface used to define the options to use to create the Inspector
  39637. */
  39638. export interface IInspectorOptions {
  39639. /**
  39640. * Display in overlay mode (default: false)
  39641. */
  39642. overlay?: boolean;
  39643. /**
  39644. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  39645. */
  39646. globalRoot?: HTMLElement;
  39647. /**
  39648. * Display the Scene explorer
  39649. */
  39650. showExplorer?: boolean;
  39651. /**
  39652. * Display the property inspector
  39653. */
  39654. showInspector?: boolean;
  39655. /**
  39656. * Display in embed mode (both panes on the right)
  39657. */
  39658. embedMode?: boolean;
  39659. /**
  39660. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  39661. */
  39662. handleResize?: boolean;
  39663. /**
  39664. * Allow the panes to popup (default: true)
  39665. */
  39666. enablePopup?: boolean;
  39667. /**
  39668. * Allow the panes to be closed by users (default: true)
  39669. */
  39670. enableClose?: boolean;
  39671. /**
  39672. * Optional list of extensibility entries
  39673. */
  39674. explorerExtensibility?: IExplorerExtensibilityGroup[];
  39675. }
  39676. interface Scene {
  39677. /**
  39678. * @hidden
  39679. * Backing field
  39680. */
  39681. _debugLayer: DebugLayer;
  39682. /**
  39683. * Gets the debug layer (aka Inspector) associated with the scene
  39684. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39685. */
  39686. debugLayer: DebugLayer;
  39687. }
  39688. /**
  39689. * The debug layer (aka Inspector) is the go to tool in order to better understand
  39690. * what is happening in your scene
  39691. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39692. */
  39693. export class DebugLayer {
  39694. /**
  39695. * Define the url to get the inspector script from.
  39696. * By default it uses the babylonjs CDN.
  39697. * @ignoreNaming
  39698. */
  39699. static InspectorURL: string;
  39700. private _scene;
  39701. private BJSINSPECTOR;
  39702. /**
  39703. * Observable triggered when a property is changed through the inspector.
  39704. */
  39705. onPropertyChangedObservable: Observable<{
  39706. object: any;
  39707. property: string;
  39708. value: any;
  39709. initialValue: any;
  39710. }>;
  39711. /**
  39712. * Instantiates a new debug layer.
  39713. * The debug layer (aka Inspector) is the go to tool in order to better understand
  39714. * what is happening in your scene
  39715. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39716. * @param scene Defines the scene to inspect
  39717. */
  39718. constructor(scene: Scene);
  39719. /** Creates the inspector window. */
  39720. private _createInspector;
  39721. /** Get the inspector from bundle or global */
  39722. private _getGlobalInspector;
  39723. /**
  39724. * Get if the inspector is visible or not.
  39725. * @returns true if visible otherwise, false
  39726. */
  39727. isVisible(): boolean;
  39728. /**
  39729. * Hide the inspector and close its window.
  39730. */
  39731. hide(): void;
  39732. /**
  39733. * Launch the debugLayer.
  39734. * @param config Define the configuration of the inspector
  39735. */
  39736. show(config?: IInspectorOptions): void;
  39737. }
  39738. }
  39739. declare module BABYLON {
  39740. /**
  39741. * Class containing static functions to help procedurally build meshes
  39742. */
  39743. export class BoxBuilder {
  39744. /**
  39745. * Creates a box mesh
  39746. * * The parameter `size` sets the size (float) of each box side (default 1)
  39747. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  39748. * * 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)
  39749. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  39750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39751. * * 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
  39752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39753. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  39754. * @param name defines the name of the mesh
  39755. * @param options defines the options used to create the mesh
  39756. * @param scene defines the hosting scene
  39757. * @returns the box mesh
  39758. */
  39759. static CreateBox(name: string, options: {
  39760. size?: number;
  39761. width?: number;
  39762. height?: number;
  39763. depth?: number;
  39764. faceUV?: Vector4[];
  39765. faceColors?: Color4[];
  39766. sideOrientation?: number;
  39767. frontUVs?: Vector4;
  39768. backUVs?: Vector4;
  39769. updatable?: boolean;
  39770. }, scene?: Nullable<Scene>): Mesh;
  39771. }
  39772. }
  39773. declare module BABYLON {
  39774. /**
  39775. * Class containing static functions to help procedurally build meshes
  39776. */
  39777. export class SphereBuilder {
  39778. /**
  39779. * Creates a sphere mesh
  39780. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  39781. * * 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`)
  39782. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  39783. * * 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
  39784. * * 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)
  39785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39786. * * 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
  39787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39788. * @param name defines the name of the mesh
  39789. * @param options defines the options used to create the mesh
  39790. * @param scene defines the hosting scene
  39791. * @returns the sphere mesh
  39792. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  39793. */
  39794. static CreateSphere(name: string, options: {
  39795. segments?: number;
  39796. diameter?: number;
  39797. diameterX?: number;
  39798. diameterY?: number;
  39799. diameterZ?: number;
  39800. arc?: number;
  39801. slice?: number;
  39802. sideOrientation?: number;
  39803. frontUVs?: Vector4;
  39804. backUVs?: Vector4;
  39805. updatable?: boolean;
  39806. }, scene: any): Mesh;
  39807. }
  39808. }
  39809. declare module BABYLON.Debug {
  39810. /**
  39811. * Used to show the physics impostor around the specific mesh
  39812. */
  39813. export class PhysicsViewer {
  39814. /** @hidden */
  39815. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  39816. /** @hidden */
  39817. protected _meshes: Array<Nullable<AbstractMesh>>;
  39818. /** @hidden */
  39819. protected _scene: Nullable<Scene>;
  39820. /** @hidden */
  39821. protected _numMeshes: number;
  39822. /** @hidden */
  39823. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  39824. private _renderFunction;
  39825. private _utilityLayer;
  39826. private _debugBoxMesh;
  39827. private _debugSphereMesh;
  39828. private _debugMaterial;
  39829. /**
  39830. * Creates a new PhysicsViewer
  39831. * @param scene defines the hosting scene
  39832. */
  39833. constructor(scene: Scene);
  39834. /** @hidden */
  39835. protected _updateDebugMeshes(): void;
  39836. /**
  39837. * Renders a specified physic impostor
  39838. * @param impostor defines the impostor to render
  39839. * @returns the new debug mesh used to render the impostor
  39840. */
  39841. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  39842. /**
  39843. * Hides a specified physic impostor
  39844. * @param impostor defines the impostor to hide
  39845. */
  39846. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  39847. private _getDebugMaterial;
  39848. private _getDebugBoxMesh;
  39849. private _getDebugSphereMesh;
  39850. private _getDebugMesh;
  39851. /** Releases all resources */
  39852. dispose(): void;
  39853. }
  39854. }
  39855. declare module BABYLON {
  39856. /**
  39857. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  39858. * in order to better appreciate the issue one might have.
  39859. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  39860. */
  39861. export class RayHelper {
  39862. /**
  39863. * Defines the ray we are currently tryin to visualize.
  39864. */
  39865. ray: Nullable<Ray>;
  39866. private _renderPoints;
  39867. private _renderLine;
  39868. private _renderFunction;
  39869. private _scene;
  39870. private _updateToMeshFunction;
  39871. private _attachedToMesh;
  39872. private _meshSpaceDirection;
  39873. private _meshSpaceOrigin;
  39874. /**
  39875. * Helper function to create a colored helper in a scene in one line.
  39876. * @param ray Defines the ray we are currently tryin to visualize
  39877. * @param scene Defines the scene the ray is used in
  39878. * @param color Defines the color we want to see the ray in
  39879. * @returns The newly created ray helper.
  39880. */
  39881. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  39882. /**
  39883. * Instantiate a new ray helper.
  39884. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  39885. * in order to better appreciate the issue one might have.
  39886. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  39887. * @param ray Defines the ray we are currently tryin to visualize
  39888. */
  39889. constructor(ray: Ray);
  39890. /**
  39891. * Shows the ray we are willing to debug.
  39892. * @param scene Defines the scene the ray needs to be rendered in
  39893. * @param color Defines the color the ray needs to be rendered in
  39894. */
  39895. show(scene: Scene, color?: Color3): void;
  39896. /**
  39897. * Hides the ray we are debugging.
  39898. */
  39899. hide(): void;
  39900. private _render;
  39901. /**
  39902. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  39903. * @param mesh Defines the mesh we want the helper attached to
  39904. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  39905. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  39906. * @param length Defines the length of the ray
  39907. */
  39908. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  39909. /**
  39910. * Detach the ray helper from the mesh it has previously been attached to.
  39911. */
  39912. detachFromMesh(): void;
  39913. private _updateToMesh;
  39914. /**
  39915. * Dispose the helper and release its associated resources.
  39916. */
  39917. dispose(): void;
  39918. }
  39919. }
  39920. declare module BABYLON.Debug {
  39921. /**
  39922. * Class used to render a debug view of a given skeleton
  39923. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  39924. */
  39925. export class SkeletonViewer {
  39926. /** defines the skeleton to render */
  39927. skeleton: Skeleton;
  39928. /** defines the mesh attached to the skeleton */
  39929. mesh: AbstractMesh;
  39930. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  39931. autoUpdateBonesMatrices: boolean;
  39932. /** defines the rendering group id to use with the viewer */
  39933. renderingGroupId: number;
  39934. /** Gets or sets the color used to render the skeleton */
  39935. color: Color3;
  39936. private _scene;
  39937. private _debugLines;
  39938. private _debugMesh;
  39939. private _isEnabled;
  39940. private _renderFunction;
  39941. private _utilityLayer;
  39942. /**
  39943. * Returns the mesh used to render the bones
  39944. */
  39945. readonly debugMesh: Nullable<LinesMesh>;
  39946. /**
  39947. * Creates a new SkeletonViewer
  39948. * @param skeleton defines the skeleton to render
  39949. * @param mesh defines the mesh attached to the skeleton
  39950. * @param scene defines the hosting scene
  39951. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  39952. * @param renderingGroupId defines the rendering group id to use with the viewer
  39953. */
  39954. constructor(
  39955. /** defines the skeleton to render */
  39956. skeleton: Skeleton,
  39957. /** defines the mesh attached to the skeleton */
  39958. mesh: AbstractMesh, scene: Scene,
  39959. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  39960. autoUpdateBonesMatrices?: boolean,
  39961. /** defines the rendering group id to use with the viewer */
  39962. renderingGroupId?: number);
  39963. /** Gets or sets a boolean indicating if the viewer is enabled */
  39964. isEnabled: boolean;
  39965. private _getBonePosition;
  39966. private _getLinesForBonesWithLength;
  39967. private _getLinesForBonesNoLength;
  39968. /** Update the viewer to sync with current skeleton state */
  39969. update(): void;
  39970. /** Release associated resources */
  39971. dispose(): void;
  39972. }
  39973. }
  39974. declare module BABYLON {
  39975. /**
  39976. * Options to create the null engine
  39977. */
  39978. export class NullEngineOptions {
  39979. /**
  39980. * Render width (Default: 512)
  39981. */
  39982. renderWidth: number;
  39983. /**
  39984. * Render height (Default: 256)
  39985. */
  39986. renderHeight: number;
  39987. /**
  39988. * Texture size (Default: 512)
  39989. */
  39990. textureSize: number;
  39991. /**
  39992. * If delta time between frames should be constant
  39993. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39994. */
  39995. deterministicLockstep: boolean;
  39996. /**
  39997. * Maximum about of steps between frames (Default: 4)
  39998. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39999. */
  40000. lockstepMaxSteps: number;
  40001. }
  40002. /**
  40003. * The null engine class provides support for headless version of babylon.js.
  40004. * This can be used in server side scenario or for testing purposes
  40005. */
  40006. export class NullEngine extends Engine {
  40007. private _options;
  40008. /**
  40009. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40010. */
  40011. isDeterministicLockStep(): boolean;
  40012. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40013. getLockstepMaxSteps(): number;
  40014. /**
  40015. * Sets hardware scaling, used to save performance if needed
  40016. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40017. */
  40018. getHardwareScalingLevel(): number;
  40019. constructor(options?: NullEngineOptions);
  40020. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40021. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  40022. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40023. getRenderWidth(useScreen?: boolean): number;
  40024. getRenderHeight(useScreen?: boolean): number;
  40025. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40026. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40027. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  40028. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  40029. bindSamplers(effect: Effect): void;
  40030. enableEffect(effect: Effect): void;
  40031. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40032. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40033. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40034. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40035. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40036. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40037. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40038. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40039. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40040. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40041. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40042. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40043. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40044. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40045. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40046. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40047. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40048. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40049. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40050. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40051. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40052. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40053. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40054. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40055. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40056. bindBuffers(vertexBuffers: {
  40057. [key: string]: VertexBuffer;
  40058. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  40059. wipeCaches(bruteForce?: boolean): void;
  40060. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40061. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40062. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40063. /** @hidden */
  40064. _createTexture(): WebGLTexture;
  40065. /** @hidden */
  40066. _releaseTexture(texture: InternalTexture): void;
  40067. 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;
  40068. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40069. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40070. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40071. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40072. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40073. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40074. areAllEffectsReady(): boolean;
  40075. /**
  40076. * @hidden
  40077. * Get the current error code of the webGL context
  40078. * @returns the error code
  40079. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40080. */
  40081. getError(): number;
  40082. /** @hidden */
  40083. _getUnpackAlignement(): number;
  40084. /** @hidden */
  40085. _unpackFlipY(value: boolean): void;
  40086. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40087. /**
  40088. * Updates a dynamic vertex buffer.
  40089. * @param vertexBuffer the vertex buffer to update
  40090. * @param data the data used to update the vertex buffer
  40091. * @param byteOffset the byte offset of the data (optional)
  40092. * @param byteLength the byte length of the data (optional)
  40093. */
  40094. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  40095. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40096. /** @hidden */
  40097. _bindTexture(channel: number, texture: InternalTexture): void;
  40098. /** @hidden */
  40099. _releaseBuffer(buffer: WebGLBuffer): boolean;
  40100. releaseEffects(): void;
  40101. displayLoadingUI(): void;
  40102. hideLoadingUI(): void;
  40103. /** @hidden */
  40104. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40105. /** @hidden */
  40106. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40107. /** @hidden */
  40108. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40109. /** @hidden */
  40110. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40111. }
  40112. }
  40113. declare module BABYLON {
  40114. /** @hidden */
  40115. export class _OcclusionDataStorage {
  40116. /** @hidden */
  40117. occlusionInternalRetryCounter: number;
  40118. /** @hidden */
  40119. isOcclusionQueryInProgress: boolean;
  40120. /** @hidden */
  40121. isOccluded: boolean;
  40122. /** @hidden */
  40123. occlusionRetryCount: number;
  40124. /** @hidden */
  40125. occlusionType: number;
  40126. /** @hidden */
  40127. occlusionQueryAlgorithmType: number;
  40128. }
  40129. interface Engine {
  40130. /**
  40131. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40132. * @return the new query
  40133. */
  40134. createQuery(): WebGLQuery;
  40135. /**
  40136. * Delete and release a webGL query
  40137. * @param query defines the query to delete
  40138. * @return the current engine
  40139. */
  40140. deleteQuery(query: WebGLQuery): Engine;
  40141. /**
  40142. * Check if a given query has resolved and got its value
  40143. * @param query defines the query to check
  40144. * @returns true if the query got its value
  40145. */
  40146. isQueryResultAvailable(query: WebGLQuery): boolean;
  40147. /**
  40148. * Gets the value of a given query
  40149. * @param query defines the query to check
  40150. * @returns the value of the query
  40151. */
  40152. getQueryResult(query: WebGLQuery): number;
  40153. /**
  40154. * Initiates an occlusion query
  40155. * @param algorithmType defines the algorithm to use
  40156. * @param query defines the query to use
  40157. * @returns the current engine
  40158. * @see http://doc.babylonjs.com/features/occlusionquery
  40159. */
  40160. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40161. /**
  40162. * Ends an occlusion query
  40163. * @see http://doc.babylonjs.com/features/occlusionquery
  40164. * @param algorithmType defines the algorithm to use
  40165. * @returns the current engine
  40166. */
  40167. endOcclusionQuery(algorithmType: number): Engine;
  40168. /**
  40169. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40170. * Please note that only one query can be issued at a time
  40171. * @returns a time token used to track the time span
  40172. */
  40173. startTimeQuery(): Nullable<_TimeToken>;
  40174. /**
  40175. * Ends a time query
  40176. * @param token defines the token used to measure the time span
  40177. * @returns the time spent (in ns)
  40178. */
  40179. endTimeQuery(token: _TimeToken): int;
  40180. /** @hidden */
  40181. _currentNonTimestampToken: Nullable<_TimeToken>;
  40182. /** @hidden */
  40183. _createTimeQuery(): WebGLQuery;
  40184. /** @hidden */
  40185. _deleteTimeQuery(query: WebGLQuery): void;
  40186. /** @hidden */
  40187. _getGlAlgorithmType(algorithmType: number): number;
  40188. /** @hidden */
  40189. _getTimeQueryResult(query: WebGLQuery): any;
  40190. /** @hidden */
  40191. _getTimeQueryAvailability(query: WebGLQuery): any;
  40192. }
  40193. interface AbstractMesh {
  40194. /**
  40195. * Backing filed
  40196. * @hidden
  40197. */
  40198. __occlusionDataStorage: _OcclusionDataStorage;
  40199. /**
  40200. * Access property
  40201. * @hidden
  40202. */
  40203. _occlusionDataStorage: _OcclusionDataStorage;
  40204. /**
  40205. * 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.
  40206. * The default value is -1 which means don't break the query and wait till the result
  40207. * @see http://doc.babylonjs.com/features/occlusionquery
  40208. */
  40209. occlusionRetryCount: number;
  40210. /**
  40211. * 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:
  40212. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40213. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40214. * * 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.
  40215. * @see http://doc.babylonjs.com/features/occlusionquery
  40216. */
  40217. occlusionType: number;
  40218. /**
  40219. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40220. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40221. * * 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.
  40222. * @see http://doc.babylonjs.com/features/occlusionquery
  40223. */
  40224. occlusionQueryAlgorithmType: number;
  40225. /**
  40226. * 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
  40227. * @see http://doc.babylonjs.com/features/occlusionquery
  40228. */
  40229. isOccluded: boolean;
  40230. /**
  40231. * Flag to check the progress status of the query
  40232. * @see http://doc.babylonjs.com/features/occlusionquery
  40233. */
  40234. isOcclusionQueryInProgress: boolean;
  40235. }
  40236. }
  40237. declare module BABYLON {
  40238. /** @hidden */
  40239. export var _forceTransformFeedbackToBundle: boolean;
  40240. interface Engine {
  40241. /**
  40242. * Creates a webGL transform feedback object
  40243. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40244. * @returns the webGL transform feedback object
  40245. */
  40246. createTransformFeedback(): WebGLTransformFeedback;
  40247. /**
  40248. * Delete a webGL transform feedback object
  40249. * @param value defines the webGL transform feedback object to delete
  40250. */
  40251. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40252. /**
  40253. * Bind a webGL transform feedback object to the webgl context
  40254. * @param value defines the webGL transform feedback object to bind
  40255. */
  40256. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40257. /**
  40258. * Begins a transform feedback operation
  40259. * @param usePoints defines if points or triangles must be used
  40260. */
  40261. beginTransformFeedback(usePoints: boolean): void;
  40262. /**
  40263. * Ends a transform feedback operation
  40264. */
  40265. endTransformFeedback(): void;
  40266. /**
  40267. * Specify the varyings to use with transform feedback
  40268. * @param program defines the associated webGL program
  40269. * @param value defines the list of strings representing the varying names
  40270. */
  40271. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40272. /**
  40273. * Bind a webGL buffer for a transform feedback operation
  40274. * @param value defines the webGL buffer to bind
  40275. */
  40276. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  40277. }
  40278. }
  40279. declare module BABYLON {
  40280. /**
  40281. * Gather the list of clipboard event types as constants.
  40282. */
  40283. export class ClipboardEventTypes {
  40284. /**
  40285. * The clipboard event is fired when a copy command is active (pressed).
  40286. */
  40287. static readonly COPY: number;
  40288. /**
  40289. * The clipboard event is fired when a cut command is active (pressed).
  40290. */
  40291. static readonly CUT: number;
  40292. /**
  40293. * The clipboard event is fired when a paste command is active (pressed).
  40294. */
  40295. static readonly PASTE: number;
  40296. }
  40297. /**
  40298. * This class is used to store clipboard related info for the onClipboardObservable event.
  40299. */
  40300. export class ClipboardInfo {
  40301. /**
  40302. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40303. */
  40304. type: number;
  40305. /**
  40306. * Defines the related dom event
  40307. */
  40308. event: ClipboardEvent;
  40309. /**
  40310. *Creates an instance of ClipboardInfo.
  40311. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  40312. * @param event Defines the related dom event
  40313. */
  40314. constructor(
  40315. /**
  40316. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40317. */
  40318. type: number,
  40319. /**
  40320. * Defines the related dom event
  40321. */
  40322. event: ClipboardEvent);
  40323. /**
  40324. * Get the clipboard event's type from the keycode.
  40325. * @param keyCode Defines the keyCode for the current keyboard event.
  40326. * @return {number}
  40327. */
  40328. static GetTypeFromCharacter(keyCode: number): number;
  40329. }
  40330. }
  40331. declare module BABYLON {
  40332. /**
  40333. * Class used to represent data loading progression
  40334. */
  40335. export class SceneLoaderProgressEvent {
  40336. /** defines if data length to load can be evaluated */
  40337. readonly lengthComputable: boolean;
  40338. /** defines the loaded data length */
  40339. readonly loaded: number;
  40340. /** defines the data length to load */
  40341. readonly total: number;
  40342. /**
  40343. * Create a new progress event
  40344. * @param lengthComputable defines if data length to load can be evaluated
  40345. * @param loaded defines the loaded data length
  40346. * @param total defines the data length to load
  40347. */
  40348. constructor(
  40349. /** defines if data length to load can be evaluated */
  40350. lengthComputable: boolean,
  40351. /** defines the loaded data length */
  40352. loaded: number,
  40353. /** defines the data length to load */
  40354. total: number);
  40355. /**
  40356. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40357. * @param event defines the source event
  40358. * @returns a new SceneLoaderProgressEvent
  40359. */
  40360. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40361. }
  40362. /**
  40363. * Interface used by SceneLoader plugins to define supported file extensions
  40364. */
  40365. export interface ISceneLoaderPluginExtensions {
  40366. /**
  40367. * Defines the list of supported extensions
  40368. */
  40369. [extension: string]: {
  40370. isBinary: boolean;
  40371. };
  40372. }
  40373. /**
  40374. * Interface used by SceneLoader plugin factory
  40375. */
  40376. export interface ISceneLoaderPluginFactory {
  40377. /**
  40378. * Defines the name of the factory
  40379. */
  40380. name: string;
  40381. /**
  40382. * Function called to create a new plugin
  40383. * @return the new plugin
  40384. */
  40385. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40386. /**
  40387. * Boolean indicating if the plugin can direct load specific data
  40388. */
  40389. canDirectLoad?: (data: string) => boolean;
  40390. }
  40391. /**
  40392. * Interface used to define a SceneLoader plugin
  40393. */
  40394. export interface ISceneLoaderPlugin {
  40395. /**
  40396. * The friendly name of this plugin.
  40397. */
  40398. name: string;
  40399. /**
  40400. * The file extensions supported by this plugin.
  40401. */
  40402. extensions: string | ISceneLoaderPluginExtensions;
  40403. /**
  40404. * Import meshes into a scene.
  40405. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40406. * @param scene The scene to import into
  40407. * @param data The data to import
  40408. * @param rootUrl The root url for scene and resources
  40409. * @param meshes The meshes array to import into
  40410. * @param particleSystems The particle systems array to import into
  40411. * @param skeletons The skeletons array to import into
  40412. * @param onError The callback when import fails
  40413. * @returns True if successful or false otherwise
  40414. */
  40415. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  40416. /**
  40417. * Load into a scene.
  40418. * @param scene The scene to load into
  40419. * @param data The data to import
  40420. * @param rootUrl The root url for scene and resources
  40421. * @param onError The callback when import fails
  40422. * @returns true if successful or false otherwise
  40423. */
  40424. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  40425. /**
  40426. * The callback that returns true if the data can be directly loaded.
  40427. */
  40428. canDirectLoad?: (data: string) => boolean;
  40429. /**
  40430. * The callback that allows custom handling of the root url based on the response url.
  40431. */
  40432. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40433. /**
  40434. * Load into an asset container.
  40435. * @param scene The scene to load into
  40436. * @param data The data to import
  40437. * @param rootUrl The root url for scene and resources
  40438. * @param onError The callback when import fails
  40439. * @returns The loaded asset container
  40440. */
  40441. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  40442. }
  40443. /**
  40444. * Interface used to define an async SceneLoader plugin
  40445. */
  40446. export interface ISceneLoaderPluginAsync {
  40447. /**
  40448. * The friendly name of this plugin.
  40449. */
  40450. name: string;
  40451. /**
  40452. * The file extensions supported by this plugin.
  40453. */
  40454. extensions: string | ISceneLoaderPluginExtensions;
  40455. /**
  40456. * Import meshes into a scene.
  40457. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40458. * @param scene The scene to import into
  40459. * @param data The data to import
  40460. * @param rootUrl The root url for scene and resources
  40461. * @param onProgress The callback when the load progresses
  40462. * @param fileName Defines the name of the file to load
  40463. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  40464. */
  40465. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  40466. meshes: AbstractMesh[];
  40467. particleSystems: IParticleSystem[];
  40468. skeletons: Skeleton[];
  40469. animationGroups: AnimationGroup[];
  40470. }>;
  40471. /**
  40472. * Load into a scene.
  40473. * @param scene The scene to load into
  40474. * @param data The data to import
  40475. * @param rootUrl The root url for scene and resources
  40476. * @param onProgress The callback when the load progresses
  40477. * @param fileName Defines the name of the file to load
  40478. * @returns Nothing
  40479. */
  40480. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  40481. /**
  40482. * The callback that returns true if the data can be directly loaded.
  40483. */
  40484. canDirectLoad?: (data: string) => boolean;
  40485. /**
  40486. * The callback that allows custom handling of the root url based on the response url.
  40487. */
  40488. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40489. /**
  40490. * Load into an asset container.
  40491. * @param scene The scene to load into
  40492. * @param data The data to import
  40493. * @param rootUrl The root url for scene and resources
  40494. * @param onProgress The callback when the load progresses
  40495. * @param fileName Defines the name of the file to load
  40496. * @returns The loaded asset container
  40497. */
  40498. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  40499. }
  40500. /**
  40501. * Class used to load scene from various file formats using registered plugins
  40502. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  40503. */
  40504. export class SceneLoader {
  40505. /**
  40506. * No logging while loading
  40507. */
  40508. static readonly NO_LOGGING: number;
  40509. /**
  40510. * Minimal logging while loading
  40511. */
  40512. static readonly MINIMAL_LOGGING: number;
  40513. /**
  40514. * Summary logging while loading
  40515. */
  40516. static readonly SUMMARY_LOGGING: number;
  40517. /**
  40518. * Detailled logging while loading
  40519. */
  40520. static readonly DETAILED_LOGGING: number;
  40521. /**
  40522. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  40523. */
  40524. static ForceFullSceneLoadingForIncremental: boolean;
  40525. /**
  40526. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  40527. */
  40528. static ShowLoadingScreen: boolean;
  40529. /**
  40530. * Defines the current logging level (while loading the scene)
  40531. * @ignorenaming
  40532. */
  40533. static loggingLevel: number;
  40534. /**
  40535. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  40536. */
  40537. static CleanBoneMatrixWeights: boolean;
  40538. /**
  40539. * Event raised when a plugin is used to load a scene
  40540. */
  40541. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  40542. private static _registeredPlugins;
  40543. private static _getDefaultPlugin;
  40544. private static _getPluginForExtension;
  40545. private static _getPluginForDirectLoad;
  40546. private static _getPluginForFilename;
  40547. private static _getDirectLoad;
  40548. private static _loadData;
  40549. private static _getFileInfo;
  40550. /**
  40551. * Gets a plugin that can load the given extension
  40552. * @param extension defines the extension to load
  40553. * @returns a plugin or null if none works
  40554. */
  40555. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  40556. /**
  40557. * Gets a boolean indicating that the given extension can be loaded
  40558. * @param extension defines the extension to load
  40559. * @returns true if the extension is supported
  40560. */
  40561. static IsPluginForExtensionAvailable(extension: string): boolean;
  40562. /**
  40563. * Adds a new plugin to the list of registered plugins
  40564. * @param plugin defines the plugin to add
  40565. */
  40566. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  40567. /**
  40568. * Import meshes into a scene
  40569. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40570. * @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)
  40571. * @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)
  40572. * @param scene the instance of BABYLON.Scene to append to
  40573. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  40574. * @param onProgress a callback with a progress event for each file being loaded
  40575. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40576. * @param pluginExtension the extension used to determine the plugin
  40577. * @returns The loaded plugin
  40578. */
  40579. 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>;
  40580. /**
  40581. * Import meshes into a scene
  40582. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40583. * @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)
  40584. * @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)
  40585. * @param scene the instance of BABYLON.Scene to append to
  40586. * @param onProgress a callback with a progress event for each file being loaded
  40587. * @param pluginExtension the extension used to determine the plugin
  40588. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  40589. */
  40590. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  40591. meshes: AbstractMesh[];
  40592. particleSystems: IParticleSystem[];
  40593. skeletons: Skeleton[];
  40594. animationGroups: AnimationGroup[];
  40595. }>;
  40596. /**
  40597. * Load a scene
  40598. * @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)
  40599. * @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)
  40600. * @param engine is the instance of BABYLON.Engine to use to create the scene
  40601. * @param onSuccess a callback with the scene when import succeeds
  40602. * @param onProgress a callback with a progress event for each file being loaded
  40603. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40604. * @param pluginExtension the extension used to determine the plugin
  40605. * @returns The loaded plugin
  40606. */
  40607. 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>;
  40608. /**
  40609. * Load a scene
  40610. * @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)
  40611. * @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)
  40612. * @param engine is the instance of BABYLON.Engine to use to create the scene
  40613. * @param onProgress a callback with a progress event for each file being loaded
  40614. * @param pluginExtension the extension used to determine the plugin
  40615. * @returns The loaded scene
  40616. */
  40617. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  40618. /**
  40619. * Append a scene
  40620. * @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)
  40621. * @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)
  40622. * @param scene is the instance of BABYLON.Scene to append to
  40623. * @param onSuccess a callback with the scene when import succeeds
  40624. * @param onProgress a callback with a progress event for each file being loaded
  40625. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40626. * @param pluginExtension the extension used to determine the plugin
  40627. * @returns The loaded plugin
  40628. */
  40629. 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>;
  40630. /**
  40631. * Append a scene
  40632. * @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)
  40633. * @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)
  40634. * @param scene is the instance of BABYLON.Scene to append to
  40635. * @param onProgress a callback with a progress event for each file being loaded
  40636. * @param pluginExtension the extension used to determine the plugin
  40637. * @returns The given scene
  40638. */
  40639. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  40640. /**
  40641. * Load a scene into an asset container
  40642. * @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)
  40643. * @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)
  40644. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40645. * @param onSuccess a callback with the scene when import succeeds
  40646. * @param onProgress a callback with a progress event for each file being loaded
  40647. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40648. * @param pluginExtension the extension used to determine the plugin
  40649. * @returns The loaded plugin
  40650. */
  40651. 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>;
  40652. /**
  40653. * Load a scene into an asset container
  40654. * @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)
  40655. * @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)
  40656. * @param scene is the instance of Scene to append to
  40657. * @param onProgress a callback with a progress event for each file being loaded
  40658. * @param pluginExtension the extension used to determine the plugin
  40659. * @returns The loaded asset container
  40660. */
  40661. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  40662. }
  40663. }
  40664. declare module BABYLON {
  40665. /**
  40666. * Google Daydream controller
  40667. */
  40668. export class DaydreamController extends WebVRController {
  40669. /**
  40670. * Base Url for the controller model.
  40671. */
  40672. static MODEL_BASE_URL: string;
  40673. /**
  40674. * File name for the controller model.
  40675. */
  40676. static MODEL_FILENAME: string;
  40677. /**
  40678. * Gamepad Id prefix used to identify Daydream Controller.
  40679. */
  40680. static readonly GAMEPAD_ID_PREFIX: string;
  40681. /**
  40682. * Creates a new DaydreamController from a gamepad
  40683. * @param vrGamepad the gamepad that the controller should be created from
  40684. */
  40685. constructor(vrGamepad: any);
  40686. /**
  40687. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40688. * @param scene scene in which to add meshes
  40689. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40690. */
  40691. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40692. /**
  40693. * Called once for each button that changed state since the last frame
  40694. * @param buttonIdx Which button index changed
  40695. * @param state New state of the button
  40696. * @param changes Which properties on the state changed since last frame
  40697. */
  40698. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40699. }
  40700. }
  40701. declare module BABYLON {
  40702. /**
  40703. * Gear VR Controller
  40704. */
  40705. export class GearVRController extends WebVRController {
  40706. /**
  40707. * Base Url for the controller model.
  40708. */
  40709. static MODEL_BASE_URL: string;
  40710. /**
  40711. * File name for the controller model.
  40712. */
  40713. static MODEL_FILENAME: string;
  40714. /**
  40715. * Gamepad Id prefix used to identify this controller.
  40716. */
  40717. static readonly GAMEPAD_ID_PREFIX: string;
  40718. private readonly _buttonIndexToObservableNameMap;
  40719. /**
  40720. * Creates a new GearVRController from a gamepad
  40721. * @param vrGamepad the gamepad that the controller should be created from
  40722. */
  40723. constructor(vrGamepad: any);
  40724. /**
  40725. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40726. * @param scene scene in which to add meshes
  40727. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40728. */
  40729. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40730. /**
  40731. * Called once for each button that changed state since the last frame
  40732. * @param buttonIdx Which button index changed
  40733. * @param state New state of the button
  40734. * @param changes Which properties on the state changed since last frame
  40735. */
  40736. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40737. }
  40738. }
  40739. declare module BABYLON {
  40740. /**
  40741. * Generic Controller
  40742. */
  40743. export class GenericController extends WebVRController {
  40744. /**
  40745. * Base Url for the controller model.
  40746. */
  40747. static readonly MODEL_BASE_URL: string;
  40748. /**
  40749. * File name for the controller model.
  40750. */
  40751. static readonly MODEL_FILENAME: string;
  40752. /**
  40753. * Creates a new GenericController from a gamepad
  40754. * @param vrGamepad the gamepad that the controller should be created from
  40755. */
  40756. constructor(vrGamepad: any);
  40757. /**
  40758. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40759. * @param scene scene in which to add meshes
  40760. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40761. */
  40762. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40763. /**
  40764. * Called once for each button that changed state since the last frame
  40765. * @param buttonIdx Which button index changed
  40766. * @param state New state of the button
  40767. * @param changes Which properties on the state changed since last frame
  40768. */
  40769. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40770. }
  40771. }
  40772. declare module BABYLON {
  40773. /**
  40774. * Oculus Touch Controller
  40775. */
  40776. export class OculusTouchController extends WebVRController {
  40777. /**
  40778. * Base Url for the controller model.
  40779. */
  40780. static MODEL_BASE_URL: string;
  40781. /**
  40782. * File name for the left controller model.
  40783. */
  40784. static MODEL_LEFT_FILENAME: string;
  40785. /**
  40786. * File name for the right controller model.
  40787. */
  40788. static MODEL_RIGHT_FILENAME: string;
  40789. /**
  40790. * Fired when the secondary trigger on this controller is modified
  40791. */
  40792. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  40793. /**
  40794. * Fired when the thumb rest on this controller is modified
  40795. */
  40796. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  40797. /**
  40798. * Creates a new OculusTouchController from a gamepad
  40799. * @param vrGamepad the gamepad that the controller should be created from
  40800. */
  40801. constructor(vrGamepad: any);
  40802. /**
  40803. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40804. * @param scene scene in which to add meshes
  40805. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40806. */
  40807. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40808. /**
  40809. * Fired when the A button on this controller is modified
  40810. */
  40811. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40812. /**
  40813. * Fired when the B button on this controller is modified
  40814. */
  40815. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40816. /**
  40817. * Fired when the X button on this controller is modified
  40818. */
  40819. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40820. /**
  40821. * Fired when the Y button on this controller is modified
  40822. */
  40823. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40824. /**
  40825. * Called once for each button that changed state since the last frame
  40826. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  40827. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  40828. * 2) secondary trigger (same)
  40829. * 3) A (right) X (left), touch, pressed = value
  40830. * 4) B / Y
  40831. * 5) thumb rest
  40832. * @param buttonIdx Which button index changed
  40833. * @param state New state of the button
  40834. * @param changes Which properties on the state changed since last frame
  40835. */
  40836. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40837. }
  40838. }
  40839. declare module BABYLON {
  40840. /**
  40841. * Vive Controller
  40842. */
  40843. export class ViveController extends WebVRController {
  40844. /**
  40845. * Base Url for the controller model.
  40846. */
  40847. static MODEL_BASE_URL: string;
  40848. /**
  40849. * File name for the controller model.
  40850. */
  40851. static MODEL_FILENAME: string;
  40852. /**
  40853. * Creates a new ViveController from a gamepad
  40854. * @param vrGamepad the gamepad that the controller should be created from
  40855. */
  40856. constructor(vrGamepad: any);
  40857. /**
  40858. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40859. * @param scene scene in which to add meshes
  40860. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40861. */
  40862. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40863. /**
  40864. * Fired when the left button on this controller is modified
  40865. */
  40866. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40867. /**
  40868. * Fired when the right button on this controller is modified
  40869. */
  40870. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40871. /**
  40872. * Fired when the menu button on this controller is modified
  40873. */
  40874. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40875. /**
  40876. * Called once for each button that changed state since the last frame
  40877. * Vive mapping:
  40878. * 0: touchpad
  40879. * 1: trigger
  40880. * 2: left AND right buttons
  40881. * 3: menu button
  40882. * @param buttonIdx Which button index changed
  40883. * @param state New state of the button
  40884. * @param changes Which properties on the state changed since last frame
  40885. */
  40886. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40887. }
  40888. }
  40889. declare module BABYLON {
  40890. /**
  40891. * Defines the WindowsMotionController object that the state of the windows motion controller
  40892. */
  40893. export class WindowsMotionController extends WebVRController {
  40894. /**
  40895. * The base url used to load the left and right controller models
  40896. */
  40897. static MODEL_BASE_URL: string;
  40898. /**
  40899. * The name of the left controller model file
  40900. */
  40901. static MODEL_LEFT_FILENAME: string;
  40902. /**
  40903. * The name of the right controller model file
  40904. */
  40905. static MODEL_RIGHT_FILENAME: string;
  40906. /**
  40907. * The controller name prefix for this controller type
  40908. */
  40909. static readonly GAMEPAD_ID_PREFIX: string;
  40910. /**
  40911. * The controller id pattern for this controller type
  40912. */
  40913. private static readonly GAMEPAD_ID_PATTERN;
  40914. private _loadedMeshInfo;
  40915. private readonly _mapping;
  40916. /**
  40917. * Fired when the trackpad on this controller is clicked
  40918. */
  40919. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  40920. /**
  40921. * Fired when the trackpad on this controller is modified
  40922. */
  40923. onTrackpadValuesChangedObservable: Observable<StickValues>;
  40924. /**
  40925. * The current x and y values of this controller's trackpad
  40926. */
  40927. trackpad: StickValues;
  40928. /**
  40929. * Creates a new WindowsMotionController from a gamepad
  40930. * @param vrGamepad the gamepad that the controller should be created from
  40931. */
  40932. constructor(vrGamepad: any);
  40933. /**
  40934. * Fired when the trigger on this controller is modified
  40935. */
  40936. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40937. /**
  40938. * Fired when the menu button on this controller is modified
  40939. */
  40940. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40941. /**
  40942. * Fired when the grip button on this controller is modified
  40943. */
  40944. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40945. /**
  40946. * Fired when the thumbstick button on this controller is modified
  40947. */
  40948. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40949. /**
  40950. * Fired when the touchpad button on this controller is modified
  40951. */
  40952. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40953. /**
  40954. * Fired when the touchpad values on this controller are modified
  40955. */
  40956. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  40957. private _updateTrackpad;
  40958. /**
  40959. * Called once per frame by the engine.
  40960. */
  40961. update(): void;
  40962. /**
  40963. * Called once for each button that changed state since the last frame
  40964. * @param buttonIdx Which button index changed
  40965. * @param state New state of the button
  40966. * @param changes Which properties on the state changed since last frame
  40967. */
  40968. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40969. /**
  40970. * Moves the buttons on the controller mesh based on their current state
  40971. * @param buttonName the name of the button to move
  40972. * @param buttonValue the value of the button which determines the buttons new position
  40973. */
  40974. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  40975. /**
  40976. * Moves the axis on the controller mesh based on its current state
  40977. * @param axis the index of the axis
  40978. * @param axisValue the value of the axis which determines the meshes new position
  40979. * @hidden
  40980. */
  40981. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  40982. /**
  40983. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40984. * @param scene scene in which to add meshes
  40985. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40986. */
  40987. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  40988. /**
  40989. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  40990. * can be transformed by button presses and axes values, based on this._mapping.
  40991. *
  40992. * @param scene scene in which the meshes exist
  40993. * @param meshes list of meshes that make up the controller model to process
  40994. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  40995. */
  40996. private processModel;
  40997. private createMeshInfo;
  40998. /**
  40999. * Gets the ray of the controller in the direction the controller is pointing
  41000. * @param length the length the resulting ray should be
  41001. * @returns a ray in the direction the controller is pointing
  41002. */
  41003. getForwardRay(length?: number): Ray;
  41004. /**
  41005. * Disposes of the controller
  41006. */
  41007. dispose(): void;
  41008. }
  41009. }
  41010. declare module BABYLON {
  41011. /**
  41012. * Single axis scale gizmo
  41013. */
  41014. export class AxisScaleGizmo extends Gizmo {
  41015. private _coloredMaterial;
  41016. /**
  41017. * Drag behavior responsible for the gizmos dragging interactions
  41018. */
  41019. dragBehavior: PointerDragBehavior;
  41020. private _pointerObserver;
  41021. /**
  41022. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41023. */
  41024. snapDistance: number;
  41025. /**
  41026. * Event that fires each time the gizmo snaps to a new location.
  41027. * * snapDistance is the the change in distance
  41028. */
  41029. onSnapObservable: Observable<{
  41030. snapDistance: number;
  41031. }>;
  41032. /**
  41033. * If the scaling operation should be done on all axis (default: false)
  41034. */
  41035. uniformScaling: boolean;
  41036. /**
  41037. * Creates an AxisScaleGizmo
  41038. * @param gizmoLayer The utility layer the gizmo will be added to
  41039. * @param dragAxis The axis which the gizmo will be able to scale on
  41040. * @param color The color of the gizmo
  41041. */
  41042. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41043. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41044. /**
  41045. * Disposes of the gizmo
  41046. */
  41047. dispose(): void;
  41048. /**
  41049. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41050. * @param mesh The mesh to replace the default mesh of the gizmo
  41051. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41052. */
  41053. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41054. }
  41055. }
  41056. declare module BABYLON {
  41057. /**
  41058. * Bounding box gizmo
  41059. */
  41060. export class BoundingBoxGizmo extends Gizmo {
  41061. private _lineBoundingBox;
  41062. private _rotateSpheresParent;
  41063. private _scaleBoxesParent;
  41064. private _boundingDimensions;
  41065. private _renderObserver;
  41066. private _pointerObserver;
  41067. private _scaleDragSpeed;
  41068. private _tmpQuaternion;
  41069. private _tmpVector;
  41070. private _tmpRotationMatrix;
  41071. /**
  41072. * 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)
  41073. */
  41074. ignoreChildren: boolean;
  41075. /**
  41076. * 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)
  41077. */
  41078. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41079. /**
  41080. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41081. */
  41082. rotationSphereSize: number;
  41083. /**
  41084. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41085. */
  41086. scaleBoxSize: number;
  41087. /**
  41088. * 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)
  41089. */
  41090. fixedDragMeshScreenSize: boolean;
  41091. /**
  41092. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41093. */
  41094. fixedDragMeshScreenSizeDistanceFactor: number;
  41095. /**
  41096. * Fired when a rotation sphere or scale box is dragged
  41097. */
  41098. onDragStartObservable: Observable<{}>;
  41099. /**
  41100. * Fired when a scale box is dragged
  41101. */
  41102. onScaleBoxDragObservable: Observable<{}>;
  41103. /**
  41104. * Fired when a scale box drag is ended
  41105. */
  41106. onScaleBoxDragEndObservable: Observable<{}>;
  41107. /**
  41108. * Fired when a rotation sphere is dragged
  41109. */
  41110. onRotationSphereDragObservable: Observable<{}>;
  41111. /**
  41112. * Fired when a rotation sphere drag is ended
  41113. */
  41114. onRotationSphereDragEndObservable: Observable<{}>;
  41115. /**
  41116. * 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)
  41117. */
  41118. scalePivot: Nullable<Vector3>;
  41119. private _anchorMesh;
  41120. private _existingMeshScale;
  41121. private _dragMesh;
  41122. private pointerDragBehavior;
  41123. /**
  41124. * Creates an BoundingBoxGizmo
  41125. * @param gizmoLayer The utility layer the gizmo will be added to
  41126. * @param color The color of the gizmo
  41127. */
  41128. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41129. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41130. private _selectNode;
  41131. /**
  41132. * Updates the bounding box information for the Gizmo
  41133. */
  41134. updateBoundingBox(): void;
  41135. private _updateRotationSpheres;
  41136. private _updateScaleBoxes;
  41137. /**
  41138. * Enables rotation on the specified axis and disables rotation on the others
  41139. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41140. */
  41141. setEnabledRotationAxis(axis: string): void;
  41142. /**
  41143. * Enables/disables scaling
  41144. * @param enable if scaling should be enabled
  41145. */
  41146. setEnabledScaling(enable: boolean): void;
  41147. private _updateDummy;
  41148. /**
  41149. * Enables a pointer drag behavior on the bounding box of the gizmo
  41150. */
  41151. enableDragBehavior(): void;
  41152. /**
  41153. * Disposes of the gizmo
  41154. */
  41155. dispose(): void;
  41156. /**
  41157. * 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)
  41158. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41159. * @returns the bounding box mesh with the passed in mesh as a child
  41160. */
  41161. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41162. /**
  41163. * CustomMeshes are not supported by this gizmo
  41164. * @param mesh The mesh to replace the default mesh of the gizmo
  41165. */
  41166. setCustomMesh(mesh: Mesh): void;
  41167. }
  41168. }
  41169. declare module BABYLON {
  41170. /**
  41171. * Single plane rotation gizmo
  41172. */
  41173. export class PlaneRotationGizmo extends Gizmo {
  41174. /**
  41175. * Drag behavior responsible for the gizmos dragging interactions
  41176. */
  41177. dragBehavior: PointerDragBehavior;
  41178. private _pointerObserver;
  41179. /**
  41180. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41181. */
  41182. snapDistance: number;
  41183. /**
  41184. * Event that fires each time the gizmo snaps to a new location.
  41185. * * snapDistance is the the change in distance
  41186. */
  41187. onSnapObservable: Observable<{
  41188. snapDistance: number;
  41189. }>;
  41190. /**
  41191. * Creates a PlaneRotationGizmo
  41192. * @param gizmoLayer The utility layer the gizmo will be added to
  41193. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41194. * @param color The color of the gizmo
  41195. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41196. */
  41197. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41198. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41199. /**
  41200. * Disposes of the gizmo
  41201. */
  41202. dispose(): void;
  41203. }
  41204. }
  41205. declare module BABYLON {
  41206. /**
  41207. * Gizmo that enables rotating a mesh along 3 axis
  41208. */
  41209. export class RotationGizmo extends Gizmo {
  41210. /**
  41211. * Internal gizmo used for interactions on the x axis
  41212. */
  41213. xGizmo: PlaneRotationGizmo;
  41214. /**
  41215. * Internal gizmo used for interactions on the y axis
  41216. */
  41217. yGizmo: PlaneRotationGizmo;
  41218. /**
  41219. * Internal gizmo used for interactions on the z axis
  41220. */
  41221. zGizmo: PlaneRotationGizmo;
  41222. /** Fires an event when any of it's sub gizmos are dragged */
  41223. onDragStartObservable: Observable<{}>;
  41224. /** Fires an event when any of it's sub gizmos are released from dragging */
  41225. onDragEndObservable: Observable<{}>;
  41226. attachedMesh: Nullable<AbstractMesh>;
  41227. /**
  41228. * Creates a RotationGizmo
  41229. * @param gizmoLayer The utility layer the gizmo will be added to
  41230. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41231. */
  41232. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41233. updateGizmoRotationToMatchAttachedMesh: boolean;
  41234. /**
  41235. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41236. */
  41237. snapDistance: number;
  41238. /**
  41239. * Ratio for the scale of the gizmo (Default: 1)
  41240. */
  41241. scaleRatio: number;
  41242. /**
  41243. * Disposes of the gizmo
  41244. */
  41245. dispose(): void;
  41246. /**
  41247. * CustomMeshes are not supported by this gizmo
  41248. * @param mesh The mesh to replace the default mesh of the gizmo
  41249. */
  41250. setCustomMesh(mesh: Mesh): void;
  41251. }
  41252. }
  41253. declare module BABYLON {
  41254. /**
  41255. * Gizmo that enables dragging a mesh along 3 axis
  41256. */
  41257. export class PositionGizmo extends Gizmo {
  41258. /**
  41259. * Internal gizmo used for interactions on the x axis
  41260. */
  41261. xGizmo: AxisDragGizmo;
  41262. /**
  41263. * Internal gizmo used for interactions on the y axis
  41264. */
  41265. yGizmo: AxisDragGizmo;
  41266. /**
  41267. * Internal gizmo used for interactions on the z axis
  41268. */
  41269. zGizmo: AxisDragGizmo;
  41270. /** Fires an event when any of it's sub gizmos are dragged */
  41271. onDragStartObservable: Observable<{}>;
  41272. /** Fires an event when any of it's sub gizmos are released from dragging */
  41273. onDragEndObservable: Observable<{}>;
  41274. attachedMesh: Nullable<AbstractMesh>;
  41275. /**
  41276. * Creates a PositionGizmo
  41277. * @param gizmoLayer The utility layer the gizmo will be added to
  41278. */
  41279. constructor(gizmoLayer?: UtilityLayerRenderer);
  41280. updateGizmoRotationToMatchAttachedMesh: boolean;
  41281. /**
  41282. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41283. */
  41284. snapDistance: number;
  41285. /**
  41286. * Ratio for the scale of the gizmo (Default: 1)
  41287. */
  41288. scaleRatio: number;
  41289. /**
  41290. * Disposes of the gizmo
  41291. */
  41292. dispose(): void;
  41293. /**
  41294. * CustomMeshes are not supported by this gizmo
  41295. * @param mesh The mesh to replace the default mesh of the gizmo
  41296. */
  41297. setCustomMesh(mesh: Mesh): void;
  41298. }
  41299. }
  41300. declare module BABYLON {
  41301. /**
  41302. * Class containing static functions to help procedurally build meshes
  41303. */
  41304. export class PolyhedronBuilder {
  41305. /**
  41306. * Creates a polyhedron mesh
  41307. * * 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
  41308. * * The parameter `size` (positive float, default 1) sets the polygon size
  41309. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  41310. * * 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`
  41311. * * 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
  41312. * * 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)`)
  41313. * * 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
  41314. * * 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
  41315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41316. * * 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
  41317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41318. * @param name defines the name of the mesh
  41319. * @param options defines the options used to create the mesh
  41320. * @param scene defines the hosting scene
  41321. * @returns the polyhedron mesh
  41322. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  41323. */
  41324. static CreatePolyhedron(name: string, options: {
  41325. type?: number;
  41326. size?: number;
  41327. sizeX?: number;
  41328. sizeY?: number;
  41329. sizeZ?: number;
  41330. custom?: any;
  41331. faceUV?: Vector4[];
  41332. faceColors?: Color4[];
  41333. flat?: boolean;
  41334. updatable?: boolean;
  41335. sideOrientation?: number;
  41336. frontUVs?: Vector4;
  41337. backUVs?: Vector4;
  41338. }, scene: Scene): Mesh;
  41339. }
  41340. }
  41341. declare module BABYLON {
  41342. /**
  41343. * Gizmo that enables scaling a mesh along 3 axis
  41344. */
  41345. export class ScaleGizmo extends Gizmo {
  41346. /**
  41347. * Internal gizmo used for interactions on the x axis
  41348. */
  41349. xGizmo: AxisScaleGizmo;
  41350. /**
  41351. * Internal gizmo used for interactions on the y axis
  41352. */
  41353. yGizmo: AxisScaleGizmo;
  41354. /**
  41355. * Internal gizmo used for interactions on the z axis
  41356. */
  41357. zGizmo: AxisScaleGizmo;
  41358. /**
  41359. * Internal gizmo used to scale all axis equally
  41360. */
  41361. uniformScaleGizmo: AxisScaleGizmo;
  41362. /** Fires an event when any of it's sub gizmos are dragged */
  41363. onDragStartObservable: Observable<{}>;
  41364. /** Fires an event when any of it's sub gizmos are released from dragging */
  41365. onDragEndObservable: Observable<{}>;
  41366. attachedMesh: Nullable<AbstractMesh>;
  41367. /**
  41368. * Creates a ScaleGizmo
  41369. * @param gizmoLayer The utility layer the gizmo will be added to
  41370. */
  41371. constructor(gizmoLayer?: UtilityLayerRenderer);
  41372. updateGizmoRotationToMatchAttachedMesh: boolean;
  41373. /**
  41374. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41375. */
  41376. snapDistance: number;
  41377. /**
  41378. * Ratio for the scale of the gizmo (Default: 1)
  41379. */
  41380. scaleRatio: number;
  41381. /**
  41382. * Disposes of the gizmo
  41383. */
  41384. dispose(): void;
  41385. }
  41386. }
  41387. declare module BABYLON {
  41388. /**
  41389. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  41390. */
  41391. export class GizmoManager implements IDisposable {
  41392. private scene;
  41393. /**
  41394. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  41395. */
  41396. gizmos: {
  41397. positionGizmo: Nullable<PositionGizmo>;
  41398. rotationGizmo: Nullable<RotationGizmo>;
  41399. scaleGizmo: Nullable<ScaleGizmo>;
  41400. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  41401. };
  41402. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  41403. clearGizmoOnEmptyPointerEvent: boolean;
  41404. /** Fires an event when the manager is attached to a mesh */
  41405. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  41406. private _gizmosEnabled;
  41407. private _pointerObserver;
  41408. private _attachedMesh;
  41409. private _boundingBoxColor;
  41410. private _defaultUtilityLayer;
  41411. private _defaultKeepDepthUtilityLayer;
  41412. /**
  41413. * When bounding box gizmo is enabled, this can be used to track drag/end events
  41414. */
  41415. boundingBoxDragBehavior: SixDofDragBehavior;
  41416. /**
  41417. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  41418. */
  41419. attachableMeshes: Nullable<Array<AbstractMesh>>;
  41420. /**
  41421. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  41422. */
  41423. usePointerToAttachGizmos: boolean;
  41424. /**
  41425. * Instatiates a gizmo manager
  41426. * @param scene the scene to overlay the gizmos on top of
  41427. */
  41428. constructor(scene: Scene);
  41429. /**
  41430. * Attaches a set of gizmos to the specified mesh
  41431. * @param mesh The mesh the gizmo's should be attached to
  41432. */
  41433. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  41434. /**
  41435. * If the position gizmo is enabled
  41436. */
  41437. positionGizmoEnabled: boolean;
  41438. /**
  41439. * If the rotation gizmo is enabled
  41440. */
  41441. rotationGizmoEnabled: boolean;
  41442. /**
  41443. * If the scale gizmo is enabled
  41444. */
  41445. scaleGizmoEnabled: boolean;
  41446. /**
  41447. * If the boundingBox gizmo is enabled
  41448. */
  41449. boundingBoxGizmoEnabled: boolean;
  41450. /**
  41451. * Disposes of the gizmo manager
  41452. */
  41453. dispose(): void;
  41454. }
  41455. }
  41456. declare module BABYLON {
  41457. /** @hidden */
  41458. export var backgroundFragmentDeclaration: {
  41459. name: string;
  41460. shader: string;
  41461. };
  41462. }
  41463. declare module BABYLON {
  41464. /** @hidden */
  41465. export var backgroundUboDeclaration: {
  41466. name: string;
  41467. shader: string;
  41468. };
  41469. }
  41470. declare module BABYLON {
  41471. /** @hidden */
  41472. export var backgroundPixelShader: {
  41473. name: string;
  41474. shader: string;
  41475. };
  41476. }
  41477. declare module BABYLON {
  41478. /** @hidden */
  41479. export var backgroundVertexDeclaration: {
  41480. name: string;
  41481. shader: string;
  41482. };
  41483. }
  41484. declare module BABYLON {
  41485. /** @hidden */
  41486. export var backgroundVertexShader: {
  41487. name: string;
  41488. shader: string;
  41489. };
  41490. }
  41491. declare module BABYLON {
  41492. /**
  41493. * Background material used to create an efficient environement around your scene.
  41494. */
  41495. export class BackgroundMaterial extends PushMaterial {
  41496. /**
  41497. * Standard reflectance value at parallel view angle.
  41498. */
  41499. static StandardReflectance0: number;
  41500. /**
  41501. * Standard reflectance value at grazing angle.
  41502. */
  41503. static StandardReflectance90: number;
  41504. protected _primaryColor: Color3;
  41505. /**
  41506. * Key light Color (multiply against the environement texture)
  41507. */
  41508. primaryColor: Color3;
  41509. protected __perceptualColor: Nullable<Color3>;
  41510. /**
  41511. * Experimental Internal Use Only.
  41512. *
  41513. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  41514. * This acts as a helper to set the primary color to a more "human friendly" value.
  41515. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  41516. * output color as close as possible from the chosen value.
  41517. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  41518. * part of lighting setup.)
  41519. */
  41520. _perceptualColor: Nullable<Color3>;
  41521. protected _primaryColorShadowLevel: float;
  41522. /**
  41523. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  41524. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  41525. */
  41526. primaryColorShadowLevel: float;
  41527. protected _primaryColorHighlightLevel: float;
  41528. /**
  41529. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  41530. * The primary color is used at the level chosen to define what the white area would look.
  41531. */
  41532. primaryColorHighlightLevel: float;
  41533. protected _reflectionTexture: Nullable<BaseTexture>;
  41534. /**
  41535. * Reflection Texture used in the material.
  41536. * Should be author in a specific way for the best result (refer to the documentation).
  41537. */
  41538. reflectionTexture: Nullable<BaseTexture>;
  41539. protected _reflectionBlur: float;
  41540. /**
  41541. * Reflection Texture level of blur.
  41542. *
  41543. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  41544. * texture twice.
  41545. */
  41546. reflectionBlur: float;
  41547. protected _diffuseTexture: Nullable<BaseTexture>;
  41548. /**
  41549. * Diffuse Texture used in the material.
  41550. * Should be author in a specific way for the best result (refer to the documentation).
  41551. */
  41552. diffuseTexture: Nullable<BaseTexture>;
  41553. protected _shadowLights: Nullable<IShadowLight[]>;
  41554. /**
  41555. * Specify the list of lights casting shadow on the material.
  41556. * All scene shadow lights will be included if null.
  41557. */
  41558. shadowLights: Nullable<IShadowLight[]>;
  41559. protected _shadowLevel: float;
  41560. /**
  41561. * Helps adjusting the shadow to a softer level if required.
  41562. * 0 means black shadows and 1 means no shadows.
  41563. */
  41564. shadowLevel: float;
  41565. protected _sceneCenter: Vector3;
  41566. /**
  41567. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  41568. * It is usually zero but might be interesting to modify according to your setup.
  41569. */
  41570. sceneCenter: Vector3;
  41571. protected _opacityFresnel: boolean;
  41572. /**
  41573. * This helps specifying that the material is falling off to the sky box at grazing angle.
  41574. * This helps ensuring a nice transition when the camera goes under the ground.
  41575. */
  41576. opacityFresnel: boolean;
  41577. protected _reflectionFresnel: boolean;
  41578. /**
  41579. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  41580. * This helps adding a mirror texture on the ground.
  41581. */
  41582. reflectionFresnel: boolean;
  41583. protected _reflectionFalloffDistance: number;
  41584. /**
  41585. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  41586. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  41587. */
  41588. reflectionFalloffDistance: number;
  41589. protected _reflectionAmount: number;
  41590. /**
  41591. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  41592. */
  41593. reflectionAmount: number;
  41594. protected _reflectionReflectance0: number;
  41595. /**
  41596. * This specifies the weight of the reflection at grazing angle.
  41597. */
  41598. reflectionReflectance0: number;
  41599. protected _reflectionReflectance90: number;
  41600. /**
  41601. * This specifies the weight of the reflection at a perpendicular point of view.
  41602. */
  41603. reflectionReflectance90: number;
  41604. /**
  41605. * Sets the reflection reflectance fresnel values according to the default standard
  41606. * empirically know to work well :-)
  41607. */
  41608. reflectionStandardFresnelWeight: number;
  41609. protected _useRGBColor: boolean;
  41610. /**
  41611. * Helps to directly use the maps channels instead of their level.
  41612. */
  41613. useRGBColor: boolean;
  41614. protected _enableNoise: boolean;
  41615. /**
  41616. * This helps reducing the banding effect that could occur on the background.
  41617. */
  41618. enableNoise: boolean;
  41619. /**
  41620. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  41621. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  41622. * Recommended to be keep at 1.0 except for special cases.
  41623. */
  41624. fovMultiplier: number;
  41625. private _fovMultiplier;
  41626. /**
  41627. * Enable the FOV adjustment feature controlled by fovMultiplier.
  41628. */
  41629. useEquirectangularFOV: boolean;
  41630. private _maxSimultaneousLights;
  41631. /**
  41632. * Number of Simultaneous lights allowed on the material.
  41633. */
  41634. maxSimultaneousLights: int;
  41635. /**
  41636. * Default configuration related to image processing available in the Background Material.
  41637. */
  41638. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41639. /**
  41640. * Keep track of the image processing observer to allow dispose and replace.
  41641. */
  41642. private _imageProcessingObserver;
  41643. /**
  41644. * Attaches a new image processing configuration to the PBR Material.
  41645. * @param configuration (if null the scene configuration will be use)
  41646. */
  41647. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41648. /**
  41649. * Gets the image processing configuration used either in this material.
  41650. */
  41651. /**
  41652. * Sets the Default image processing configuration used either in the this material.
  41653. *
  41654. * If sets to null, the scene one is in use.
  41655. */
  41656. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  41657. /**
  41658. * Gets wether the color curves effect is enabled.
  41659. */
  41660. /**
  41661. * Sets wether the color curves effect is enabled.
  41662. */
  41663. cameraColorCurvesEnabled: boolean;
  41664. /**
  41665. * Gets wether the color grading effect is enabled.
  41666. */
  41667. /**
  41668. * Gets wether the color grading effect is enabled.
  41669. */
  41670. cameraColorGradingEnabled: boolean;
  41671. /**
  41672. * Gets wether tonemapping is enabled or not.
  41673. */
  41674. /**
  41675. * Sets wether tonemapping is enabled or not
  41676. */
  41677. cameraToneMappingEnabled: boolean;
  41678. /**
  41679. * The camera exposure used on this material.
  41680. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41681. * This corresponds to a photographic exposure.
  41682. */
  41683. /**
  41684. * The camera exposure used on this material.
  41685. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41686. * This corresponds to a photographic exposure.
  41687. */
  41688. cameraExposure: float;
  41689. /**
  41690. * Gets The camera contrast used on this material.
  41691. */
  41692. /**
  41693. * Sets The camera contrast used on this material.
  41694. */
  41695. cameraContrast: float;
  41696. /**
  41697. * Gets the Color Grading 2D Lookup Texture.
  41698. */
  41699. /**
  41700. * Sets the Color Grading 2D Lookup Texture.
  41701. */
  41702. cameraColorGradingTexture: Nullable<BaseTexture>;
  41703. /**
  41704. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41705. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41706. * 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;
  41707. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41708. */
  41709. /**
  41710. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41711. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41712. * 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;
  41713. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41714. */
  41715. cameraColorCurves: Nullable<ColorCurves>;
  41716. /**
  41717. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  41718. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  41719. */
  41720. switchToBGR: boolean;
  41721. private _renderTargets;
  41722. private _reflectionControls;
  41723. private _white;
  41724. private _primaryShadowColor;
  41725. private _primaryHighlightColor;
  41726. /**
  41727. * Instantiates a Background Material in the given scene
  41728. * @param name The friendly name of the material
  41729. * @param scene The scene to add the material to
  41730. */
  41731. constructor(name: string, scene: Scene);
  41732. /**
  41733. * Gets a boolean indicating that current material needs to register RTT
  41734. */
  41735. readonly hasRenderTargetTextures: boolean;
  41736. /**
  41737. * The entire material has been created in order to prevent overdraw.
  41738. * @returns false
  41739. */
  41740. needAlphaTesting(): boolean;
  41741. /**
  41742. * The entire material has been created in order to prevent overdraw.
  41743. * @returns true if blending is enable
  41744. */
  41745. needAlphaBlending(): boolean;
  41746. /**
  41747. * Checks wether the material is ready to be rendered for a given mesh.
  41748. * @param mesh The mesh to render
  41749. * @param subMesh The submesh to check against
  41750. * @param useInstances Specify wether or not the material is used with instances
  41751. * @returns true if all the dependencies are ready (Textures, Effects...)
  41752. */
  41753. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41754. /**
  41755. * Compute the primary color according to the chosen perceptual color.
  41756. */
  41757. private _computePrimaryColorFromPerceptualColor;
  41758. /**
  41759. * Compute the highlights and shadow colors according to their chosen levels.
  41760. */
  41761. private _computePrimaryColors;
  41762. /**
  41763. * Build the uniform buffer used in the material.
  41764. */
  41765. buildUniformLayout(): void;
  41766. /**
  41767. * Unbind the material.
  41768. */
  41769. unbind(): void;
  41770. /**
  41771. * Bind only the world matrix to the material.
  41772. * @param world The world matrix to bind.
  41773. */
  41774. bindOnlyWorldMatrix(world: Matrix): void;
  41775. /**
  41776. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  41777. * @param world The world matrix to bind.
  41778. * @param subMesh The submesh to bind for.
  41779. */
  41780. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41781. /**
  41782. * Dispose the material.
  41783. * @param forceDisposeEffect Force disposal of the associated effect.
  41784. * @param forceDisposeTextures Force disposal of the associated textures.
  41785. */
  41786. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41787. /**
  41788. * Clones the material.
  41789. * @param name The cloned name.
  41790. * @returns The cloned material.
  41791. */
  41792. clone(name: string): BackgroundMaterial;
  41793. /**
  41794. * Serializes the current material to its JSON representation.
  41795. * @returns The JSON representation.
  41796. */
  41797. serialize(): any;
  41798. /**
  41799. * Gets the class name of the material
  41800. * @returns "BackgroundMaterial"
  41801. */
  41802. getClassName(): string;
  41803. /**
  41804. * Parse a JSON input to create back a background material.
  41805. * @param source The JSON data to parse
  41806. * @param scene The scene to create the parsed material in
  41807. * @param rootUrl The root url of the assets the material depends upon
  41808. * @returns the instantiated BackgroundMaterial.
  41809. */
  41810. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  41811. }
  41812. }
  41813. declare module BABYLON {
  41814. /**
  41815. * Represents the different options available during the creation of
  41816. * a Environment helper.
  41817. *
  41818. * This can control the default ground, skybox and image processing setup of your scene.
  41819. */
  41820. export interface IEnvironmentHelperOptions {
  41821. /**
  41822. * Specifies wether or not to create a ground.
  41823. * True by default.
  41824. */
  41825. createGround: boolean;
  41826. /**
  41827. * Specifies the ground size.
  41828. * 15 by default.
  41829. */
  41830. groundSize: number;
  41831. /**
  41832. * The texture used on the ground for the main color.
  41833. * Comes from the BabylonJS CDN by default.
  41834. *
  41835. * Remarks: Can be either a texture or a url.
  41836. */
  41837. groundTexture: string | BaseTexture;
  41838. /**
  41839. * The color mixed in the ground texture by default.
  41840. * BabylonJS clearColor by default.
  41841. */
  41842. groundColor: Color3;
  41843. /**
  41844. * Specifies the ground opacity.
  41845. * 1 by default.
  41846. */
  41847. groundOpacity: number;
  41848. /**
  41849. * Enables the ground to receive shadows.
  41850. * True by default.
  41851. */
  41852. enableGroundShadow: boolean;
  41853. /**
  41854. * Helps preventing the shadow to be fully black on the ground.
  41855. * 0.5 by default.
  41856. */
  41857. groundShadowLevel: number;
  41858. /**
  41859. * Creates a mirror texture attach to the ground.
  41860. * false by default.
  41861. */
  41862. enableGroundMirror: boolean;
  41863. /**
  41864. * Specifies the ground mirror size ratio.
  41865. * 0.3 by default as the default kernel is 64.
  41866. */
  41867. groundMirrorSizeRatio: number;
  41868. /**
  41869. * Specifies the ground mirror blur kernel size.
  41870. * 64 by default.
  41871. */
  41872. groundMirrorBlurKernel: number;
  41873. /**
  41874. * Specifies the ground mirror visibility amount.
  41875. * 1 by default
  41876. */
  41877. groundMirrorAmount: number;
  41878. /**
  41879. * Specifies the ground mirror reflectance weight.
  41880. * This uses the standard weight of the background material to setup the fresnel effect
  41881. * of the mirror.
  41882. * 1 by default.
  41883. */
  41884. groundMirrorFresnelWeight: number;
  41885. /**
  41886. * Specifies the ground mirror Falloff distance.
  41887. * This can helps reducing the size of the reflection.
  41888. * 0 by Default.
  41889. */
  41890. groundMirrorFallOffDistance: number;
  41891. /**
  41892. * Specifies the ground mirror texture type.
  41893. * Unsigned Int by Default.
  41894. */
  41895. groundMirrorTextureType: number;
  41896. /**
  41897. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  41898. * the shown objects.
  41899. */
  41900. groundYBias: number;
  41901. /**
  41902. * Specifies wether or not to create a skybox.
  41903. * True by default.
  41904. */
  41905. createSkybox: boolean;
  41906. /**
  41907. * Specifies the skybox size.
  41908. * 20 by default.
  41909. */
  41910. skyboxSize: number;
  41911. /**
  41912. * The texture used on the skybox for the main color.
  41913. * Comes from the BabylonJS CDN by default.
  41914. *
  41915. * Remarks: Can be either a texture or a url.
  41916. */
  41917. skyboxTexture: string | BaseTexture;
  41918. /**
  41919. * The color mixed in the skybox texture by default.
  41920. * BabylonJS clearColor by default.
  41921. */
  41922. skyboxColor: Color3;
  41923. /**
  41924. * The background rotation around the Y axis of the scene.
  41925. * This helps aligning the key lights of your scene with the background.
  41926. * 0 by default.
  41927. */
  41928. backgroundYRotation: number;
  41929. /**
  41930. * Compute automatically the size of the elements to best fit with the scene.
  41931. */
  41932. sizeAuto: boolean;
  41933. /**
  41934. * Default position of the rootMesh if autoSize is not true.
  41935. */
  41936. rootPosition: Vector3;
  41937. /**
  41938. * Sets up the image processing in the scene.
  41939. * true by default.
  41940. */
  41941. setupImageProcessing: boolean;
  41942. /**
  41943. * The texture used as your environment texture in the scene.
  41944. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  41945. *
  41946. * Remarks: Can be either a texture or a url.
  41947. */
  41948. environmentTexture: string | BaseTexture;
  41949. /**
  41950. * The value of the exposure to apply to the scene.
  41951. * 0.6 by default if setupImageProcessing is true.
  41952. */
  41953. cameraExposure: number;
  41954. /**
  41955. * The value of the contrast to apply to the scene.
  41956. * 1.6 by default if setupImageProcessing is true.
  41957. */
  41958. cameraContrast: number;
  41959. /**
  41960. * Specifies wether or not tonemapping should be enabled in the scene.
  41961. * true by default if setupImageProcessing is true.
  41962. */
  41963. toneMappingEnabled: boolean;
  41964. }
  41965. /**
  41966. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  41967. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  41968. * It also helps with the default setup of your imageProcessing configuration.
  41969. */
  41970. export class EnvironmentHelper {
  41971. /**
  41972. * Default ground texture URL.
  41973. */
  41974. private static _groundTextureCDNUrl;
  41975. /**
  41976. * Default skybox texture URL.
  41977. */
  41978. private static _skyboxTextureCDNUrl;
  41979. /**
  41980. * Default environment texture URL.
  41981. */
  41982. private static _environmentTextureCDNUrl;
  41983. /**
  41984. * Creates the default options for the helper.
  41985. */
  41986. private static _getDefaultOptions;
  41987. private _rootMesh;
  41988. /**
  41989. * Gets the root mesh created by the helper.
  41990. */
  41991. readonly rootMesh: Mesh;
  41992. private _skybox;
  41993. /**
  41994. * Gets the skybox created by the helper.
  41995. */
  41996. readonly skybox: Nullable<Mesh>;
  41997. private _skyboxTexture;
  41998. /**
  41999. * Gets the skybox texture created by the helper.
  42000. */
  42001. readonly skyboxTexture: Nullable<BaseTexture>;
  42002. private _skyboxMaterial;
  42003. /**
  42004. * Gets the skybox material created by the helper.
  42005. */
  42006. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  42007. private _ground;
  42008. /**
  42009. * Gets the ground mesh created by the helper.
  42010. */
  42011. readonly ground: Nullable<Mesh>;
  42012. private _groundTexture;
  42013. /**
  42014. * Gets the ground texture created by the helper.
  42015. */
  42016. readonly groundTexture: Nullable<BaseTexture>;
  42017. private _groundMirror;
  42018. /**
  42019. * Gets the ground mirror created by the helper.
  42020. */
  42021. readonly groundMirror: Nullable<MirrorTexture>;
  42022. /**
  42023. * Gets the ground mirror render list to helps pushing the meshes
  42024. * you wish in the ground reflection.
  42025. */
  42026. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  42027. private _groundMaterial;
  42028. /**
  42029. * Gets the ground material created by the helper.
  42030. */
  42031. readonly groundMaterial: Nullable<BackgroundMaterial>;
  42032. /**
  42033. * Stores the creation options.
  42034. */
  42035. private readonly _scene;
  42036. private _options;
  42037. /**
  42038. * This observable will be notified with any error during the creation of the environment,
  42039. * mainly texture creation errors.
  42040. */
  42041. onErrorObservable: Observable<{
  42042. message?: string;
  42043. exception?: any;
  42044. }>;
  42045. /**
  42046. * constructor
  42047. * @param options Defines the options we want to customize the helper
  42048. * @param scene The scene to add the material to
  42049. */
  42050. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  42051. /**
  42052. * Updates the background according to the new options
  42053. * @param options
  42054. */
  42055. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  42056. /**
  42057. * Sets the primary color of all the available elements.
  42058. * @param color the main color to affect to the ground and the background
  42059. */
  42060. setMainColor(color: Color3): void;
  42061. /**
  42062. * Setup the image processing according to the specified options.
  42063. */
  42064. private _setupImageProcessing;
  42065. /**
  42066. * Setup the environment texture according to the specified options.
  42067. */
  42068. private _setupEnvironmentTexture;
  42069. /**
  42070. * Setup the background according to the specified options.
  42071. */
  42072. private _setupBackground;
  42073. /**
  42074. * Get the scene sizes according to the setup.
  42075. */
  42076. private _getSceneSize;
  42077. /**
  42078. * Setup the ground according to the specified options.
  42079. */
  42080. private _setupGround;
  42081. /**
  42082. * Setup the ground material according to the specified options.
  42083. */
  42084. private _setupGroundMaterial;
  42085. /**
  42086. * Setup the ground diffuse texture according to the specified options.
  42087. */
  42088. private _setupGroundDiffuseTexture;
  42089. /**
  42090. * Setup the ground mirror texture according to the specified options.
  42091. */
  42092. private _setupGroundMirrorTexture;
  42093. /**
  42094. * Setup the ground to receive the mirror texture.
  42095. */
  42096. private _setupMirrorInGroundMaterial;
  42097. /**
  42098. * Setup the skybox according to the specified options.
  42099. */
  42100. private _setupSkybox;
  42101. /**
  42102. * Setup the skybox material according to the specified options.
  42103. */
  42104. private _setupSkyboxMaterial;
  42105. /**
  42106. * Setup the skybox reflection texture according to the specified options.
  42107. */
  42108. private _setupSkyboxReflectionTexture;
  42109. private _errorHandler;
  42110. /**
  42111. * Dispose all the elements created by the Helper.
  42112. */
  42113. dispose(): void;
  42114. }
  42115. }
  42116. declare module BABYLON {
  42117. /**
  42118. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  42119. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  42120. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  42121. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  42122. */
  42123. export class PhotoDome extends TransformNode {
  42124. private _useDirectMapping;
  42125. /**
  42126. * The texture being displayed on the sphere
  42127. */
  42128. protected _photoTexture: Texture;
  42129. /**
  42130. * Gets or sets the texture being displayed on the sphere
  42131. */
  42132. photoTexture: Texture;
  42133. /**
  42134. * Observable raised when an error occured while loading the 360 image
  42135. */
  42136. onLoadErrorObservable: Observable<string>;
  42137. /**
  42138. * The skybox material
  42139. */
  42140. protected _material: BackgroundMaterial;
  42141. /**
  42142. * The surface used for the skybox
  42143. */
  42144. protected _mesh: Mesh;
  42145. /**
  42146. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42147. * Also see the options.resolution property.
  42148. */
  42149. fovMultiplier: number;
  42150. /**
  42151. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  42152. * @param name Element's name, child elements will append suffixes for their own names.
  42153. * @param urlsOfPhoto defines the url of the photo to display
  42154. * @param options defines an object containing optional or exposed sub element properties
  42155. * @param onError defines a callback called when an error occured while loading the texture
  42156. */
  42157. constructor(name: string, urlOfPhoto: string, options: {
  42158. resolution?: number;
  42159. size?: number;
  42160. useDirectMapping?: boolean;
  42161. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  42162. /**
  42163. * Releases resources associated with this node.
  42164. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  42165. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  42166. */
  42167. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  42168. }
  42169. }
  42170. declare module BABYLON {
  42171. /**
  42172. * Class used to host texture specific utilities
  42173. */
  42174. export class TextureTools {
  42175. /**
  42176. * Uses the GPU to create a copy texture rescaled at a given size
  42177. * @param texture Texture to copy from
  42178. * @param width defines the desired width
  42179. * @param height defines the desired height
  42180. * @param useBilinearMode defines if bilinear mode has to be used
  42181. * @return the generated texture
  42182. */
  42183. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  42184. /**
  42185. * Gets an environment BRDF texture for a given scene
  42186. * @param scene defines the hosting scene
  42187. * @returns the environment BRDF texture
  42188. */
  42189. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  42190. private static _environmentBRDFBase64Texture;
  42191. }
  42192. }
  42193. declare module BABYLON {
  42194. /** @hidden */
  42195. export var pbrFragmentDeclaration: {
  42196. name: string;
  42197. shader: string;
  42198. };
  42199. }
  42200. declare module BABYLON {
  42201. /** @hidden */
  42202. export var pbrUboDeclaration: {
  42203. name: string;
  42204. shader: string;
  42205. };
  42206. }
  42207. declare module BABYLON {
  42208. /** @hidden */
  42209. export var pbrFunctions: {
  42210. name: string;
  42211. shader: string;
  42212. };
  42213. }
  42214. declare module BABYLON {
  42215. /** @hidden */
  42216. export var harmonicsFunctions: {
  42217. name: string;
  42218. shader: string;
  42219. };
  42220. }
  42221. declare module BABYLON {
  42222. /** @hidden */
  42223. export var pbrLightFunctions: {
  42224. name: string;
  42225. shader: string;
  42226. };
  42227. }
  42228. declare module BABYLON {
  42229. /** @hidden */
  42230. export var pbrPixelShader: {
  42231. name: string;
  42232. shader: string;
  42233. };
  42234. }
  42235. declare module BABYLON {
  42236. /** @hidden */
  42237. export var pbrVertexDeclaration: {
  42238. name: string;
  42239. shader: string;
  42240. };
  42241. }
  42242. declare module BABYLON {
  42243. /** @hidden */
  42244. export var pbrVertexShader: {
  42245. name: string;
  42246. shader: string;
  42247. };
  42248. }
  42249. declare module BABYLON {
  42250. /**
  42251. * The Physically based material base class of BJS.
  42252. *
  42253. * This offers the main features of a standard PBR material.
  42254. * For more information, please refer to the documentation :
  42255. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  42256. */
  42257. export abstract class PBRBaseMaterial extends PushMaterial {
  42258. /**
  42259. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  42260. */
  42261. static readonly PBRMATERIAL_OPAQUE: number;
  42262. /**
  42263. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  42264. */
  42265. static readonly PBRMATERIAL_ALPHATEST: number;
  42266. /**
  42267. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42268. */
  42269. static readonly PBRMATERIAL_ALPHABLEND: number;
  42270. /**
  42271. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42272. * They are also discarded below the alpha cutoff threshold to improve performances.
  42273. */
  42274. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  42275. /**
  42276. * Defines the default value of how much AO map is occluding the analytical lights
  42277. * (point spot...).
  42278. */
  42279. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  42280. /**
  42281. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  42282. */
  42283. static readonly LIGHTFALLOFF_PHYSICAL: number;
  42284. /**
  42285. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  42286. * to enhance interoperability with other engines.
  42287. */
  42288. static readonly LIGHTFALLOFF_GLTF: number;
  42289. /**
  42290. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  42291. * to enhance interoperability with other materials.
  42292. */
  42293. static readonly LIGHTFALLOFF_STANDARD: number;
  42294. /**
  42295. * Intensity of the direct lights e.g. the four lights available in your scene.
  42296. * This impacts both the direct diffuse and specular highlights.
  42297. */
  42298. protected _directIntensity: number;
  42299. /**
  42300. * Intensity of the emissive part of the material.
  42301. * This helps controlling the emissive effect without modifying the emissive color.
  42302. */
  42303. protected _emissiveIntensity: number;
  42304. /**
  42305. * Intensity of the environment e.g. how much the environment will light the object
  42306. * either through harmonics for rough material or through the refelction for shiny ones.
  42307. */
  42308. protected _environmentIntensity: number;
  42309. /**
  42310. * This is a special control allowing the reduction of the specular highlights coming from the
  42311. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  42312. */
  42313. protected _specularIntensity: number;
  42314. /**
  42315. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  42316. */
  42317. private _lightingInfos;
  42318. /**
  42319. * Debug Control allowing disabling the bump map on this material.
  42320. */
  42321. protected _disableBumpMap: boolean;
  42322. /**
  42323. * AKA Diffuse Texture in standard nomenclature.
  42324. */
  42325. protected _albedoTexture: BaseTexture;
  42326. /**
  42327. * AKA Occlusion Texture in other nomenclature.
  42328. */
  42329. protected _ambientTexture: BaseTexture;
  42330. /**
  42331. * AKA Occlusion Texture Intensity in other nomenclature.
  42332. */
  42333. protected _ambientTextureStrength: number;
  42334. /**
  42335. * Defines how much the AO map is occluding the analytical lights (point spot...).
  42336. * 1 means it completely occludes it
  42337. * 0 mean it has no impact
  42338. */
  42339. protected _ambientTextureImpactOnAnalyticalLights: number;
  42340. /**
  42341. * Stores the alpha values in a texture.
  42342. */
  42343. protected _opacityTexture: BaseTexture;
  42344. /**
  42345. * Stores the reflection values in a texture.
  42346. */
  42347. protected _reflectionTexture: BaseTexture;
  42348. /**
  42349. * Stores the refraction values in a texture.
  42350. */
  42351. protected _refractionTexture: BaseTexture;
  42352. /**
  42353. * Stores the emissive values in a texture.
  42354. */
  42355. protected _emissiveTexture: BaseTexture;
  42356. /**
  42357. * AKA Specular texture in other nomenclature.
  42358. */
  42359. protected _reflectivityTexture: BaseTexture;
  42360. /**
  42361. * Used to switch from specular/glossiness to metallic/roughness workflow.
  42362. */
  42363. protected _metallicTexture: BaseTexture;
  42364. /**
  42365. * Specifies the metallic scalar of the metallic/roughness workflow.
  42366. * Can also be used to scale the metalness values of the metallic texture.
  42367. */
  42368. protected _metallic: Nullable<number>;
  42369. /**
  42370. * Specifies the roughness scalar of the metallic/roughness workflow.
  42371. * Can also be used to scale the roughness values of the metallic texture.
  42372. */
  42373. protected _roughness: Nullable<number>;
  42374. /**
  42375. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  42376. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  42377. */
  42378. protected _microSurfaceTexture: BaseTexture;
  42379. /**
  42380. * Stores surface normal data used to displace a mesh in a texture.
  42381. */
  42382. protected _bumpTexture: BaseTexture;
  42383. /**
  42384. * Stores the pre-calculated light information of a mesh in a texture.
  42385. */
  42386. protected _lightmapTexture: BaseTexture;
  42387. /**
  42388. * The color of a material in ambient lighting.
  42389. */
  42390. protected _ambientColor: Color3;
  42391. /**
  42392. * AKA Diffuse Color in other nomenclature.
  42393. */
  42394. protected _albedoColor: Color3;
  42395. /**
  42396. * AKA Specular Color in other nomenclature.
  42397. */
  42398. protected _reflectivityColor: Color3;
  42399. /**
  42400. * The color applied when light is reflected from a material.
  42401. */
  42402. protected _reflectionColor: Color3;
  42403. /**
  42404. * The color applied when light is emitted from a material.
  42405. */
  42406. protected _emissiveColor: Color3;
  42407. /**
  42408. * AKA Glossiness in other nomenclature.
  42409. */
  42410. protected _microSurface: number;
  42411. /**
  42412. * source material index of refraction (IOR)' / 'destination material IOR.
  42413. */
  42414. protected _indexOfRefraction: number;
  42415. /**
  42416. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  42417. */
  42418. protected _invertRefractionY: boolean;
  42419. /**
  42420. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  42421. * Materials half opaque for instance using refraction could benefit from this control.
  42422. */
  42423. protected _linkRefractionWithTransparency: boolean;
  42424. /**
  42425. * Specifies that the material will use the light map as a show map.
  42426. */
  42427. protected _useLightmapAsShadowmap: boolean;
  42428. /**
  42429. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  42430. * makes the reflect vector face the model (under horizon).
  42431. */
  42432. protected _useHorizonOcclusion: boolean;
  42433. /**
  42434. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  42435. * too much the area relying on ambient texture to define their ambient occlusion.
  42436. */
  42437. protected _useRadianceOcclusion: boolean;
  42438. /**
  42439. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  42440. */
  42441. protected _useAlphaFromAlbedoTexture: boolean;
  42442. /**
  42443. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  42444. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42445. */
  42446. protected _useSpecularOverAlpha: boolean;
  42447. /**
  42448. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  42449. */
  42450. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  42451. /**
  42452. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  42453. */
  42454. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  42455. /**
  42456. * Specifies if the metallic texture contains the roughness information in its green channel.
  42457. */
  42458. protected _useRoughnessFromMetallicTextureGreen: boolean;
  42459. /**
  42460. * Specifies if the metallic texture contains the metallness information in its blue channel.
  42461. */
  42462. protected _useMetallnessFromMetallicTextureBlue: boolean;
  42463. /**
  42464. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  42465. */
  42466. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  42467. /**
  42468. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  42469. */
  42470. protected _useAmbientInGrayScale: boolean;
  42471. /**
  42472. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  42473. * The material will try to infer what glossiness each pixel should be.
  42474. */
  42475. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  42476. /**
  42477. * Defines the falloff type used in this material.
  42478. * It by default is Physical.
  42479. */
  42480. protected _lightFalloff: number;
  42481. /**
  42482. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42483. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42484. */
  42485. protected _useRadianceOverAlpha: boolean;
  42486. /**
  42487. * Allows using an object space normal map (instead of tangent space).
  42488. */
  42489. protected _useObjectSpaceNormalMap: boolean;
  42490. /**
  42491. * Allows using the bump map in parallax mode.
  42492. */
  42493. protected _useParallax: boolean;
  42494. /**
  42495. * Allows using the bump map in parallax occlusion mode.
  42496. */
  42497. protected _useParallaxOcclusion: boolean;
  42498. /**
  42499. * Controls the scale bias of the parallax mode.
  42500. */
  42501. protected _parallaxScaleBias: number;
  42502. /**
  42503. * If sets to true, disables all the lights affecting the material.
  42504. */
  42505. protected _disableLighting: boolean;
  42506. /**
  42507. * Number of Simultaneous lights allowed on the material.
  42508. */
  42509. protected _maxSimultaneousLights: number;
  42510. /**
  42511. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  42512. */
  42513. protected _invertNormalMapX: boolean;
  42514. /**
  42515. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  42516. */
  42517. protected _invertNormalMapY: boolean;
  42518. /**
  42519. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42520. */
  42521. protected _twoSidedLighting: boolean;
  42522. /**
  42523. * Defines the alpha limits in alpha test mode.
  42524. */
  42525. protected _alphaCutOff: number;
  42526. /**
  42527. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  42528. */
  42529. protected _forceAlphaTest: boolean;
  42530. /**
  42531. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42532. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  42533. */
  42534. protected _useAlphaFresnel: boolean;
  42535. /**
  42536. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42537. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  42538. */
  42539. protected _useLinearAlphaFresnel: boolean;
  42540. /**
  42541. * The transparency mode of the material.
  42542. */
  42543. protected _transparencyMode: Nullable<number>;
  42544. /**
  42545. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  42546. * from cos thetav and roughness:
  42547. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  42548. */
  42549. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  42550. /**
  42551. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  42552. */
  42553. protected _forceIrradianceInFragment: boolean;
  42554. /**
  42555. * Force normal to face away from face.
  42556. */
  42557. protected _forceNormalForward: boolean;
  42558. /**
  42559. * Enables specular anti aliasing in the PBR shader.
  42560. * It will both interacts on the Geometry for analytical and IBL lighting.
  42561. * It also prefilter the roughness map based on the bump values.
  42562. */
  42563. protected _enableSpecularAntiAliasing: boolean;
  42564. /**
  42565. * Default configuration related to image processing available in the PBR Material.
  42566. */
  42567. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42568. /**
  42569. * Keep track of the image processing observer to allow dispose and replace.
  42570. */
  42571. private _imageProcessingObserver;
  42572. /**
  42573. * Attaches a new image processing configuration to the PBR Material.
  42574. * @param configuration
  42575. */
  42576. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42577. /**
  42578. * Stores the available render targets.
  42579. */
  42580. private _renderTargets;
  42581. /**
  42582. * Sets the global ambient color for the material used in lighting calculations.
  42583. */
  42584. private _globalAmbientColor;
  42585. /**
  42586. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  42587. */
  42588. private _useLogarithmicDepth;
  42589. /**
  42590. * If set to true, no lighting calculations will be applied.
  42591. */
  42592. private _unlit;
  42593. /**
  42594. * Instantiates a new PBRMaterial instance.
  42595. *
  42596. * @param name The material name
  42597. * @param scene The scene the material will be use in.
  42598. */
  42599. constructor(name: string, scene: Scene);
  42600. /**
  42601. * Gets a boolean indicating that current material needs to register RTT
  42602. */
  42603. readonly hasRenderTargetTextures: boolean;
  42604. /**
  42605. * Gets the name of the material class.
  42606. */
  42607. getClassName(): string;
  42608. /**
  42609. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  42610. */
  42611. /**
  42612. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  42613. */
  42614. useLogarithmicDepth: boolean;
  42615. /**
  42616. * Gets the current transparency mode.
  42617. */
  42618. /**
  42619. * Sets the transparency mode of the material.
  42620. *
  42621. * | Value | Type | Description |
  42622. * | ----- | ----------------------------------- | ----------- |
  42623. * | 0 | OPAQUE | |
  42624. * | 1 | ALPHATEST | |
  42625. * | 2 | ALPHABLEND | |
  42626. * | 3 | ALPHATESTANDBLEND | |
  42627. *
  42628. */
  42629. transparencyMode: Nullable<number>;
  42630. /**
  42631. * Returns true if alpha blending should be disabled.
  42632. */
  42633. private readonly _disableAlphaBlending;
  42634. /**
  42635. * Specifies whether or not this material should be rendered in alpha blend mode.
  42636. */
  42637. needAlphaBlending(): boolean;
  42638. /**
  42639. * Specifies if the mesh will require alpha blending.
  42640. * @param mesh - BJS mesh.
  42641. */
  42642. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  42643. /**
  42644. * Specifies whether or not this material should be rendered in alpha test mode.
  42645. */
  42646. needAlphaTesting(): boolean;
  42647. /**
  42648. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  42649. */
  42650. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  42651. /**
  42652. * Gets the texture used for the alpha test.
  42653. */
  42654. getAlphaTestTexture(): BaseTexture;
  42655. /**
  42656. * Specifies that the submesh is ready to be used.
  42657. * @param mesh - BJS mesh.
  42658. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  42659. * @param useInstances - Specifies that instances should be used.
  42660. * @returns - boolean indicating that the submesh is ready or not.
  42661. */
  42662. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42663. /**
  42664. * Specifies if the material uses metallic roughness workflow.
  42665. * @returns boolean specifiying if the material uses metallic roughness workflow.
  42666. */
  42667. isMetallicWorkflow(): boolean;
  42668. private _prepareEffect;
  42669. private _prepareDefines;
  42670. /**
  42671. * Force shader compilation
  42672. */
  42673. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  42674. clipPlane: boolean;
  42675. }>): void;
  42676. /**
  42677. * Initializes the uniform buffer layout for the shader.
  42678. */
  42679. buildUniformLayout(): void;
  42680. /**
  42681. * Unbinds the textures.
  42682. */
  42683. unbind(): void;
  42684. /**
  42685. * Binds the submesh data.
  42686. * @param world - The world matrix.
  42687. * @param mesh - The BJS mesh.
  42688. * @param subMesh - A submesh of the BJS mesh.
  42689. */
  42690. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42691. /**
  42692. * Returns the animatable textures.
  42693. * @returns - Array of animatable textures.
  42694. */
  42695. getAnimatables(): IAnimatable[];
  42696. /**
  42697. * Returns the texture used for reflections.
  42698. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  42699. */
  42700. private _getReflectionTexture;
  42701. /**
  42702. * Returns the texture used for refraction or null if none is used.
  42703. * @returns - Refection texture if present. If no refraction texture and refraction
  42704. * is linked with transparency, returns environment texture. Otherwise, returns null.
  42705. */
  42706. private _getRefractionTexture;
  42707. /**
  42708. * Disposes the resources of the material.
  42709. * @param forceDisposeEffect - Forces the disposal of effects.
  42710. * @param forceDisposeTextures - Forces the disposal of all textures.
  42711. */
  42712. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42713. }
  42714. }
  42715. declare module BABYLON {
  42716. /**
  42717. * The Physically based material of BJS.
  42718. *
  42719. * This offers the main features of a standard PBR material.
  42720. * For more information, please refer to the documentation :
  42721. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  42722. */
  42723. export class PBRMaterial extends PBRBaseMaterial {
  42724. /**
  42725. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  42726. */
  42727. static readonly PBRMATERIAL_OPAQUE: number;
  42728. /**
  42729. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  42730. */
  42731. static readonly PBRMATERIAL_ALPHATEST: number;
  42732. /**
  42733. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42734. */
  42735. static readonly PBRMATERIAL_ALPHABLEND: number;
  42736. /**
  42737. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42738. * They are also discarded below the alpha cutoff threshold to improve performances.
  42739. */
  42740. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  42741. /**
  42742. * Defines the default value of how much AO map is occluding the analytical lights
  42743. * (point spot...).
  42744. */
  42745. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  42746. /**
  42747. * Intensity of the direct lights e.g. the four lights available in your scene.
  42748. * This impacts both the direct diffuse and specular highlights.
  42749. */
  42750. directIntensity: number;
  42751. /**
  42752. * Intensity of the emissive part of the material.
  42753. * This helps controlling the emissive effect without modifying the emissive color.
  42754. */
  42755. emissiveIntensity: number;
  42756. /**
  42757. * Intensity of the environment e.g. how much the environment will light the object
  42758. * either through harmonics for rough material or through the refelction for shiny ones.
  42759. */
  42760. environmentIntensity: number;
  42761. /**
  42762. * This is a special control allowing the reduction of the specular highlights coming from the
  42763. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  42764. */
  42765. specularIntensity: number;
  42766. /**
  42767. * Debug Control allowing disabling the bump map on this material.
  42768. */
  42769. disableBumpMap: boolean;
  42770. /**
  42771. * AKA Diffuse Texture in standard nomenclature.
  42772. */
  42773. albedoTexture: BaseTexture;
  42774. /**
  42775. * AKA Occlusion Texture in other nomenclature.
  42776. */
  42777. ambientTexture: BaseTexture;
  42778. /**
  42779. * AKA Occlusion Texture Intensity in other nomenclature.
  42780. */
  42781. ambientTextureStrength: number;
  42782. /**
  42783. * Defines how much the AO map is occluding the analytical lights (point spot...).
  42784. * 1 means it completely occludes it
  42785. * 0 mean it has no impact
  42786. */
  42787. ambientTextureImpactOnAnalyticalLights: number;
  42788. /**
  42789. * Stores the alpha values in a texture.
  42790. */
  42791. opacityTexture: BaseTexture;
  42792. /**
  42793. * Stores the reflection values in a texture.
  42794. */
  42795. reflectionTexture: Nullable<BaseTexture>;
  42796. /**
  42797. * Stores the emissive values in a texture.
  42798. */
  42799. emissiveTexture: BaseTexture;
  42800. /**
  42801. * AKA Specular texture in other nomenclature.
  42802. */
  42803. reflectivityTexture: BaseTexture;
  42804. /**
  42805. * Used to switch from specular/glossiness to metallic/roughness workflow.
  42806. */
  42807. metallicTexture: BaseTexture;
  42808. /**
  42809. * Specifies the metallic scalar of the metallic/roughness workflow.
  42810. * Can also be used to scale the metalness values of the metallic texture.
  42811. */
  42812. metallic: Nullable<number>;
  42813. /**
  42814. * Specifies the roughness scalar of the metallic/roughness workflow.
  42815. * Can also be used to scale the roughness values of the metallic texture.
  42816. */
  42817. roughness: Nullable<number>;
  42818. /**
  42819. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  42820. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  42821. */
  42822. microSurfaceTexture: BaseTexture;
  42823. /**
  42824. * Stores surface normal data used to displace a mesh in a texture.
  42825. */
  42826. bumpTexture: BaseTexture;
  42827. /**
  42828. * Stores the pre-calculated light information of a mesh in a texture.
  42829. */
  42830. lightmapTexture: BaseTexture;
  42831. /**
  42832. * Stores the refracted light information in a texture.
  42833. */
  42834. refractionTexture: BaseTexture;
  42835. /**
  42836. * The color of a material in ambient lighting.
  42837. */
  42838. ambientColor: Color3;
  42839. /**
  42840. * AKA Diffuse Color in other nomenclature.
  42841. */
  42842. albedoColor: Color3;
  42843. /**
  42844. * AKA Specular Color in other nomenclature.
  42845. */
  42846. reflectivityColor: Color3;
  42847. /**
  42848. * The color reflected from the material.
  42849. */
  42850. reflectionColor: Color3;
  42851. /**
  42852. * The color emitted from the material.
  42853. */
  42854. emissiveColor: Color3;
  42855. /**
  42856. * AKA Glossiness in other nomenclature.
  42857. */
  42858. microSurface: number;
  42859. /**
  42860. * source material index of refraction (IOR)' / 'destination material IOR.
  42861. */
  42862. indexOfRefraction: number;
  42863. /**
  42864. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  42865. */
  42866. invertRefractionY: boolean;
  42867. /**
  42868. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  42869. * Materials half opaque for instance using refraction could benefit from this control.
  42870. */
  42871. linkRefractionWithTransparency: boolean;
  42872. /**
  42873. * If true, the light map contains occlusion information instead of lighting info.
  42874. */
  42875. useLightmapAsShadowmap: boolean;
  42876. /**
  42877. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  42878. */
  42879. useAlphaFromAlbedoTexture: boolean;
  42880. /**
  42881. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  42882. */
  42883. forceAlphaTest: boolean;
  42884. /**
  42885. * Defines the alpha limits in alpha test mode.
  42886. */
  42887. alphaCutOff: number;
  42888. /**
  42889. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42890. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42891. */
  42892. useSpecularOverAlpha: boolean;
  42893. /**
  42894. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  42895. */
  42896. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  42897. /**
  42898. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  42899. */
  42900. useRoughnessFromMetallicTextureAlpha: boolean;
  42901. /**
  42902. * Specifies if the metallic texture contains the roughness information in its green channel.
  42903. */
  42904. useRoughnessFromMetallicTextureGreen: boolean;
  42905. /**
  42906. * Specifies if the metallic texture contains the metallness information in its blue channel.
  42907. */
  42908. useMetallnessFromMetallicTextureBlue: boolean;
  42909. /**
  42910. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  42911. */
  42912. useAmbientOcclusionFromMetallicTextureRed: boolean;
  42913. /**
  42914. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  42915. */
  42916. useAmbientInGrayScale: boolean;
  42917. /**
  42918. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  42919. * The material will try to infer what glossiness each pixel should be.
  42920. */
  42921. useAutoMicroSurfaceFromReflectivityMap: boolean;
  42922. /**
  42923. * BJS is using an harcoded light falloff based on a manually sets up range.
  42924. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  42925. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  42926. */
  42927. /**
  42928. * BJS is using an harcoded light falloff based on a manually sets up range.
  42929. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  42930. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  42931. */
  42932. usePhysicalLightFalloff: boolean;
  42933. /**
  42934. * In order to support the falloff compatibility with gltf, a special mode has been added
  42935. * to reproduce the gltf light falloff.
  42936. */
  42937. /**
  42938. * In order to support the falloff compatibility with gltf, a special mode has been added
  42939. * to reproduce the gltf light falloff.
  42940. */
  42941. useGLTFLightFalloff: boolean;
  42942. /**
  42943. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42944. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42945. */
  42946. useRadianceOverAlpha: boolean;
  42947. /**
  42948. * Allows using an object space normal map (instead of tangent space).
  42949. */
  42950. useObjectSpaceNormalMap: boolean;
  42951. /**
  42952. * Allows using the bump map in parallax mode.
  42953. */
  42954. useParallax: boolean;
  42955. /**
  42956. * Allows using the bump map in parallax occlusion mode.
  42957. */
  42958. useParallaxOcclusion: boolean;
  42959. /**
  42960. * Controls the scale bias of the parallax mode.
  42961. */
  42962. parallaxScaleBias: number;
  42963. /**
  42964. * If sets to true, disables all the lights affecting the material.
  42965. */
  42966. disableLighting: boolean;
  42967. /**
  42968. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  42969. */
  42970. forceIrradianceInFragment: boolean;
  42971. /**
  42972. * Number of Simultaneous lights allowed on the material.
  42973. */
  42974. maxSimultaneousLights: number;
  42975. /**
  42976. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42977. */
  42978. invertNormalMapX: boolean;
  42979. /**
  42980. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42981. */
  42982. invertNormalMapY: boolean;
  42983. /**
  42984. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42985. */
  42986. twoSidedLighting: boolean;
  42987. /**
  42988. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42989. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  42990. */
  42991. useAlphaFresnel: boolean;
  42992. /**
  42993. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42994. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  42995. */
  42996. useLinearAlphaFresnel: boolean;
  42997. /**
  42998. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42999. * And/Or occlude the blended part.
  43000. */
  43001. environmentBRDFTexture: Nullable<BaseTexture>;
  43002. /**
  43003. * Force normal to face away from face.
  43004. */
  43005. forceNormalForward: boolean;
  43006. /**
  43007. * Enables specular anti aliasing in the PBR shader.
  43008. * It will both interacts on the Geometry for analytical and IBL lighting.
  43009. * It also prefilter the roughness map based on the bump values.
  43010. */
  43011. enableSpecularAntiAliasing: boolean;
  43012. /**
  43013. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  43014. * makes the reflect vector face the model (under horizon).
  43015. */
  43016. useHorizonOcclusion: boolean;
  43017. /**
  43018. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  43019. * too much the area relying on ambient texture to define their ambient occlusion.
  43020. */
  43021. useRadianceOcclusion: boolean;
  43022. /**
  43023. * If set to true, no lighting calculations will be applied.
  43024. */
  43025. unlit: boolean;
  43026. /**
  43027. * Gets the image processing configuration used either in this material.
  43028. */
  43029. /**
  43030. * Sets the Default image processing configuration used either in the this material.
  43031. *
  43032. * If sets to null, the scene one is in use.
  43033. */
  43034. imageProcessingConfiguration: ImageProcessingConfiguration;
  43035. /**
  43036. * Gets wether the color curves effect is enabled.
  43037. */
  43038. /**
  43039. * Sets wether the color curves effect is enabled.
  43040. */
  43041. cameraColorCurvesEnabled: boolean;
  43042. /**
  43043. * Gets wether the color grading effect is enabled.
  43044. */
  43045. /**
  43046. * Gets wether the color grading effect is enabled.
  43047. */
  43048. cameraColorGradingEnabled: boolean;
  43049. /**
  43050. * Gets wether tonemapping is enabled or not.
  43051. */
  43052. /**
  43053. * Sets wether tonemapping is enabled or not
  43054. */
  43055. cameraToneMappingEnabled: boolean;
  43056. /**
  43057. * The camera exposure used on this material.
  43058. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43059. * This corresponds to a photographic exposure.
  43060. */
  43061. /**
  43062. * The camera exposure used on this material.
  43063. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43064. * This corresponds to a photographic exposure.
  43065. */
  43066. cameraExposure: number;
  43067. /**
  43068. * Gets The camera contrast used on this material.
  43069. */
  43070. /**
  43071. * Sets The camera contrast used on this material.
  43072. */
  43073. cameraContrast: number;
  43074. /**
  43075. * Gets the Color Grading 2D Lookup Texture.
  43076. */
  43077. /**
  43078. * Sets the Color Grading 2D Lookup Texture.
  43079. */
  43080. cameraColorGradingTexture: Nullable<BaseTexture>;
  43081. /**
  43082. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43083. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43084. * 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;
  43085. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43086. */
  43087. /**
  43088. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43089. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43090. * 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;
  43091. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43092. */
  43093. cameraColorCurves: Nullable<ColorCurves>;
  43094. /**
  43095. * Instantiates a new PBRMaterial instance.
  43096. *
  43097. * @param name The material name
  43098. * @param scene The scene the material will be use in.
  43099. */
  43100. constructor(name: string, scene: Scene);
  43101. /**
  43102. * Returns the name of this material class.
  43103. */
  43104. getClassName(): string;
  43105. /**
  43106. * Returns an array of the actively used textures.
  43107. * @returns - Array of BaseTextures
  43108. */
  43109. getActiveTextures(): BaseTexture[];
  43110. /**
  43111. * Checks to see if a texture is used in the material.
  43112. * @param texture - Base texture to use.
  43113. * @returns - Boolean specifying if a texture is used in the material.
  43114. */
  43115. hasTexture(texture: BaseTexture): boolean;
  43116. /**
  43117. * Makes a duplicate of the current material.
  43118. * @param name - name to use for the new material.
  43119. */
  43120. clone(name: string): PBRMaterial;
  43121. /**
  43122. * Serializes this PBR Material.
  43123. * @returns - An object with the serialized material.
  43124. */
  43125. serialize(): any;
  43126. /**
  43127. * Parses a PBR Material from a serialized object.
  43128. * @param source - Serialized object.
  43129. * @param scene - BJS scene instance.
  43130. * @param rootUrl - url for the scene object
  43131. * @returns - PBRMaterial
  43132. */
  43133. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  43134. }
  43135. }
  43136. declare module BABYLON {
  43137. /** @hidden */
  43138. export var _forceSceneHelpersToBundle: boolean;
  43139. interface Scene {
  43140. /**
  43141. * Creates a default light for the scene.
  43142. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  43143. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  43144. */
  43145. createDefaultLight(replace?: boolean): void;
  43146. /**
  43147. * Creates a default camera for the scene.
  43148. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  43149. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  43150. * @param replace has default false, when true replaces the active camera in the scene
  43151. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  43152. */
  43153. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  43154. /**
  43155. * Creates a default camera and a default light.
  43156. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  43157. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  43158. * @param replace has the default false, when true replaces the active camera/light in the scene
  43159. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  43160. */
  43161. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  43162. /**
  43163. * Creates a new sky box
  43164. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  43165. * @param environmentTexture defines the texture to use as environment texture
  43166. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  43167. * @param scale defines the overall scale of the skybox
  43168. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  43169. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  43170. * @returns a new mesh holding the sky box
  43171. */
  43172. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  43173. /**
  43174. * Creates a new environment
  43175. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  43176. * @param options defines the options you can use to configure the environment
  43177. * @returns the new EnvironmentHelper
  43178. */
  43179. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  43180. /**
  43181. * Creates a new VREXperienceHelper
  43182. * @see http://doc.babylonjs.com/how_to/webvr_helper
  43183. * @param webVROptions defines the options used to create the new VREXperienceHelper
  43184. * @returns a new VREXperienceHelper
  43185. */
  43186. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  43187. /**
  43188. * Creates a new XREXperienceHelper
  43189. * @see http://doc.babylonjs.com/how_to/webxr
  43190. * @returns a promise for a new XREXperienceHelper
  43191. */
  43192. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  43193. }
  43194. }
  43195. declare module BABYLON {
  43196. /**
  43197. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  43198. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  43199. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  43200. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43201. */
  43202. export class VideoDome extends TransformNode {
  43203. private _useDirectMapping;
  43204. /**
  43205. * The video texture being displayed on the sphere
  43206. */
  43207. protected _videoTexture: VideoTexture;
  43208. /**
  43209. * Gets the video texture being displayed on the sphere
  43210. */
  43211. readonly videoTexture: VideoTexture;
  43212. /**
  43213. * The skybox material
  43214. */
  43215. protected _material: BackgroundMaterial;
  43216. /**
  43217. * The surface used for the skybox
  43218. */
  43219. protected _mesh: Mesh;
  43220. /**
  43221. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43222. * Also see the options.resolution property.
  43223. */
  43224. fovMultiplier: number;
  43225. /**
  43226. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  43227. * @param name Element's name, child elements will append suffixes for their own names.
  43228. * @param urlsOrVideo defines the url(s) or the video element to use
  43229. * @param options An object containing optional or exposed sub element properties
  43230. */
  43231. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  43232. resolution?: number;
  43233. clickToPlay?: boolean;
  43234. autoPlay?: boolean;
  43235. loop?: boolean;
  43236. size?: number;
  43237. poster?: string;
  43238. useDirectMapping?: boolean;
  43239. }, scene: Scene);
  43240. /**
  43241. * Releases resources associated with this node.
  43242. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43243. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43244. */
  43245. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43246. }
  43247. }
  43248. declare module BABYLON {
  43249. /**
  43250. * This class can be used to get instrumentation data from a Babylon engine
  43251. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  43252. */
  43253. export class EngineInstrumentation implements IDisposable {
  43254. /**
  43255. * Define the instrumented engine.
  43256. */
  43257. engine: Engine;
  43258. private _captureGPUFrameTime;
  43259. private _gpuFrameTimeToken;
  43260. private _gpuFrameTime;
  43261. private _captureShaderCompilationTime;
  43262. private _shaderCompilationTime;
  43263. private _onBeginFrameObserver;
  43264. private _onEndFrameObserver;
  43265. private _onBeforeShaderCompilationObserver;
  43266. private _onAfterShaderCompilationObserver;
  43267. /**
  43268. * Gets the perf counter used for GPU frame time
  43269. */
  43270. readonly gpuFrameTimeCounter: PerfCounter;
  43271. /**
  43272. * Gets the GPU frame time capture status
  43273. */
  43274. /**
  43275. * Enable or disable the GPU frame time capture
  43276. */
  43277. captureGPUFrameTime: boolean;
  43278. /**
  43279. * Gets the perf counter used for shader compilation time
  43280. */
  43281. readonly shaderCompilationTimeCounter: PerfCounter;
  43282. /**
  43283. * Gets the shader compilation time capture status
  43284. */
  43285. /**
  43286. * Enable or disable the shader compilation time capture
  43287. */
  43288. captureShaderCompilationTime: boolean;
  43289. /**
  43290. * Instantiates a new engine instrumentation.
  43291. * This class can be used to get instrumentation data from a Babylon engine
  43292. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  43293. * @param engine Defines the engine to instrument
  43294. */
  43295. constructor(
  43296. /**
  43297. * Define the instrumented engine.
  43298. */
  43299. engine: Engine);
  43300. /**
  43301. * Dispose and release associated resources.
  43302. */
  43303. dispose(): void;
  43304. }
  43305. }
  43306. declare module BABYLON {
  43307. /**
  43308. * This class can be used to get instrumentation data from a Babylon engine
  43309. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  43310. */
  43311. export class SceneInstrumentation implements IDisposable {
  43312. /**
  43313. * Defines the scene to instrument
  43314. */
  43315. scene: Scene;
  43316. private _captureActiveMeshesEvaluationTime;
  43317. private _activeMeshesEvaluationTime;
  43318. private _captureRenderTargetsRenderTime;
  43319. private _renderTargetsRenderTime;
  43320. private _captureFrameTime;
  43321. private _frameTime;
  43322. private _captureRenderTime;
  43323. private _renderTime;
  43324. private _captureInterFrameTime;
  43325. private _interFrameTime;
  43326. private _captureParticlesRenderTime;
  43327. private _particlesRenderTime;
  43328. private _captureSpritesRenderTime;
  43329. private _spritesRenderTime;
  43330. private _capturePhysicsTime;
  43331. private _physicsTime;
  43332. private _captureAnimationsTime;
  43333. private _animationsTime;
  43334. private _captureCameraRenderTime;
  43335. private _cameraRenderTime;
  43336. private _onBeforeActiveMeshesEvaluationObserver;
  43337. private _onAfterActiveMeshesEvaluationObserver;
  43338. private _onBeforeRenderTargetsRenderObserver;
  43339. private _onAfterRenderTargetsRenderObserver;
  43340. private _onAfterRenderObserver;
  43341. private _onBeforeDrawPhaseObserver;
  43342. private _onAfterDrawPhaseObserver;
  43343. private _onBeforeAnimationsObserver;
  43344. private _onBeforeParticlesRenderingObserver;
  43345. private _onAfterParticlesRenderingObserver;
  43346. private _onBeforeSpritesRenderingObserver;
  43347. private _onAfterSpritesRenderingObserver;
  43348. private _onBeforePhysicsObserver;
  43349. private _onAfterPhysicsObserver;
  43350. private _onAfterAnimationsObserver;
  43351. private _onBeforeCameraRenderObserver;
  43352. private _onAfterCameraRenderObserver;
  43353. /**
  43354. * Gets the perf counter used for active meshes evaluation time
  43355. */
  43356. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  43357. /**
  43358. * Gets the active meshes evaluation time capture status
  43359. */
  43360. /**
  43361. * Enable or disable the active meshes evaluation time capture
  43362. */
  43363. captureActiveMeshesEvaluationTime: boolean;
  43364. /**
  43365. * Gets the perf counter used for render targets render time
  43366. */
  43367. readonly renderTargetsRenderTimeCounter: PerfCounter;
  43368. /**
  43369. * Gets the render targets render time capture status
  43370. */
  43371. /**
  43372. * Enable or disable the render targets render time capture
  43373. */
  43374. captureRenderTargetsRenderTime: boolean;
  43375. /**
  43376. * Gets the perf counter used for particles render time
  43377. */
  43378. readonly particlesRenderTimeCounter: PerfCounter;
  43379. /**
  43380. * Gets the particles render time capture status
  43381. */
  43382. /**
  43383. * Enable or disable the particles render time capture
  43384. */
  43385. captureParticlesRenderTime: boolean;
  43386. /**
  43387. * Gets the perf counter used for sprites render time
  43388. */
  43389. readonly spritesRenderTimeCounter: PerfCounter;
  43390. /**
  43391. * Gets the sprites render time capture status
  43392. */
  43393. /**
  43394. * Enable or disable the sprites render time capture
  43395. */
  43396. captureSpritesRenderTime: boolean;
  43397. /**
  43398. * Gets the perf counter used for physics time
  43399. */
  43400. readonly physicsTimeCounter: PerfCounter;
  43401. /**
  43402. * Gets the physics time capture status
  43403. */
  43404. /**
  43405. * Enable or disable the physics time capture
  43406. */
  43407. capturePhysicsTime: boolean;
  43408. /**
  43409. * Gets the perf counter used for animations time
  43410. */
  43411. readonly animationsTimeCounter: PerfCounter;
  43412. /**
  43413. * Gets the animations time capture status
  43414. */
  43415. /**
  43416. * Enable or disable the animations time capture
  43417. */
  43418. captureAnimationsTime: boolean;
  43419. /**
  43420. * Gets the perf counter used for frame time capture
  43421. */
  43422. readonly frameTimeCounter: PerfCounter;
  43423. /**
  43424. * Gets the frame time capture status
  43425. */
  43426. /**
  43427. * Enable or disable the frame time capture
  43428. */
  43429. captureFrameTime: boolean;
  43430. /**
  43431. * Gets the perf counter used for inter-frames time capture
  43432. */
  43433. readonly interFrameTimeCounter: PerfCounter;
  43434. /**
  43435. * Gets the inter-frames time capture status
  43436. */
  43437. /**
  43438. * Enable or disable the inter-frames time capture
  43439. */
  43440. captureInterFrameTime: boolean;
  43441. /**
  43442. * Gets the perf counter used for render time capture
  43443. */
  43444. readonly renderTimeCounter: PerfCounter;
  43445. /**
  43446. * Gets the render time capture status
  43447. */
  43448. /**
  43449. * Enable or disable the render time capture
  43450. */
  43451. captureRenderTime: boolean;
  43452. /**
  43453. * Gets the perf counter used for camera render time capture
  43454. */
  43455. readonly cameraRenderTimeCounter: PerfCounter;
  43456. /**
  43457. * Gets the camera render time capture status
  43458. */
  43459. /**
  43460. * Enable or disable the camera render time capture
  43461. */
  43462. captureCameraRenderTime: boolean;
  43463. /**
  43464. * Gets the perf counter used for draw calls
  43465. */
  43466. readonly drawCallsCounter: PerfCounter;
  43467. /**
  43468. * Gets the perf counter used for texture collisions
  43469. */
  43470. readonly textureCollisionsCounter: PerfCounter;
  43471. /**
  43472. * Instantiates a new scene instrumentation.
  43473. * This class can be used to get instrumentation data from a Babylon engine
  43474. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  43475. * @param scene Defines the scene to instrument
  43476. */
  43477. constructor(
  43478. /**
  43479. * Defines the scene to instrument
  43480. */
  43481. scene: Scene);
  43482. /**
  43483. * Dispose and release associated resources.
  43484. */
  43485. dispose(): void;
  43486. }
  43487. }
  43488. declare module BABYLON {
  43489. /** @hidden */
  43490. export var glowMapGenerationPixelShader: {
  43491. name: string;
  43492. shader: string;
  43493. };
  43494. }
  43495. declare module BABYLON {
  43496. /** @hidden */
  43497. export var glowMapGenerationVertexShader: {
  43498. name: string;
  43499. shader: string;
  43500. };
  43501. }
  43502. declare module BABYLON {
  43503. /**
  43504. * Effect layer options. This helps customizing the behaviour
  43505. * of the effect layer.
  43506. */
  43507. export interface IEffectLayerOptions {
  43508. /**
  43509. * Multiplication factor apply to the canvas size to compute the render target size
  43510. * used to generated the objects (the smaller the faster).
  43511. */
  43512. mainTextureRatio: number;
  43513. /**
  43514. * Enforces a fixed size texture to ensure effect stability across devices.
  43515. */
  43516. mainTextureFixedSize?: number;
  43517. /**
  43518. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  43519. */
  43520. alphaBlendingMode: number;
  43521. /**
  43522. * The camera attached to the layer.
  43523. */
  43524. camera: Nullable<Camera>;
  43525. /**
  43526. * The rendering group to draw the layer in.
  43527. */
  43528. renderingGroupId: number;
  43529. }
  43530. /**
  43531. * The effect layer Helps adding post process effect blended with the main pass.
  43532. *
  43533. * This can be for instance use to generate glow or higlight effects on the scene.
  43534. *
  43535. * The effect layer class can not be used directly and is intented to inherited from to be
  43536. * customized per effects.
  43537. */
  43538. export abstract class EffectLayer {
  43539. private _vertexBuffers;
  43540. private _indexBuffer;
  43541. private _cachedDefines;
  43542. private _effectLayerMapGenerationEffect;
  43543. private _effectLayerOptions;
  43544. private _mergeEffect;
  43545. protected _scene: Scene;
  43546. protected _engine: Engine;
  43547. protected _maxSize: number;
  43548. protected _mainTextureDesiredSize: ISize;
  43549. protected _mainTexture: RenderTargetTexture;
  43550. protected _shouldRender: boolean;
  43551. protected _postProcesses: PostProcess[];
  43552. protected _textures: BaseTexture[];
  43553. protected _emissiveTextureAndColor: {
  43554. texture: Nullable<BaseTexture>;
  43555. color: Color4;
  43556. };
  43557. /**
  43558. * The name of the layer
  43559. */
  43560. name: string;
  43561. /**
  43562. * The clear color of the texture used to generate the glow map.
  43563. */
  43564. neutralColor: Color4;
  43565. /**
  43566. * Specifies wether the highlight layer is enabled or not.
  43567. */
  43568. isEnabled: boolean;
  43569. /**
  43570. * Gets the camera attached to the layer.
  43571. */
  43572. readonly camera: Nullable<Camera>;
  43573. /**
  43574. * Gets the rendering group id the layer should render in.
  43575. */
  43576. readonly renderingGroupId: number;
  43577. /**
  43578. * An event triggered when the effect layer has been disposed.
  43579. */
  43580. onDisposeObservable: Observable<EffectLayer>;
  43581. /**
  43582. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  43583. */
  43584. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  43585. /**
  43586. * An event triggered when the generated texture is being merged in the scene.
  43587. */
  43588. onBeforeComposeObservable: Observable<EffectLayer>;
  43589. /**
  43590. * An event triggered when the generated texture has been merged in the scene.
  43591. */
  43592. onAfterComposeObservable: Observable<EffectLayer>;
  43593. /**
  43594. * An event triggered when the efffect layer changes its size.
  43595. */
  43596. onSizeChangedObservable: Observable<EffectLayer>;
  43597. /** @hidden */
  43598. static _SceneComponentInitialization: (scene: Scene) => void;
  43599. /**
  43600. * Instantiates a new effect Layer and references it in the scene.
  43601. * @param name The name of the layer
  43602. * @param scene The scene to use the layer in
  43603. */
  43604. constructor(
  43605. /** The Friendly of the effect in the scene */
  43606. name: string, scene: Scene);
  43607. /**
  43608. * Get the effect name of the layer.
  43609. * @return The effect name
  43610. */
  43611. abstract getEffectName(): string;
  43612. /**
  43613. * Checks for the readiness of the element composing the layer.
  43614. * @param subMesh the mesh to check for
  43615. * @param useInstances specify wether or not to use instances to render the mesh
  43616. * @return true if ready otherwise, false
  43617. */
  43618. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43619. /**
  43620. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43621. * @returns true if the effect requires stencil during the main canvas render pass.
  43622. */
  43623. abstract needStencil(): boolean;
  43624. /**
  43625. * Create the merge effect. This is the shader use to blit the information back
  43626. * to the main canvas at the end of the scene rendering.
  43627. * @returns The effect containing the shader used to merge the effect on the main canvas
  43628. */
  43629. protected abstract _createMergeEffect(): Effect;
  43630. /**
  43631. * Creates the render target textures and post processes used in the effect layer.
  43632. */
  43633. protected abstract _createTextureAndPostProcesses(): void;
  43634. /**
  43635. * Implementation specific of rendering the generating effect on the main canvas.
  43636. * @param effect The effect used to render through
  43637. */
  43638. protected abstract _internalRender(effect: Effect): void;
  43639. /**
  43640. * Sets the required values for both the emissive texture and and the main color.
  43641. */
  43642. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  43643. /**
  43644. * Free any resources and references associated to a mesh.
  43645. * Internal use
  43646. * @param mesh The mesh to free.
  43647. */
  43648. abstract _disposeMesh(mesh: Mesh): void;
  43649. /**
  43650. * Serializes this layer (Glow or Highlight for example)
  43651. * @returns a serialized layer object
  43652. */
  43653. abstract serialize?(): any;
  43654. /**
  43655. * Initializes the effect layer with the required options.
  43656. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  43657. */
  43658. protected _init(options: Partial<IEffectLayerOptions>): void;
  43659. /**
  43660. * Generates the index buffer of the full screen quad blending to the main canvas.
  43661. */
  43662. private _generateIndexBuffer;
  43663. /**
  43664. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  43665. */
  43666. private _genrateVertexBuffer;
  43667. /**
  43668. * Sets the main texture desired size which is the closest power of two
  43669. * of the engine canvas size.
  43670. */
  43671. private _setMainTextureSize;
  43672. /**
  43673. * Creates the main texture for the effect layer.
  43674. */
  43675. protected _createMainTexture(): void;
  43676. /**
  43677. * Adds specific effects defines.
  43678. * @param defines The defines to add specifics to.
  43679. */
  43680. protected _addCustomEffectDefines(defines: string[]): void;
  43681. /**
  43682. * Checks for the readiness of the element composing the layer.
  43683. * @param subMesh the mesh to check for
  43684. * @param useInstances specify wether or not to use instances to render the mesh
  43685. * @param emissiveTexture the associated emissive texture used to generate the glow
  43686. * @return true if ready otherwise, false
  43687. */
  43688. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  43689. /**
  43690. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  43691. */
  43692. render(): void;
  43693. /**
  43694. * Determine if a given mesh will be used in the current effect.
  43695. * @param mesh mesh to test
  43696. * @returns true if the mesh will be used
  43697. */
  43698. hasMesh(mesh: AbstractMesh): boolean;
  43699. /**
  43700. * Returns true if the layer contains information to display, otherwise false.
  43701. * @returns true if the glow layer should be rendered
  43702. */
  43703. shouldRender(): boolean;
  43704. /**
  43705. * Returns true if the mesh should render, otherwise false.
  43706. * @param mesh The mesh to render
  43707. * @returns true if it should render otherwise false
  43708. */
  43709. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  43710. /**
  43711. * Returns true if the mesh can be rendered, otherwise false.
  43712. * @param mesh The mesh to render
  43713. * @param material The material used on the mesh
  43714. * @returns true if it can be rendered otherwise false
  43715. */
  43716. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  43717. /**
  43718. * Returns true if the mesh should render, otherwise false.
  43719. * @param mesh The mesh to render
  43720. * @returns true if it should render otherwise false
  43721. */
  43722. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  43723. /**
  43724. * Renders the submesh passed in parameter to the generation map.
  43725. */
  43726. protected _renderSubMesh(subMesh: SubMesh): void;
  43727. /**
  43728. * Rebuild the required buffers.
  43729. * @hidden Internal use only.
  43730. */
  43731. _rebuild(): void;
  43732. /**
  43733. * Dispose only the render target textures and post process.
  43734. */
  43735. private _disposeTextureAndPostProcesses;
  43736. /**
  43737. * Dispose the highlight layer and free resources.
  43738. */
  43739. dispose(): void;
  43740. /**
  43741. * Gets the class name of the effect layer
  43742. * @returns the string with the class name of the effect layer
  43743. */
  43744. getClassName(): string;
  43745. /**
  43746. * Creates an effect layer from parsed effect layer data
  43747. * @param parsedEffectLayer defines effect layer data
  43748. * @param scene defines the current scene
  43749. * @param rootUrl defines the root URL containing the effect layer information
  43750. * @returns a parsed effect Layer
  43751. */
  43752. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  43753. }
  43754. }
  43755. declare module BABYLON {
  43756. interface AbstractScene {
  43757. /**
  43758. * The list of effect layers (highlights/glow) added to the scene
  43759. * @see http://doc.babylonjs.com/how_to/highlight_layer
  43760. * @see http://doc.babylonjs.com/how_to/glow_layer
  43761. */
  43762. effectLayers: Array<EffectLayer>;
  43763. /**
  43764. * Removes the given effect layer from this scene.
  43765. * @param toRemove defines the effect layer to remove
  43766. * @returns the index of the removed effect layer
  43767. */
  43768. removeEffectLayer(toRemove: EffectLayer): number;
  43769. /**
  43770. * Adds the given effect layer to this scene
  43771. * @param newEffectLayer defines the effect layer to add
  43772. */
  43773. addEffectLayer(newEffectLayer: EffectLayer): void;
  43774. }
  43775. /**
  43776. * Defines the layer scene component responsible to manage any effect layers
  43777. * in a given scene.
  43778. */
  43779. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  43780. /**
  43781. * The component name helpfull to identify the component in the list of scene components.
  43782. */
  43783. readonly name: string;
  43784. /**
  43785. * The scene the component belongs to.
  43786. */
  43787. scene: Scene;
  43788. private _engine;
  43789. private _renderEffects;
  43790. private _needStencil;
  43791. private _previousStencilState;
  43792. /**
  43793. * Creates a new instance of the component for the given scene
  43794. * @param scene Defines the scene to register the component in
  43795. */
  43796. constructor(scene: Scene);
  43797. /**
  43798. * Registers the component in a given scene
  43799. */
  43800. register(): void;
  43801. /**
  43802. * Rebuilds the elements related to this component in case of
  43803. * context lost for instance.
  43804. */
  43805. rebuild(): void;
  43806. /**
  43807. * Serializes the component data to the specified json object
  43808. * @param serializationObject The object to serialize to
  43809. */
  43810. serialize(serializationObject: any): void;
  43811. /**
  43812. * Adds all the element from the container to the scene
  43813. * @param container the container holding the elements
  43814. */
  43815. addFromContainer(container: AbstractScene): void;
  43816. /**
  43817. * Removes all the elements in the container from the scene
  43818. * @param container contains the elements to remove
  43819. */
  43820. removeFromContainer(container: AbstractScene): void;
  43821. /**
  43822. * Disposes the component and the associated ressources.
  43823. */
  43824. dispose(): void;
  43825. private _isReadyForMesh;
  43826. private _renderMainTexture;
  43827. private _setStencil;
  43828. private _setStencilBack;
  43829. private _draw;
  43830. private _drawCamera;
  43831. private _drawRenderingGroup;
  43832. }
  43833. }
  43834. declare module BABYLON {
  43835. /** @hidden */
  43836. export var glowMapMergePixelShader: {
  43837. name: string;
  43838. shader: string;
  43839. };
  43840. }
  43841. declare module BABYLON {
  43842. /** @hidden */
  43843. export var glowMapMergeVertexShader: {
  43844. name: string;
  43845. shader: string;
  43846. };
  43847. }
  43848. declare module BABYLON {
  43849. interface AbstractScene {
  43850. /**
  43851. * Return a the first highlight layer of the scene with a given name.
  43852. * @param name The name of the highlight layer to look for.
  43853. * @return The highlight layer if found otherwise null.
  43854. */
  43855. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  43856. }
  43857. /**
  43858. * Glow layer options. This helps customizing the behaviour
  43859. * of the glow layer.
  43860. */
  43861. export interface IGlowLayerOptions {
  43862. /**
  43863. * Multiplication factor apply to the canvas size to compute the render target size
  43864. * used to generated the glowing objects (the smaller the faster).
  43865. */
  43866. mainTextureRatio: number;
  43867. /**
  43868. * Enforces a fixed size texture to ensure resize independant blur.
  43869. */
  43870. mainTextureFixedSize?: number;
  43871. /**
  43872. * How big is the kernel of the blur texture.
  43873. */
  43874. blurKernelSize: number;
  43875. /**
  43876. * The camera attached to the layer.
  43877. */
  43878. camera: Nullable<Camera>;
  43879. /**
  43880. * Enable MSAA by chosing the number of samples.
  43881. */
  43882. mainTextureSamples?: number;
  43883. /**
  43884. * The rendering group to draw the layer in.
  43885. */
  43886. renderingGroupId: number;
  43887. }
  43888. /**
  43889. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  43890. *
  43891. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  43892. * glowy meshes to your scene.
  43893. *
  43894. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  43895. */
  43896. export class GlowLayer extends EffectLayer {
  43897. /**
  43898. * Effect Name of the layer.
  43899. */
  43900. static readonly EffectName: string;
  43901. /**
  43902. * The default blur kernel size used for the glow.
  43903. */
  43904. static DefaultBlurKernelSize: number;
  43905. /**
  43906. * The default texture size ratio used for the glow.
  43907. */
  43908. static DefaultTextureRatio: number;
  43909. /**
  43910. * Sets the kernel size of the blur.
  43911. */
  43912. /**
  43913. * Gets the kernel size of the blur.
  43914. */
  43915. blurKernelSize: number;
  43916. /**
  43917. * Sets the glow intensity.
  43918. */
  43919. /**
  43920. * Gets the glow intensity.
  43921. */
  43922. intensity: number;
  43923. private _options;
  43924. private _intensity;
  43925. private _horizontalBlurPostprocess1;
  43926. private _verticalBlurPostprocess1;
  43927. private _horizontalBlurPostprocess2;
  43928. private _verticalBlurPostprocess2;
  43929. private _blurTexture1;
  43930. private _blurTexture2;
  43931. private _postProcesses1;
  43932. private _postProcesses2;
  43933. private _includedOnlyMeshes;
  43934. private _excludedMeshes;
  43935. /**
  43936. * Callback used to let the user override the color selection on a per mesh basis
  43937. */
  43938. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  43939. /**
  43940. * Callback used to let the user override the texture selection on a per mesh basis
  43941. */
  43942. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  43943. /**
  43944. * Instantiates a new glow Layer and references it to the scene.
  43945. * @param name The name of the layer
  43946. * @param scene The scene to use the layer in
  43947. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  43948. */
  43949. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  43950. /**
  43951. * Get the effect name of the layer.
  43952. * @return The effect name
  43953. */
  43954. getEffectName(): string;
  43955. /**
  43956. * Create the merge effect. This is the shader use to blit the information back
  43957. * to the main canvas at the end of the scene rendering.
  43958. */
  43959. protected _createMergeEffect(): Effect;
  43960. /**
  43961. * Creates the render target textures and post processes used in the glow layer.
  43962. */
  43963. protected _createTextureAndPostProcesses(): void;
  43964. /**
  43965. * Checks for the readiness of the element composing the layer.
  43966. * @param subMesh the mesh to check for
  43967. * @param useInstances specify wether or not to use instances to render the mesh
  43968. * @param emissiveTexture the associated emissive texture used to generate the glow
  43969. * @return true if ready otherwise, false
  43970. */
  43971. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43972. /**
  43973. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43974. */
  43975. needStencil(): boolean;
  43976. /**
  43977. * Returns true if the mesh can be rendered, otherwise false.
  43978. * @param mesh The mesh to render
  43979. * @param material The material used on the mesh
  43980. * @returns true if it can be rendered otherwise false
  43981. */
  43982. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  43983. /**
  43984. * Implementation specific of rendering the generating effect on the main canvas.
  43985. * @param effect The effect used to render through
  43986. */
  43987. protected _internalRender(effect: Effect): void;
  43988. /**
  43989. * Sets the required values for both the emissive texture and and the main color.
  43990. */
  43991. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  43992. /**
  43993. * Returns true if the mesh should render, otherwise false.
  43994. * @param mesh The mesh to render
  43995. * @returns true if it should render otherwise false
  43996. */
  43997. protected _shouldRenderMesh(mesh: Mesh): boolean;
  43998. /**
  43999. * Adds specific effects defines.
  44000. * @param defines The defines to add specifics to.
  44001. */
  44002. protected _addCustomEffectDefines(defines: string[]): void;
  44003. /**
  44004. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  44005. * @param mesh The mesh to exclude from the glow layer
  44006. */
  44007. addExcludedMesh(mesh: Mesh): void;
  44008. /**
  44009. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  44010. * @param mesh The mesh to remove
  44011. */
  44012. removeExcludedMesh(mesh: Mesh): void;
  44013. /**
  44014. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  44015. * @param mesh The mesh to include in the glow layer
  44016. */
  44017. addIncludedOnlyMesh(mesh: Mesh): void;
  44018. /**
  44019. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  44020. * @param mesh The mesh to remove
  44021. */
  44022. removeIncludedOnlyMesh(mesh: Mesh): void;
  44023. /**
  44024. * Determine if a given mesh will be used in the glow layer
  44025. * @param mesh The mesh to test
  44026. * @returns true if the mesh will be highlighted by the current glow layer
  44027. */
  44028. hasMesh(mesh: AbstractMesh): boolean;
  44029. /**
  44030. * Free any resources and references associated to a mesh.
  44031. * Internal use
  44032. * @param mesh The mesh to free.
  44033. * @hidden
  44034. */
  44035. _disposeMesh(mesh: Mesh): void;
  44036. /**
  44037. * Gets the class name of the effect layer
  44038. * @returns the string with the class name of the effect layer
  44039. */
  44040. getClassName(): string;
  44041. /**
  44042. * Serializes this glow layer
  44043. * @returns a serialized glow layer object
  44044. */
  44045. serialize(): any;
  44046. /**
  44047. * Creates a Glow Layer from parsed glow layer data
  44048. * @param parsedGlowLayer defines glow layer data
  44049. * @param scene defines the current scene
  44050. * @param rootUrl defines the root URL containing the glow layer information
  44051. * @returns a parsed Glow Layer
  44052. */
  44053. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  44054. }
  44055. }
  44056. declare module BABYLON {
  44057. /** @hidden */
  44058. export var glowBlurPostProcessPixelShader: {
  44059. name: string;
  44060. shader: string;
  44061. };
  44062. }
  44063. declare module BABYLON {
  44064. interface AbstractScene {
  44065. /**
  44066. * Return a the first highlight layer of the scene with a given name.
  44067. * @param name The name of the highlight layer to look for.
  44068. * @return The highlight layer if found otherwise null.
  44069. */
  44070. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  44071. }
  44072. /**
  44073. * Highlight layer options. This helps customizing the behaviour
  44074. * of the highlight layer.
  44075. */
  44076. export interface IHighlightLayerOptions {
  44077. /**
  44078. * Multiplication factor apply to the canvas size to compute the render target size
  44079. * used to generated the glowing objects (the smaller the faster).
  44080. */
  44081. mainTextureRatio: number;
  44082. /**
  44083. * Enforces a fixed size texture to ensure resize independant blur.
  44084. */
  44085. mainTextureFixedSize?: number;
  44086. /**
  44087. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  44088. * of the picture to blur (the smaller the faster).
  44089. */
  44090. blurTextureSizeRatio: number;
  44091. /**
  44092. * How big in texel of the blur texture is the vertical blur.
  44093. */
  44094. blurVerticalSize: number;
  44095. /**
  44096. * How big in texel of the blur texture is the horizontal blur.
  44097. */
  44098. blurHorizontalSize: number;
  44099. /**
  44100. * Alpha blending mode used to apply the blur. Default is combine.
  44101. */
  44102. alphaBlendingMode: number;
  44103. /**
  44104. * The camera attached to the layer.
  44105. */
  44106. camera: Nullable<Camera>;
  44107. /**
  44108. * Should we display highlight as a solid stroke?
  44109. */
  44110. isStroke?: boolean;
  44111. /**
  44112. * The rendering group to draw the layer in.
  44113. */
  44114. renderingGroupId: number;
  44115. }
  44116. /**
  44117. * The highlight layer Helps adding a glow effect around a mesh.
  44118. *
  44119. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  44120. * glowy meshes to your scene.
  44121. *
  44122. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  44123. */
  44124. export class HighlightLayer extends EffectLayer {
  44125. name: string;
  44126. /**
  44127. * Effect Name of the highlight layer.
  44128. */
  44129. static readonly EffectName: string;
  44130. /**
  44131. * The neutral color used during the preparation of the glow effect.
  44132. * This is black by default as the blend operation is a blend operation.
  44133. */
  44134. static NeutralColor: Color4;
  44135. /**
  44136. * Stencil value used for glowing meshes.
  44137. */
  44138. static GlowingMeshStencilReference: number;
  44139. /**
  44140. * Stencil value used for the other meshes in the scene.
  44141. */
  44142. static NormalMeshStencilReference: number;
  44143. /**
  44144. * Specifies whether or not the inner glow is ACTIVE in the layer.
  44145. */
  44146. innerGlow: boolean;
  44147. /**
  44148. * Specifies whether or not the outer glow is ACTIVE in the layer.
  44149. */
  44150. outerGlow: boolean;
  44151. /**
  44152. * Specifies the horizontal size of the blur.
  44153. */
  44154. /**
  44155. * Gets the horizontal size of the blur.
  44156. */
  44157. blurHorizontalSize: number;
  44158. /**
  44159. * Specifies the vertical size of the blur.
  44160. */
  44161. /**
  44162. * Gets the vertical size of the blur.
  44163. */
  44164. blurVerticalSize: number;
  44165. /**
  44166. * An event triggered when the highlight layer is being blurred.
  44167. */
  44168. onBeforeBlurObservable: Observable<HighlightLayer>;
  44169. /**
  44170. * An event triggered when the highlight layer has been blurred.
  44171. */
  44172. onAfterBlurObservable: Observable<HighlightLayer>;
  44173. private _instanceGlowingMeshStencilReference;
  44174. private _options;
  44175. private _downSamplePostprocess;
  44176. private _horizontalBlurPostprocess;
  44177. private _verticalBlurPostprocess;
  44178. private _blurTexture;
  44179. private _meshes;
  44180. private _excludedMeshes;
  44181. /**
  44182. * Instantiates a new highlight Layer and references it to the scene..
  44183. * @param name The name of the layer
  44184. * @param scene The scene to use the layer in
  44185. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  44186. */
  44187. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  44188. /**
  44189. * Get the effect name of the layer.
  44190. * @return The effect name
  44191. */
  44192. getEffectName(): string;
  44193. /**
  44194. * Create the merge effect. This is the shader use to blit the information back
  44195. * to the main canvas at the end of the scene rendering.
  44196. */
  44197. protected _createMergeEffect(): Effect;
  44198. /**
  44199. * Creates the render target textures and post processes used in the highlight layer.
  44200. */
  44201. protected _createTextureAndPostProcesses(): void;
  44202. /**
  44203. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44204. */
  44205. needStencil(): boolean;
  44206. /**
  44207. * Checks for the readiness of the element composing the layer.
  44208. * @param subMesh the mesh to check for
  44209. * @param useInstances specify wether or not to use instances to render the mesh
  44210. * @param emissiveTexture the associated emissive texture used to generate the glow
  44211. * @return true if ready otherwise, false
  44212. */
  44213. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44214. /**
  44215. * Implementation specific of rendering the generating effect on the main canvas.
  44216. * @param effect The effect used to render through
  44217. */
  44218. protected _internalRender(effect: Effect): void;
  44219. /**
  44220. * Returns true if the layer contains information to display, otherwise false.
  44221. */
  44222. shouldRender(): boolean;
  44223. /**
  44224. * Returns true if the mesh should render, otherwise false.
  44225. * @param mesh The mesh to render
  44226. * @returns true if it should render otherwise false
  44227. */
  44228. protected _shouldRenderMesh(mesh: Mesh): boolean;
  44229. /**
  44230. * Sets the required values for both the emissive texture and and the main color.
  44231. */
  44232. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  44233. /**
  44234. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  44235. * @param mesh The mesh to exclude from the highlight layer
  44236. */
  44237. addExcludedMesh(mesh: Mesh): void;
  44238. /**
  44239. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  44240. * @param mesh The mesh to highlight
  44241. */
  44242. removeExcludedMesh(mesh: Mesh): void;
  44243. /**
  44244. * Determine if a given mesh will be highlighted by the current HighlightLayer
  44245. * @param mesh mesh to test
  44246. * @returns true if the mesh will be highlighted by the current HighlightLayer
  44247. */
  44248. hasMesh(mesh: AbstractMesh): boolean;
  44249. /**
  44250. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  44251. * @param mesh The mesh to highlight
  44252. * @param color The color of the highlight
  44253. * @param glowEmissiveOnly Extract the glow from the emissive texture
  44254. */
  44255. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  44256. /**
  44257. * Remove a mesh from the highlight layer in order to make it stop glowing.
  44258. * @param mesh The mesh to highlight
  44259. */
  44260. removeMesh(mesh: Mesh): void;
  44261. /**
  44262. * Force the stencil to the normal expected value for none glowing parts
  44263. */
  44264. private _defaultStencilReference;
  44265. /**
  44266. * Free any resources and references associated to a mesh.
  44267. * Internal use
  44268. * @param mesh The mesh to free.
  44269. * @hidden
  44270. */
  44271. _disposeMesh(mesh: Mesh): void;
  44272. /**
  44273. * Dispose the highlight layer and free resources.
  44274. */
  44275. dispose(): void;
  44276. /**
  44277. * Gets the class name of the effect layer
  44278. * @returns the string with the class name of the effect layer
  44279. */
  44280. getClassName(): string;
  44281. /**
  44282. * Serializes this Highlight layer
  44283. * @returns a serialized Highlight layer object
  44284. */
  44285. serialize(): any;
  44286. /**
  44287. * Creates a Highlight layer from parsed Highlight layer data
  44288. * @param parsedHightlightLayer defines the Highlight layer data
  44289. * @param scene defines the current scene
  44290. * @param rootUrl defines the root URL containing the Highlight layer information
  44291. * @returns a parsed Highlight layer
  44292. */
  44293. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  44294. }
  44295. }
  44296. declare module BABYLON {
  44297. /** @hidden */
  44298. export var lensFlarePixelShader: {
  44299. name: string;
  44300. shader: string;
  44301. };
  44302. }
  44303. declare module BABYLON {
  44304. /** @hidden */
  44305. export var lensFlareVertexShader: {
  44306. name: string;
  44307. shader: string;
  44308. };
  44309. }
  44310. declare module BABYLON {
  44311. /**
  44312. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44313. * It is usually composed of several `lensFlare`.
  44314. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44315. */
  44316. export class LensFlareSystem {
  44317. /**
  44318. * Define the name of the lens flare system
  44319. */
  44320. name: string;
  44321. /**
  44322. * List of lens flares used in this system.
  44323. */
  44324. lensFlares: LensFlare[];
  44325. /**
  44326. * Define a limit from the border the lens flare can be visible.
  44327. */
  44328. borderLimit: number;
  44329. /**
  44330. * Define a viewport border we do not want to see the lens flare in.
  44331. */
  44332. viewportBorder: number;
  44333. /**
  44334. * Define a predicate which could limit the list of meshes able to occlude the effect.
  44335. */
  44336. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44337. /**
  44338. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  44339. */
  44340. layerMask: number;
  44341. /**
  44342. * Define the id of the lens flare system in the scene.
  44343. * (equal to name by default)
  44344. */
  44345. id: string;
  44346. private _scene;
  44347. private _emitter;
  44348. private _vertexBuffers;
  44349. private _indexBuffer;
  44350. private _effect;
  44351. private _positionX;
  44352. private _positionY;
  44353. private _isEnabled;
  44354. /** @hidden */
  44355. static _SceneComponentInitialization: (scene: Scene) => void;
  44356. /**
  44357. * Instantiates a lens flare system.
  44358. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44359. * It is usually composed of several `lensFlare`.
  44360. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44361. * @param name Define the name of the lens flare system in the scene
  44362. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  44363. * @param scene Define the scene the lens flare system belongs to
  44364. */
  44365. constructor(
  44366. /**
  44367. * Define the name of the lens flare system
  44368. */
  44369. name: string, emitter: any, scene: Scene);
  44370. /**
  44371. * Define if the lens flare system is enabled.
  44372. */
  44373. isEnabled: boolean;
  44374. /**
  44375. * Get the scene the effects belongs to.
  44376. * @returns the scene holding the lens flare system
  44377. */
  44378. getScene(): Scene;
  44379. /**
  44380. * Get the emitter of the lens flare system.
  44381. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  44382. * @returns the emitter of the lens flare system
  44383. */
  44384. getEmitter(): any;
  44385. /**
  44386. * Set the emitter of the lens flare system.
  44387. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  44388. * @param newEmitter Define the new emitter of the system
  44389. */
  44390. setEmitter(newEmitter: any): void;
  44391. /**
  44392. * Get the lens flare system emitter position.
  44393. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  44394. * @returns the position
  44395. */
  44396. getEmitterPosition(): Vector3;
  44397. /**
  44398. * @hidden
  44399. */
  44400. computeEffectivePosition(globalViewport: Viewport): boolean;
  44401. /** @hidden */
  44402. _isVisible(): boolean;
  44403. /**
  44404. * @hidden
  44405. */
  44406. render(): boolean;
  44407. /**
  44408. * Dispose and release the lens flare with its associated resources.
  44409. */
  44410. dispose(): void;
  44411. /**
  44412. * Parse a lens flare system from a JSON repressentation
  44413. * @param parsedLensFlareSystem Define the JSON to parse
  44414. * @param scene Define the scene the parsed system should be instantiated in
  44415. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  44416. * @returns the parsed system
  44417. */
  44418. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  44419. /**
  44420. * Serialize the current Lens Flare System into a JSON representation.
  44421. * @returns the serialized JSON
  44422. */
  44423. serialize(): any;
  44424. }
  44425. }
  44426. declare module BABYLON {
  44427. /**
  44428. * This represents one of the lens effect in a `lensFlareSystem`.
  44429. * It controls one of the indiviual texture used in the effect.
  44430. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44431. */
  44432. export class LensFlare {
  44433. /**
  44434. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  44435. */
  44436. size: number;
  44437. /**
  44438. * 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.
  44439. */
  44440. position: number;
  44441. /**
  44442. * Define the lens color.
  44443. */
  44444. color: Color3;
  44445. /**
  44446. * Define the lens texture.
  44447. */
  44448. texture: Nullable<Texture>;
  44449. /**
  44450. * Define the alpha mode to render this particular lens.
  44451. */
  44452. alphaMode: number;
  44453. private _system;
  44454. /**
  44455. * Creates a new Lens Flare.
  44456. * This represents one of the lens effect in a `lensFlareSystem`.
  44457. * It controls one of the indiviual texture used in the effect.
  44458. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44459. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  44460. * @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.
  44461. * @param color Define the lens color
  44462. * @param imgUrl Define the lens texture url
  44463. * @param system Define the `lensFlareSystem` this flare is part of
  44464. * @returns The newly created Lens Flare
  44465. */
  44466. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  44467. /**
  44468. * Instantiates a new Lens Flare.
  44469. * This represents one of the lens effect in a `lensFlareSystem`.
  44470. * It controls one of the indiviual texture used in the effect.
  44471. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44472. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  44473. * @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.
  44474. * @param color Define the lens color
  44475. * @param imgUrl Define the lens texture url
  44476. * @param system Define the `lensFlareSystem` this flare is part of
  44477. */
  44478. constructor(
  44479. /**
  44480. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  44481. */
  44482. size: number,
  44483. /**
  44484. * 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.
  44485. */
  44486. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  44487. /**
  44488. * Dispose and release the lens flare with its associated resources.
  44489. */
  44490. dispose(): void;
  44491. }
  44492. }
  44493. declare module BABYLON {
  44494. interface AbstractScene {
  44495. /**
  44496. * The list of lens flare system added to the scene
  44497. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44498. */
  44499. lensFlareSystems: Array<LensFlareSystem>;
  44500. /**
  44501. * Removes the given lens flare system from this scene.
  44502. * @param toRemove The lens flare system to remove
  44503. * @returns The index of the removed lens flare system
  44504. */
  44505. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  44506. /**
  44507. * Adds the given lens flare system to this scene
  44508. * @param newLensFlareSystem The lens flare system to add
  44509. */
  44510. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  44511. /**
  44512. * Gets a lens flare system using its name
  44513. * @param name defines the name to look for
  44514. * @returns the lens flare system or null if not found
  44515. */
  44516. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  44517. /**
  44518. * Gets a lens flare system using its id
  44519. * @param id defines the id to look for
  44520. * @returns the lens flare system or null if not found
  44521. */
  44522. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  44523. }
  44524. /**
  44525. * Defines the lens flare scene component responsible to manage any lens flares
  44526. * in a given scene.
  44527. */
  44528. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  44529. /**
  44530. * The component name helpfull to identify the component in the list of scene components.
  44531. */
  44532. readonly name: string;
  44533. /**
  44534. * The scene the component belongs to.
  44535. */
  44536. scene: Scene;
  44537. /**
  44538. * Creates a new instance of the component for the given scene
  44539. * @param scene Defines the scene to register the component in
  44540. */
  44541. constructor(scene: Scene);
  44542. /**
  44543. * Registers the component in a given scene
  44544. */
  44545. register(): void;
  44546. /**
  44547. * Rebuilds the elements related to this component in case of
  44548. * context lost for instance.
  44549. */
  44550. rebuild(): void;
  44551. /**
  44552. * Adds all the element from the container to the scene
  44553. * @param container the container holding the elements
  44554. */
  44555. addFromContainer(container: AbstractScene): void;
  44556. /**
  44557. * Removes all the elements in the container from the scene
  44558. * @param container contains the elements to remove
  44559. */
  44560. removeFromContainer(container: AbstractScene): void;
  44561. /**
  44562. * Serializes the component data to the specified json object
  44563. * @param serializationObject The object to serialize to
  44564. */
  44565. serialize(serializationObject: any): void;
  44566. /**
  44567. * Disposes the component and the associated ressources.
  44568. */
  44569. dispose(): void;
  44570. private _draw;
  44571. }
  44572. }
  44573. declare module BABYLON {
  44574. /**
  44575. * Defines the shadow generator component responsible to manage any shadow generators
  44576. * in a given scene.
  44577. */
  44578. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44579. /**
  44580. * The component name helpfull to identify the component in the list of scene components.
  44581. */
  44582. readonly name: string;
  44583. /**
  44584. * The scene the component belongs to.
  44585. */
  44586. scene: Scene;
  44587. /**
  44588. * Creates a new instance of the component for the given scene
  44589. * @param scene Defines the scene to register the component in
  44590. */
  44591. constructor(scene: Scene);
  44592. /**
  44593. * Registers the component in a given scene
  44594. */
  44595. register(): void;
  44596. /**
  44597. * Rebuilds the elements related to this component in case of
  44598. * context lost for instance.
  44599. */
  44600. rebuild(): void;
  44601. /**
  44602. * Serializes the component data to the specified json object
  44603. * @param serializationObject The object to serialize to
  44604. */
  44605. serialize(serializationObject: any): void;
  44606. /**
  44607. * Adds all the element from the container to the scene
  44608. * @param container the container holding the elements
  44609. */
  44610. addFromContainer(container: AbstractScene): void;
  44611. /**
  44612. * Removes all the elements in the container from the scene
  44613. * @param container contains the elements to remove
  44614. */
  44615. removeFromContainer(container: AbstractScene): void;
  44616. /**
  44617. * Rebuilds the elements related to this component in case of
  44618. * context lost for instance.
  44619. */
  44620. dispose(): void;
  44621. private _gatherRenderTargets;
  44622. }
  44623. }
  44624. declare module BABYLON {
  44625. /**
  44626. * A directional light is defined by a direction (what a surprise!).
  44627. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44628. * 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.
  44629. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44630. */
  44631. export class DirectionalLight extends ShadowLight {
  44632. private _shadowFrustumSize;
  44633. /**
  44634. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44635. */
  44636. /**
  44637. * Specifies a fix frustum size for the shadow generation.
  44638. */
  44639. shadowFrustumSize: number;
  44640. private _shadowOrthoScale;
  44641. /**
  44642. * Gets the shadow projection scale against the optimal computed one.
  44643. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44644. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44645. */
  44646. /**
  44647. * Sets the shadow projection scale against the optimal computed one.
  44648. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44649. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44650. */
  44651. shadowOrthoScale: number;
  44652. /**
  44653. * Automatically compute the projection matrix to best fit (including all the casters)
  44654. * on each frame.
  44655. */
  44656. autoUpdateExtends: boolean;
  44657. private _orthoLeft;
  44658. private _orthoRight;
  44659. private _orthoTop;
  44660. private _orthoBottom;
  44661. /**
  44662. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44663. * The directional light is emitted from everywhere in the given direction.
  44664. * It can cast shadows.
  44665. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44666. * @param name The friendly name of the light
  44667. * @param direction The direction of the light
  44668. * @param scene The scene the light belongs to
  44669. */
  44670. constructor(name: string, direction: Vector3, scene: Scene);
  44671. /**
  44672. * Returns the string "DirectionalLight".
  44673. * @return The class name
  44674. */
  44675. getClassName(): string;
  44676. /**
  44677. * Returns the integer 1.
  44678. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44679. */
  44680. getTypeID(): number;
  44681. /**
  44682. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44683. * Returns the DirectionalLight Shadow projection matrix.
  44684. */
  44685. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44686. /**
  44687. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44688. * Returns the DirectionalLight Shadow projection matrix.
  44689. */
  44690. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44691. /**
  44692. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44693. * Returns the DirectionalLight Shadow projection matrix.
  44694. */
  44695. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44696. protected _buildUniformLayout(): void;
  44697. /**
  44698. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44699. * @param effect The effect to update
  44700. * @param lightIndex The index of the light in the effect to update
  44701. * @returns The directional light
  44702. */
  44703. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44704. /**
  44705. * Gets the minZ used for shadow according to both the scene and the light.
  44706. *
  44707. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44708. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44709. * @param activeCamera The camera we are returning the min for
  44710. * @returns the depth min z
  44711. */
  44712. getDepthMinZ(activeCamera: Camera): number;
  44713. /**
  44714. * Gets the maxZ used for shadow according to both the scene and the light.
  44715. *
  44716. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44717. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44718. * @param activeCamera The camera we are returning the max for
  44719. * @returns the depth max z
  44720. */
  44721. getDepthMaxZ(activeCamera: Camera): number;
  44722. /**
  44723. * Prepares the list of defines specific to the light type.
  44724. * @param defines the list of defines
  44725. * @param lightIndex defines the index of the light for the effect
  44726. */
  44727. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44728. }
  44729. }
  44730. declare module BABYLON {
  44731. /**
  44732. * A point light is a light defined by an unique point in world space.
  44733. * The light is emitted in every direction from this point.
  44734. * A good example of a point light is a standard light bulb.
  44735. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44736. */
  44737. export class PointLight extends ShadowLight {
  44738. private _shadowAngle;
  44739. /**
  44740. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44741. * This specifies what angle the shadow will use to be created.
  44742. *
  44743. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  44744. */
  44745. /**
  44746. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44747. * This specifies what angle the shadow will use to be created.
  44748. *
  44749. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  44750. */
  44751. shadowAngle: number;
  44752. /**
  44753. * Gets the direction if it has been set.
  44754. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44755. */
  44756. /**
  44757. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44758. */
  44759. direction: Vector3;
  44760. /**
  44761. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  44762. * A PointLight emits the light in every direction.
  44763. * It can cast shadows.
  44764. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  44765. * ```javascript
  44766. * var pointLight = new PointLight("pl", camera.position, scene);
  44767. * ```
  44768. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44769. * @param name The light friendly name
  44770. * @param position The position of the point light in the scene
  44771. * @param scene The scene the lights belongs to
  44772. */
  44773. constructor(name: string, position: Vector3, scene: Scene);
  44774. /**
  44775. * Returns the string "PointLight"
  44776. * @returns the class name
  44777. */
  44778. getClassName(): string;
  44779. /**
  44780. * Returns the integer 0.
  44781. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44782. */
  44783. getTypeID(): number;
  44784. /**
  44785. * Specifies wether or not the shadowmap should be a cube texture.
  44786. * @returns true if the shadowmap needs to be a cube texture.
  44787. */
  44788. needCube(): boolean;
  44789. /**
  44790. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  44791. * @param faceIndex The index of the face we are computed the direction to generate shadow
  44792. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  44793. */
  44794. getShadowDirection(faceIndex?: number): Vector3;
  44795. /**
  44796. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  44797. * - fov = PI / 2
  44798. * - aspect ratio : 1.0
  44799. * - z-near and far equal to the active camera minZ and maxZ.
  44800. * Returns the PointLight.
  44801. */
  44802. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44803. protected _buildUniformLayout(): void;
  44804. /**
  44805. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  44806. * @param effect The effect to update
  44807. * @param lightIndex The index of the light in the effect to update
  44808. * @returns The point light
  44809. */
  44810. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  44811. /**
  44812. * Prepares the list of defines specific to the light type.
  44813. * @param defines the list of defines
  44814. * @param lightIndex defines the index of the light for the effect
  44815. */
  44816. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44817. }
  44818. }
  44819. declare module BABYLON {
  44820. /**
  44821. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44822. * These values define a cone of light starting from the position, emitting toward the direction.
  44823. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44824. * and the exponent defines the speed of the decay of the light with distance (reach).
  44825. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44826. */
  44827. export class SpotLight extends ShadowLight {
  44828. private _angle;
  44829. private _innerAngle;
  44830. private _cosHalfAngle;
  44831. private _lightAngleScale;
  44832. private _lightAngleOffset;
  44833. /**
  44834. * Gets the cone angle of the spot light in Radians.
  44835. */
  44836. /**
  44837. * Sets the cone angle of the spot light in Radians.
  44838. */
  44839. angle: number;
  44840. /**
  44841. * Only used in gltf falloff mode, this defines the angle where
  44842. * the directional falloff will start before cutting at angle which could be seen
  44843. * as outer angle.
  44844. */
  44845. /**
  44846. * Only used in gltf falloff mode, this defines the angle where
  44847. * the directional falloff will start before cutting at angle which could be seen
  44848. * as outer angle.
  44849. */
  44850. innerAngle: number;
  44851. private _shadowAngleScale;
  44852. /**
  44853. * Allows scaling the angle of the light for shadow generation only.
  44854. */
  44855. /**
  44856. * Allows scaling the angle of the light for shadow generation only.
  44857. */
  44858. shadowAngleScale: number;
  44859. /**
  44860. * The light decay speed with the distance from the emission spot.
  44861. */
  44862. exponent: number;
  44863. private _projectionTextureMatrix;
  44864. /**
  44865. * Allows reading the projecton texture
  44866. */
  44867. readonly projectionTextureMatrix: Matrix;
  44868. protected _projectionTextureLightNear: number;
  44869. /**
  44870. * Gets the near clip of the Spotlight for texture projection.
  44871. */
  44872. /**
  44873. * Sets the near clip of the Spotlight for texture projection.
  44874. */
  44875. projectionTextureLightNear: number;
  44876. protected _projectionTextureLightFar: number;
  44877. /**
  44878. * Gets the far clip of the Spotlight for texture projection.
  44879. */
  44880. /**
  44881. * Sets the far clip of the Spotlight for texture projection.
  44882. */
  44883. projectionTextureLightFar: number;
  44884. protected _projectionTextureUpDirection: Vector3;
  44885. /**
  44886. * Gets the Up vector of the Spotlight for texture projection.
  44887. */
  44888. /**
  44889. * Sets the Up vector of the Spotlight for texture projection.
  44890. */
  44891. projectionTextureUpDirection: Vector3;
  44892. private _projectionTexture;
  44893. /**
  44894. * Gets the projection texture of the light.
  44895. */
  44896. /**
  44897. * Sets the projection texture of the light.
  44898. */
  44899. projectionTexture: Nullable<BaseTexture>;
  44900. private _projectionTextureViewLightDirty;
  44901. private _projectionTextureProjectionLightDirty;
  44902. private _projectionTextureDirty;
  44903. private _projectionTextureViewTargetVector;
  44904. private _projectionTextureViewLightMatrix;
  44905. private _projectionTextureProjectionLightMatrix;
  44906. private _projectionTextureScalingMatrix;
  44907. /**
  44908. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44909. * It can cast shadows.
  44910. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44911. * @param name The light friendly name
  44912. * @param position The position of the spot light in the scene
  44913. * @param direction The direction of the light in the scene
  44914. * @param angle The cone angle of the light in Radians
  44915. * @param exponent The light decay speed with the distance from the emission spot
  44916. * @param scene The scene the lights belongs to
  44917. */
  44918. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44919. /**
  44920. * Returns the string "SpotLight".
  44921. * @returns the class name
  44922. */
  44923. getClassName(): string;
  44924. /**
  44925. * Returns the integer 2.
  44926. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44927. */
  44928. getTypeID(): number;
  44929. /**
  44930. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44931. */
  44932. protected _setDirection(value: Vector3): void;
  44933. /**
  44934. * Overrides the position setter to recompute the projection texture view light Matrix.
  44935. */
  44936. protected _setPosition(value: Vector3): void;
  44937. /**
  44938. * 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.
  44939. * Returns the SpotLight.
  44940. */
  44941. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44942. protected _computeProjectionTextureViewLightMatrix(): void;
  44943. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44944. /**
  44945. * Main function for light texture projection matrix computing.
  44946. */
  44947. protected _computeProjectionTextureMatrix(): void;
  44948. protected _buildUniformLayout(): void;
  44949. private _computeAngleValues;
  44950. /**
  44951. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44952. * @param effect The effect to update
  44953. * @param lightIndex The index of the light in the effect to update
  44954. * @returns The spot light
  44955. */
  44956. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44957. /**
  44958. * Disposes the light and the associated resources.
  44959. */
  44960. dispose(): void;
  44961. /**
  44962. * Prepares the list of defines specific to the light type.
  44963. * @param defines the list of defines
  44964. * @param lightIndex defines the index of the light for the effect
  44965. */
  44966. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44967. }
  44968. }
  44969. declare module BABYLON {
  44970. /**
  44971. * Header information of HDR texture files.
  44972. */
  44973. export interface HDRInfo {
  44974. /**
  44975. * The height of the texture in pixels.
  44976. */
  44977. height: number;
  44978. /**
  44979. * The width of the texture in pixels.
  44980. */
  44981. width: number;
  44982. /**
  44983. * The index of the beginning of the data in the binary file.
  44984. */
  44985. dataPosition: number;
  44986. }
  44987. /**
  44988. * This groups tools to convert HDR texture to native colors array.
  44989. */
  44990. export class HDRTools {
  44991. private static Ldexp;
  44992. private static Rgbe2float;
  44993. private static readStringLine;
  44994. /**
  44995. * Reads header information from an RGBE texture stored in a native array.
  44996. * More information on this format are available here:
  44997. * https://en.wikipedia.org/wiki/RGBE_image_format
  44998. *
  44999. * @param uint8array The binary file stored in native array.
  45000. * @return The header information.
  45001. */
  45002. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  45003. /**
  45004. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  45005. * This RGBE texture needs to store the information as a panorama.
  45006. *
  45007. * More information on this format are available here:
  45008. * https://en.wikipedia.org/wiki/RGBE_image_format
  45009. *
  45010. * @param buffer The binary file stored in an array buffer.
  45011. * @param size The expected size of the extracted cubemap.
  45012. * @return The Cube Map information.
  45013. */
  45014. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  45015. /**
  45016. * Returns the pixels data extracted from an RGBE texture.
  45017. * This pixels will be stored left to right up to down in the R G B order in one array.
  45018. *
  45019. * More information on this format are available here:
  45020. * https://en.wikipedia.org/wiki/RGBE_image_format
  45021. *
  45022. * @param uint8array The binary file stored in an array buffer.
  45023. * @param hdrInfo The header information of the file.
  45024. * @return The pixels data in RGB right to left up to down order.
  45025. */
  45026. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  45027. private static RGBE_ReadPixels_RLE;
  45028. }
  45029. }
  45030. declare module BABYLON {
  45031. /**
  45032. * This represents a texture coming from an HDR input.
  45033. *
  45034. * The only supported format is currently panorama picture stored in RGBE format.
  45035. * Example of such files can be found on HDRLib: http://hdrlib.com/
  45036. */
  45037. export class HDRCubeTexture extends BaseTexture {
  45038. private static _facesMapping;
  45039. private _generateHarmonics;
  45040. private _noMipmap;
  45041. private _textureMatrix;
  45042. private _size;
  45043. private _onLoad;
  45044. private _onError;
  45045. /**
  45046. * The texture URL.
  45047. */
  45048. url: string;
  45049. /**
  45050. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  45051. */
  45052. coordinatesMode: number;
  45053. protected _isBlocking: boolean;
  45054. /**
  45055. * Sets wether or not the texture is blocking during loading.
  45056. */
  45057. /**
  45058. * Gets wether or not the texture is blocking during loading.
  45059. */
  45060. isBlocking: boolean;
  45061. protected _rotationY: number;
  45062. /**
  45063. * Sets texture matrix rotation angle around Y axis in radians.
  45064. */
  45065. /**
  45066. * Gets texture matrix rotation angle around Y axis radians.
  45067. */
  45068. rotationY: number;
  45069. /**
  45070. * Gets or sets the center of the bounding box associated with the cube texture
  45071. * It must define where the camera used to render the texture was set
  45072. */
  45073. boundingBoxPosition: Vector3;
  45074. private _boundingBoxSize;
  45075. /**
  45076. * Gets or sets the size of the bounding box associated with the cube texture
  45077. * When defined, the cubemap will switch to local mode
  45078. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45079. * @example https://www.babylonjs-playground.com/#RNASML
  45080. */
  45081. boundingBoxSize: Vector3;
  45082. /**
  45083. * Instantiates an HDRTexture from the following parameters.
  45084. *
  45085. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  45086. * @param scene The scene the texture will be used in
  45087. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  45088. * @param noMipmap Forces to not generate the mipmap if true
  45089. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  45090. * @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)
  45091. * @param reserved Reserved flag for internal use.
  45092. */
  45093. 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>);
  45094. /**
  45095. * Get the current class name of the texture useful for serialization or dynamic coding.
  45096. * @returns "HDRCubeTexture"
  45097. */
  45098. getClassName(): string;
  45099. /**
  45100. * Occurs when the file is raw .hdr file.
  45101. */
  45102. private loadTexture;
  45103. clone(): HDRCubeTexture;
  45104. delayLoad(): void;
  45105. /**
  45106. * Get the texture reflection matrix used to rotate/transform the reflection.
  45107. * @returns the reflection matrix
  45108. */
  45109. getReflectionTextureMatrix(): Matrix;
  45110. /**
  45111. * Set the texture reflection matrix used to rotate/transform the reflection.
  45112. * @param value Define the reflection matrix to set
  45113. */
  45114. setReflectionTextureMatrix(value: Matrix): void;
  45115. /**
  45116. * Parses a JSON representation of an HDR Texture in order to create the texture
  45117. * @param parsedTexture Define the JSON representation
  45118. * @param scene Define the scene the texture should be created in
  45119. * @param rootUrl Define the root url in case we need to load relative dependencies
  45120. * @returns the newly created texture after parsing
  45121. */
  45122. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  45123. serialize(): any;
  45124. }
  45125. }
  45126. declare module BABYLON {
  45127. /**
  45128. * Class used to control physics engine
  45129. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  45130. */
  45131. export class PhysicsEngine implements IPhysicsEngine {
  45132. private _physicsPlugin;
  45133. /**
  45134. * Global value used to control the smallest number supported by the simulation
  45135. */
  45136. static Epsilon: number;
  45137. private _impostors;
  45138. private _joints;
  45139. /**
  45140. * Gets the gravity vector used by the simulation
  45141. */
  45142. gravity: Vector3;
  45143. /**
  45144. * Factory used to create the default physics plugin.
  45145. * @returns The default physics plugin
  45146. */
  45147. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  45148. /**
  45149. * Creates a new Physics Engine
  45150. * @param gravity defines the gravity vector used by the simulation
  45151. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  45152. */
  45153. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  45154. /**
  45155. * Sets the gravity vector used by the simulation
  45156. * @param gravity defines the gravity vector to use
  45157. */
  45158. setGravity(gravity: Vector3): void;
  45159. /**
  45160. * Set the time step of the physics engine.
  45161. * Default is 1/60.
  45162. * To slow it down, enter 1/600 for example.
  45163. * To speed it up, 1/30
  45164. * @param newTimeStep defines the new timestep to apply to this world.
  45165. */
  45166. setTimeStep(newTimeStep?: number): void;
  45167. /**
  45168. * Get the time step of the physics engine.
  45169. * @returns the current time step
  45170. */
  45171. getTimeStep(): number;
  45172. /**
  45173. * Release all resources
  45174. */
  45175. dispose(): void;
  45176. /**
  45177. * Gets the name of the current physics plugin
  45178. * @returns the name of the plugin
  45179. */
  45180. getPhysicsPluginName(): string;
  45181. /**
  45182. * Adding a new impostor for the impostor tracking.
  45183. * This will be done by the impostor itself.
  45184. * @param impostor the impostor to add
  45185. */
  45186. addImpostor(impostor: PhysicsImpostor): void;
  45187. /**
  45188. * Remove an impostor from the engine.
  45189. * This impostor and its mesh will not longer be updated by the physics engine.
  45190. * @param impostor the impostor to remove
  45191. */
  45192. removeImpostor(impostor: PhysicsImpostor): void;
  45193. /**
  45194. * Add a joint to the physics engine
  45195. * @param mainImpostor defines the main impostor to which the joint is added.
  45196. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  45197. * @param joint defines the joint that will connect both impostors.
  45198. */
  45199. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  45200. /**
  45201. * Removes a joint from the simulation
  45202. * @param mainImpostor defines the impostor used with the joint
  45203. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  45204. * @param joint defines the joint to remove
  45205. */
  45206. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  45207. /**
  45208. * Called by the scene. No need to call it.
  45209. * @param delta defines the timespam between frames
  45210. */
  45211. _step(delta: number): void;
  45212. /**
  45213. * Gets the current plugin used to run the simulation
  45214. * @returns current plugin
  45215. */
  45216. getPhysicsPlugin(): IPhysicsEnginePlugin;
  45217. /**
  45218. * Gets the list of physic impostors
  45219. * @returns an array of PhysicsImpostor
  45220. */
  45221. getImpostors(): Array<PhysicsImpostor>;
  45222. /**
  45223. * Gets the impostor for a physics enabled object
  45224. * @param object defines the object impersonated by the impostor
  45225. * @returns the PhysicsImpostor or null if not found
  45226. */
  45227. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  45228. /**
  45229. * Gets the impostor for a physics body object
  45230. * @param body defines physics body used by the impostor
  45231. * @returns the PhysicsImpostor or null if not found
  45232. */
  45233. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  45234. }
  45235. }
  45236. declare module BABYLON {
  45237. /** @hidden */
  45238. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  45239. private _useDeltaForWorldStep;
  45240. world: any;
  45241. name: string;
  45242. private _physicsMaterials;
  45243. private _fixedTimeStep;
  45244. BJSCANNON: any;
  45245. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  45246. setGravity(gravity: Vector3): void;
  45247. setTimeStep(timeStep: number): void;
  45248. getTimeStep(): number;
  45249. executeStep(delta: number): void;
  45250. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45251. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45252. generatePhysicsBody(impostor: PhysicsImpostor): void;
  45253. private _processChildMeshes;
  45254. removePhysicsBody(impostor: PhysicsImpostor): void;
  45255. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  45256. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  45257. private _addMaterial;
  45258. private _checkWithEpsilon;
  45259. private _createShape;
  45260. private _createHeightmap;
  45261. private _minus90X;
  45262. private _plus90X;
  45263. private _tmpPosition;
  45264. private _tmpDeltaPosition;
  45265. private _tmpUnityRotation;
  45266. private _updatePhysicsBodyTransformation;
  45267. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  45268. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  45269. isSupported(): boolean;
  45270. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45271. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45272. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45273. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45274. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  45275. getBodyMass(impostor: PhysicsImpostor): number;
  45276. getBodyFriction(impostor: PhysicsImpostor): number;
  45277. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  45278. getBodyRestitution(impostor: PhysicsImpostor): number;
  45279. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  45280. sleepBody(impostor: PhysicsImpostor): void;
  45281. wakeUpBody(impostor: PhysicsImpostor): void;
  45282. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  45283. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  45284. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  45285. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  45286. getRadius(impostor: PhysicsImpostor): number;
  45287. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  45288. dispose(): void;
  45289. private _extendNamespace;
  45290. }
  45291. }
  45292. declare module BABYLON {
  45293. /** @hidden */
  45294. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  45295. world: any;
  45296. name: string;
  45297. BJSOIMO: any;
  45298. constructor(iterations?: number, oimoInjection?: any);
  45299. setGravity(gravity: Vector3): void;
  45300. setTimeStep(timeStep: number): void;
  45301. getTimeStep(): number;
  45302. private _tmpImpostorsArray;
  45303. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  45304. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45305. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45306. generatePhysicsBody(impostor: PhysicsImpostor): void;
  45307. private _tmpPositionVector;
  45308. removePhysicsBody(impostor: PhysicsImpostor): void;
  45309. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  45310. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  45311. isSupported(): boolean;
  45312. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  45313. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  45314. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45315. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45316. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45317. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45318. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  45319. getBodyMass(impostor: PhysicsImpostor): number;
  45320. getBodyFriction(impostor: PhysicsImpostor): number;
  45321. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  45322. getBodyRestitution(impostor: PhysicsImpostor): number;
  45323. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  45324. sleepBody(impostor: PhysicsImpostor): void;
  45325. wakeUpBody(impostor: PhysicsImpostor): void;
  45326. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  45327. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  45328. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  45329. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  45330. getRadius(impostor: PhysicsImpostor): number;
  45331. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  45332. dispose(): void;
  45333. }
  45334. }
  45335. declare module BABYLON {
  45336. interface AbstractScene {
  45337. /**
  45338. * The list of reflection probes added to the scene
  45339. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  45340. */
  45341. reflectionProbes: Array<ReflectionProbe>;
  45342. /**
  45343. * Removes the given reflection probe from this scene.
  45344. * @param toRemove The reflection probe to remove
  45345. * @returns The index of the removed reflection probe
  45346. */
  45347. removeReflectionProbe(toRemove: ReflectionProbe): number;
  45348. /**
  45349. * Adds the given reflection probe to this scene.
  45350. * @param newReflectionProbe The reflection probe to add
  45351. */
  45352. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  45353. }
  45354. /**
  45355. * Class used to generate realtime reflection / refraction cube textures
  45356. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  45357. */
  45358. export class ReflectionProbe {
  45359. /** defines the name of the probe */
  45360. name: string;
  45361. private _scene;
  45362. private _renderTargetTexture;
  45363. private _projectionMatrix;
  45364. private _viewMatrix;
  45365. private _target;
  45366. private _add;
  45367. private _attachedMesh;
  45368. private _invertYAxis;
  45369. /** Gets or sets probe position (center of the cube map) */
  45370. position: Vector3;
  45371. /**
  45372. * Creates a new reflection probe
  45373. * @param name defines the name of the probe
  45374. * @param size defines the texture resolution (for each face)
  45375. * @param scene defines the hosting scene
  45376. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  45377. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  45378. */
  45379. constructor(
  45380. /** defines the name of the probe */
  45381. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  45382. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  45383. samples: number;
  45384. /** Gets or sets the refresh rate to use (on every frame by default) */
  45385. refreshRate: number;
  45386. /**
  45387. * Gets the hosting scene
  45388. * @returns a Scene
  45389. */
  45390. getScene(): Scene;
  45391. /** Gets the internal CubeTexture used to render to */
  45392. readonly cubeTexture: RenderTargetTexture;
  45393. /** Gets the list of meshes to render */
  45394. readonly renderList: Nullable<AbstractMesh[]>;
  45395. /**
  45396. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  45397. * @param mesh defines the mesh to attach to
  45398. */
  45399. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45400. /**
  45401. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  45402. * @param renderingGroupId The rendering group id corresponding to its index
  45403. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  45404. */
  45405. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  45406. /**
  45407. * Clean all associated resources
  45408. */
  45409. dispose(): void;
  45410. /**
  45411. * Converts the reflection probe information to a readable string for debug purpose.
  45412. * @param fullDetails Supports for multiple levels of logging within scene loading
  45413. * @returns the human readable reflection probe info
  45414. */
  45415. toString(fullDetails?: boolean): string;
  45416. /**
  45417. * Get the class name of the relfection probe.
  45418. * @returns "ReflectionProbe"
  45419. */
  45420. getClassName(): string;
  45421. /**
  45422. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  45423. * @returns The JSON representation of the texture
  45424. */
  45425. serialize(): any;
  45426. /**
  45427. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  45428. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  45429. * @param scene Define the scene the parsed reflection probe should be instantiated in
  45430. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  45431. * @returns The parsed reflection probe if successful
  45432. */
  45433. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  45434. }
  45435. }
  45436. declare module BABYLON {
  45437. /** @hidden */
  45438. export var _BabylonLoaderRegistered: boolean;
  45439. }
  45440. declare module BABYLON {
  45441. /**
  45442. * The Physically based simple base material of BJS.
  45443. *
  45444. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45445. * It is used as the base class for both the specGloss and metalRough conventions.
  45446. */
  45447. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45448. /**
  45449. * Number of Simultaneous lights allowed on the material.
  45450. */
  45451. maxSimultaneousLights: number;
  45452. /**
  45453. * If sets to true, disables all the lights affecting the material.
  45454. */
  45455. disableLighting: boolean;
  45456. /**
  45457. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45458. */
  45459. environmentTexture: BaseTexture;
  45460. /**
  45461. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45462. */
  45463. invertNormalMapX: boolean;
  45464. /**
  45465. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45466. */
  45467. invertNormalMapY: boolean;
  45468. /**
  45469. * Normal map used in the model.
  45470. */
  45471. normalTexture: BaseTexture;
  45472. /**
  45473. * Emissivie color used to self-illuminate the model.
  45474. */
  45475. emissiveColor: Color3;
  45476. /**
  45477. * Emissivie texture used to self-illuminate the model.
  45478. */
  45479. emissiveTexture: BaseTexture;
  45480. /**
  45481. * Occlusion Channel Strenght.
  45482. */
  45483. occlusionStrength: number;
  45484. /**
  45485. * Occlusion Texture of the material (adding extra occlusion effects).
  45486. */
  45487. occlusionTexture: BaseTexture;
  45488. /**
  45489. * Defines the alpha limits in alpha test mode.
  45490. */
  45491. alphaCutOff: number;
  45492. /**
  45493. * Gets the current double sided mode.
  45494. */
  45495. /**
  45496. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45497. */
  45498. doubleSided: boolean;
  45499. /**
  45500. * Stores the pre-calculated light information of a mesh in a texture.
  45501. */
  45502. lightmapTexture: BaseTexture;
  45503. /**
  45504. * If true, the light map contains occlusion information instead of lighting info.
  45505. */
  45506. useLightmapAsShadowmap: boolean;
  45507. /**
  45508. * Return the active textures of the material.
  45509. */
  45510. getActiveTextures(): BaseTexture[];
  45511. hasTexture(texture: BaseTexture): boolean;
  45512. /**
  45513. * Instantiates a new PBRMaterial instance.
  45514. *
  45515. * @param name The material name
  45516. * @param scene The scene the material will be use in.
  45517. */
  45518. constructor(name: string, scene: Scene);
  45519. getClassName(): string;
  45520. }
  45521. }
  45522. declare module BABYLON {
  45523. /**
  45524. * The PBR material of BJS following the metal roughness convention.
  45525. *
  45526. * This fits to the PBR convention in the GLTF definition:
  45527. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  45528. */
  45529. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  45530. /**
  45531. * The base color has two different interpretations depending on the value of metalness.
  45532. * When the material is a metal, the base color is the specific measured reflectance value
  45533. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  45534. * of the material.
  45535. */
  45536. baseColor: Color3;
  45537. /**
  45538. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  45539. * well as opacity information in the alpha channel.
  45540. */
  45541. baseTexture: BaseTexture;
  45542. /**
  45543. * Specifies the metallic scalar value of the material.
  45544. * Can also be used to scale the metalness values of the metallic texture.
  45545. */
  45546. metallic: number;
  45547. /**
  45548. * Specifies the roughness scalar value of the material.
  45549. * Can also be used to scale the roughness values of the metallic texture.
  45550. */
  45551. roughness: number;
  45552. /**
  45553. * Texture containing both the metallic value in the B channel and the
  45554. * roughness value in the G channel to keep better precision.
  45555. */
  45556. metallicRoughnessTexture: BaseTexture;
  45557. /**
  45558. * Instantiates a new PBRMetalRoughnessMaterial instance.
  45559. *
  45560. * @param name The material name
  45561. * @param scene The scene the material will be use in.
  45562. */
  45563. constructor(name: string, scene: Scene);
  45564. /**
  45565. * Return the currrent class name of the material.
  45566. */
  45567. getClassName(): string;
  45568. /**
  45569. * Return the active textures of the material.
  45570. */
  45571. getActiveTextures(): BaseTexture[];
  45572. /**
  45573. * Checks to see if a texture is used in the material.
  45574. * @param texture - Base texture to use.
  45575. * @returns - Boolean specifying if a texture is used in the material.
  45576. */
  45577. hasTexture(texture: BaseTexture): boolean;
  45578. /**
  45579. * Makes a duplicate of the current material.
  45580. * @param name - name to use for the new material.
  45581. */
  45582. clone(name: string): PBRMetallicRoughnessMaterial;
  45583. /**
  45584. * Serialize the material to a parsable JSON object.
  45585. */
  45586. serialize(): any;
  45587. /**
  45588. * Parses a JSON object correponding to the serialize function.
  45589. */
  45590. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  45591. }
  45592. }
  45593. declare module BABYLON {
  45594. /**
  45595. * The PBR material of BJS following the specular glossiness convention.
  45596. *
  45597. * This fits to the PBR convention in the GLTF definition:
  45598. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  45599. */
  45600. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  45601. /**
  45602. * Specifies the diffuse color of the material.
  45603. */
  45604. diffuseColor: Color3;
  45605. /**
  45606. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  45607. * channel.
  45608. */
  45609. diffuseTexture: BaseTexture;
  45610. /**
  45611. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  45612. */
  45613. specularColor: Color3;
  45614. /**
  45615. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  45616. */
  45617. glossiness: number;
  45618. /**
  45619. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  45620. */
  45621. specularGlossinessTexture: BaseTexture;
  45622. /**
  45623. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  45624. *
  45625. * @param name The material name
  45626. * @param scene The scene the material will be use in.
  45627. */
  45628. constructor(name: string, scene: Scene);
  45629. /**
  45630. * Return the currrent class name of the material.
  45631. */
  45632. getClassName(): string;
  45633. /**
  45634. * Return the active textures of the material.
  45635. */
  45636. getActiveTextures(): BaseTexture[];
  45637. /**
  45638. * Checks to see if a texture is used in the material.
  45639. * @param texture - Base texture to use.
  45640. * @returns - Boolean specifying if a texture is used in the material.
  45641. */
  45642. hasTexture(texture: BaseTexture): boolean;
  45643. /**
  45644. * Makes a duplicate of the current material.
  45645. * @param name - name to use for the new material.
  45646. */
  45647. clone(name: string): PBRSpecularGlossinessMaterial;
  45648. /**
  45649. * Serialize the material to a parsable JSON object.
  45650. */
  45651. serialize(): any;
  45652. /**
  45653. * Parses a JSON object correponding to the serialize function.
  45654. */
  45655. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  45656. }
  45657. }
  45658. declare module BABYLON {
  45659. /**
  45660. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  45661. * It can help converting any input color in a desired output one. This can then be used to create effects
  45662. * from sepia, black and white to sixties or futuristic rendering...
  45663. *
  45664. * The only supported format is currently 3dl.
  45665. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  45666. */
  45667. export class ColorGradingTexture extends BaseTexture {
  45668. /**
  45669. * The current texture matrix. (will always be identity in color grading texture)
  45670. */
  45671. private _textureMatrix;
  45672. /**
  45673. * The texture URL.
  45674. */
  45675. url: string;
  45676. /**
  45677. * Empty line regex stored for GC.
  45678. */
  45679. private static _noneEmptyLineRegex;
  45680. private _engine;
  45681. /**
  45682. * Instantiates a ColorGradingTexture from the following parameters.
  45683. *
  45684. * @param url The location of the color gradind data (currently only supporting 3dl)
  45685. * @param scene The scene the texture will be used in
  45686. */
  45687. constructor(url: string, scene: Scene);
  45688. /**
  45689. * Returns the texture matrix used in most of the material.
  45690. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  45691. */
  45692. getTextureMatrix(): Matrix;
  45693. /**
  45694. * Occurs when the file being loaded is a .3dl LUT file.
  45695. */
  45696. private load3dlTexture;
  45697. /**
  45698. * Starts the loading process of the texture.
  45699. */
  45700. private loadTexture;
  45701. /**
  45702. * Clones the color gradind texture.
  45703. */
  45704. clone(): ColorGradingTexture;
  45705. /**
  45706. * Called during delayed load for textures.
  45707. */
  45708. delayLoad(): void;
  45709. /**
  45710. * Parses a color grading texture serialized by Babylon.
  45711. * @param parsedTexture The texture information being parsedTexture
  45712. * @param scene The scene to load the texture in
  45713. * @param rootUrl The root url of the data assets to load
  45714. * @return A color gradind texture
  45715. */
  45716. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  45717. /**
  45718. * Serializes the LUT texture to json format.
  45719. */
  45720. serialize(): any;
  45721. }
  45722. }
  45723. declare module BABYLON {
  45724. /**
  45725. * Direct draw surface info
  45726. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45727. */
  45728. export interface DDSInfo {
  45729. /**
  45730. * Width of the texture
  45731. */
  45732. width: number;
  45733. /**
  45734. * Width of the texture
  45735. */
  45736. height: number;
  45737. /**
  45738. * Number of Mipmaps for the texture
  45739. * @see https://en.wikipedia.org/wiki/Mipmap
  45740. */
  45741. mipmapCount: number;
  45742. /**
  45743. * If the textures format is a known fourCC format
  45744. * @see https://www.fourcc.org/
  45745. */
  45746. isFourCC: boolean;
  45747. /**
  45748. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45749. */
  45750. isRGB: boolean;
  45751. /**
  45752. * If the texture is a lumincance format
  45753. */
  45754. isLuminance: boolean;
  45755. /**
  45756. * If this is a cube texture
  45757. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45758. */
  45759. isCube: boolean;
  45760. /**
  45761. * If the texture is a compressed format eg. FOURCC_DXT1
  45762. */
  45763. isCompressed: boolean;
  45764. /**
  45765. * The dxgiFormat of the texture
  45766. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45767. */
  45768. dxgiFormat: number;
  45769. /**
  45770. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45771. */
  45772. textureType: number;
  45773. /**
  45774. * Sphericle polynomial created for the dds texture
  45775. */
  45776. sphericalPolynomial?: SphericalPolynomial;
  45777. }
  45778. /**
  45779. * Class used to provide DDS decompression tools
  45780. */
  45781. export class DDSTools {
  45782. /**
  45783. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45784. */
  45785. static StoreLODInAlphaChannel: boolean;
  45786. /**
  45787. * Gets DDS information from an array buffer
  45788. * @param arrayBuffer defines the array buffer to read data from
  45789. * @returns the DDS information
  45790. */
  45791. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45792. private static _FloatView;
  45793. private static _Int32View;
  45794. private static _ToHalfFloat;
  45795. private static _FromHalfFloat;
  45796. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45797. private static _GetHalfFloatRGBAArrayBuffer;
  45798. private static _GetFloatRGBAArrayBuffer;
  45799. private static _GetFloatAsUIntRGBAArrayBuffer;
  45800. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45801. private static _GetRGBAArrayBuffer;
  45802. private static _ExtractLongWordOrder;
  45803. private static _GetRGBArrayBuffer;
  45804. private static _GetLuminanceArrayBuffer;
  45805. /**
  45806. * Uploads DDS Levels to a Babylon Texture
  45807. * @hidden
  45808. */
  45809. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45810. }
  45811. interface Engine {
  45812. /**
  45813. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45814. * @param rootUrl defines the url where the file to load is located
  45815. * @param scene defines the current scene
  45816. * @param lodScale defines scale to apply to the mip map selection
  45817. * @param lodOffset defines offset to apply to the mip map selection
  45818. * @param onLoad defines an optional callback raised when the texture is loaded
  45819. * @param onError defines an optional callback raised if there is an issue to load the texture
  45820. * @param format defines the format of the data
  45821. * @param forcedExtension defines the extension to use to pick the right loader
  45822. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45823. * @returns the cube texture as an InternalTexture
  45824. */
  45825. 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;
  45826. }
  45827. }
  45828. declare module BABYLON {
  45829. /**
  45830. * Implementation of the DDS Texture Loader.
  45831. * @hidden
  45832. */
  45833. export class _DDSTextureLoader implements IInternalTextureLoader {
  45834. /**
  45835. * Defines wether the loader supports cascade loading the different faces.
  45836. */
  45837. readonly supportCascades: boolean;
  45838. /**
  45839. * This returns if the loader support the current file information.
  45840. * @param extension defines the file extension of the file being loaded
  45841. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45842. * @param fallback defines the fallback internal texture if any
  45843. * @param isBase64 defines whether the texture is encoded as a base64
  45844. * @param isBuffer defines whether the texture data are stored as a buffer
  45845. * @returns true if the loader can load the specified file
  45846. */
  45847. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45848. /**
  45849. * Transform the url before loading if required.
  45850. * @param rootUrl the url of the texture
  45851. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45852. * @returns the transformed texture
  45853. */
  45854. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45855. /**
  45856. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45857. * @param rootUrl the url of the texture
  45858. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45859. * @returns the fallback texture
  45860. */
  45861. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45862. /**
  45863. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45864. * @param data contains the texture data
  45865. * @param texture defines the BabylonJS internal texture
  45866. * @param createPolynomials will be true if polynomials have been requested
  45867. * @param onLoad defines the callback to trigger once the texture is ready
  45868. * @param onError defines the callback to trigger in case of error
  45869. */
  45870. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45871. /**
  45872. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45873. * @param data contains the texture data
  45874. * @param texture defines the BabylonJS internal texture
  45875. * @param callback defines the method to call once ready to upload
  45876. */
  45877. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45878. }
  45879. }
  45880. declare module BABYLON {
  45881. /** @hidden */
  45882. export var rgbdEncodePixelShader: {
  45883. name: string;
  45884. shader: string;
  45885. };
  45886. }
  45887. declare module BABYLON {
  45888. /** @hidden */
  45889. export var rgbdDecodePixelShader: {
  45890. name: string;
  45891. shader: string;
  45892. };
  45893. }
  45894. declare module BABYLON {
  45895. /**
  45896. * Raw texture data and descriptor sufficient for WebGL texture upload
  45897. */
  45898. export interface EnvironmentTextureInfo {
  45899. /**
  45900. * Version of the environment map
  45901. */
  45902. version: number;
  45903. /**
  45904. * Width of image
  45905. */
  45906. width: number;
  45907. /**
  45908. * Irradiance information stored in the file.
  45909. */
  45910. irradiance: any;
  45911. /**
  45912. * Specular information stored in the file.
  45913. */
  45914. specular: any;
  45915. }
  45916. /**
  45917. * Sets of helpers addressing the serialization and deserialization of environment texture
  45918. * stored in a BabylonJS env file.
  45919. * Those files are usually stored as .env files.
  45920. */
  45921. export class EnvironmentTextureTools {
  45922. /**
  45923. * Magic number identifying the env file.
  45924. */
  45925. private static _MagicBytes;
  45926. /**
  45927. * Gets the environment info from an env file.
  45928. * @param data The array buffer containing the .env bytes.
  45929. * @returns the environment file info (the json header) if successfully parsed.
  45930. */
  45931. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45932. /**
  45933. * Creates an environment texture from a loaded cube texture.
  45934. * @param texture defines the cube texture to convert in env file
  45935. * @return a promise containing the environment data if succesfull.
  45936. */
  45937. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45938. /**
  45939. * Creates a JSON representation of the spherical data.
  45940. * @param texture defines the texture containing the polynomials
  45941. * @return the JSON representation of the spherical info
  45942. */
  45943. private static _CreateEnvTextureIrradiance;
  45944. /**
  45945. * Uploads the texture info contained in the env file to the GPU.
  45946. * @param texture defines the internal texture to upload to
  45947. * @param arrayBuffer defines the buffer cotaining the data to load
  45948. * @param info defines the texture info retrieved through the GetEnvInfo method
  45949. * @returns a promise
  45950. */
  45951. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45952. /**
  45953. * Uploads the levels of image data to the GPU.
  45954. * @param texture defines the internal texture to upload to
  45955. * @param imageData defines the array buffer views of image data [mipmap][face]
  45956. * @returns a promise
  45957. */
  45958. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45959. /**
  45960. * Uploads spherical polynomials information to the texture.
  45961. * @param texture defines the texture we are trying to upload the information to
  45962. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45963. */
  45964. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45965. /** @hidden */
  45966. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45967. }
  45968. }
  45969. declare module BABYLON {
  45970. /**
  45971. * Implementation of the ENV Texture Loader.
  45972. * @hidden
  45973. */
  45974. export class _ENVTextureLoader implements IInternalTextureLoader {
  45975. /**
  45976. * Defines wether the loader supports cascade loading the different faces.
  45977. */
  45978. readonly supportCascades: boolean;
  45979. /**
  45980. * This returns if the loader support the current file information.
  45981. * @param extension defines the file extension of the file being loaded
  45982. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45983. * @param fallback defines the fallback internal texture if any
  45984. * @param isBase64 defines whether the texture is encoded as a base64
  45985. * @param isBuffer defines whether the texture data are stored as a buffer
  45986. * @returns true if the loader can load the specified file
  45987. */
  45988. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45989. /**
  45990. * Transform the url before loading if required.
  45991. * @param rootUrl the url of the texture
  45992. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45993. * @returns the transformed texture
  45994. */
  45995. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45996. /**
  45997. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45998. * @param rootUrl the url of the texture
  45999. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46000. * @returns the fallback texture
  46001. */
  46002. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46003. /**
  46004. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46005. * @param data contains the texture data
  46006. * @param texture defines the BabylonJS internal texture
  46007. * @param createPolynomials will be true if polynomials have been requested
  46008. * @param onLoad defines the callback to trigger once the texture is ready
  46009. * @param onError defines the callback to trigger in case of error
  46010. */
  46011. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46012. /**
  46013. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46014. * @param data contains the texture data
  46015. * @param texture defines the BabylonJS internal texture
  46016. * @param callback defines the method to call once ready to upload
  46017. */
  46018. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46019. }
  46020. }
  46021. declare module BABYLON {
  46022. /**
  46023. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46024. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46025. */
  46026. export class KhronosTextureContainer {
  46027. /** contents of the KTX container file */
  46028. arrayBuffer: any;
  46029. private static HEADER_LEN;
  46030. private static COMPRESSED_2D;
  46031. private static COMPRESSED_3D;
  46032. private static TEX_2D;
  46033. private static TEX_3D;
  46034. /**
  46035. * Gets the openGL type
  46036. */
  46037. glType: number;
  46038. /**
  46039. * Gets the openGL type size
  46040. */
  46041. glTypeSize: number;
  46042. /**
  46043. * Gets the openGL format
  46044. */
  46045. glFormat: number;
  46046. /**
  46047. * Gets the openGL internal format
  46048. */
  46049. glInternalFormat: number;
  46050. /**
  46051. * Gets the base internal format
  46052. */
  46053. glBaseInternalFormat: number;
  46054. /**
  46055. * Gets image width in pixel
  46056. */
  46057. pixelWidth: number;
  46058. /**
  46059. * Gets image height in pixel
  46060. */
  46061. pixelHeight: number;
  46062. /**
  46063. * Gets image depth in pixels
  46064. */
  46065. pixelDepth: number;
  46066. /**
  46067. * Gets the number of array elements
  46068. */
  46069. numberOfArrayElements: number;
  46070. /**
  46071. * Gets the number of faces
  46072. */
  46073. numberOfFaces: number;
  46074. /**
  46075. * Gets the number of mipmap levels
  46076. */
  46077. numberOfMipmapLevels: number;
  46078. /**
  46079. * Gets the bytes of key value data
  46080. */
  46081. bytesOfKeyValueData: number;
  46082. /**
  46083. * Gets the load type
  46084. */
  46085. loadType: number;
  46086. /**
  46087. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46088. */
  46089. isInvalid: boolean;
  46090. /**
  46091. * Creates a new KhronosTextureContainer
  46092. * @param arrayBuffer contents of the KTX container file
  46093. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46094. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46095. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46096. */
  46097. constructor(
  46098. /** contents of the KTX container file */
  46099. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46100. /**
  46101. * Uploads KTX content to a Babylon Texture.
  46102. * It is assumed that the texture has already been created & is currently bound
  46103. * @hidden
  46104. */
  46105. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46106. private _upload2DCompressedLevels;
  46107. }
  46108. }
  46109. declare module BABYLON {
  46110. /**
  46111. * Implementation of the KTX Texture Loader.
  46112. * @hidden
  46113. */
  46114. export class _KTXTextureLoader implements IInternalTextureLoader {
  46115. /**
  46116. * Defines wether the loader supports cascade loading the different faces.
  46117. */
  46118. readonly supportCascades: boolean;
  46119. /**
  46120. * This returns if the loader support the current file information.
  46121. * @param extension defines the file extension of the file being loaded
  46122. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46123. * @param fallback defines the fallback internal texture if any
  46124. * @param isBase64 defines whether the texture is encoded as a base64
  46125. * @param isBuffer defines whether the texture data are stored as a buffer
  46126. * @returns true if the loader can load the specified file
  46127. */
  46128. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46129. /**
  46130. * Transform the url before loading if required.
  46131. * @param rootUrl the url of the texture
  46132. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46133. * @returns the transformed texture
  46134. */
  46135. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46136. /**
  46137. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46138. * @param rootUrl the url of the texture
  46139. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46140. * @returns the fallback texture
  46141. */
  46142. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46143. /**
  46144. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46145. * @param data contains the texture data
  46146. * @param texture defines the BabylonJS internal texture
  46147. * @param createPolynomials will be true if polynomials have been requested
  46148. * @param onLoad defines the callback to trigger once the texture is ready
  46149. * @param onError defines the callback to trigger in case of error
  46150. */
  46151. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46152. /**
  46153. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46154. * @param data contains the texture data
  46155. * @param texture defines the BabylonJS internal texture
  46156. * @param callback defines the method to call once ready to upload
  46157. */
  46158. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46159. }
  46160. }
  46161. declare module BABYLON {
  46162. /**
  46163. * Based on jsTGALoader - Javascript loader for TGA file
  46164. * By Vincent Thibault
  46165. * @see http://blog.robrowser.com/javascript-tga-loader.html
  46166. */
  46167. export class TGATools {
  46168. private static _TYPE_INDEXED;
  46169. private static _TYPE_RGB;
  46170. private static _TYPE_GREY;
  46171. private static _TYPE_RLE_INDEXED;
  46172. private static _TYPE_RLE_RGB;
  46173. private static _TYPE_RLE_GREY;
  46174. private static _ORIGIN_MASK;
  46175. private static _ORIGIN_SHIFT;
  46176. private static _ORIGIN_BL;
  46177. private static _ORIGIN_BR;
  46178. private static _ORIGIN_UL;
  46179. private static _ORIGIN_UR;
  46180. /**
  46181. * Gets the header of a TGA file
  46182. * @param data defines the TGA data
  46183. * @returns the header
  46184. */
  46185. static GetTGAHeader(data: Uint8Array): any;
  46186. /**
  46187. * Uploads TGA content to a Babylon Texture
  46188. * @hidden
  46189. */
  46190. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  46191. /** @hidden */
  46192. 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;
  46193. /** @hidden */
  46194. 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;
  46195. /** @hidden */
  46196. 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;
  46197. /** @hidden */
  46198. 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;
  46199. /** @hidden */
  46200. 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;
  46201. /** @hidden */
  46202. 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;
  46203. }
  46204. }
  46205. declare module BABYLON {
  46206. /**
  46207. * Implementation of the TGA Texture Loader.
  46208. * @hidden
  46209. */
  46210. export class _TGATextureLoader implements IInternalTextureLoader {
  46211. /**
  46212. * Defines wether the loader supports cascade loading the different faces.
  46213. */
  46214. readonly supportCascades: boolean;
  46215. /**
  46216. * This returns if the loader support the current file information.
  46217. * @param extension defines the file extension of the file being loaded
  46218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46219. * @param fallback defines the fallback internal texture if any
  46220. * @param isBase64 defines whether the texture is encoded as a base64
  46221. * @param isBuffer defines whether the texture data are stored as a buffer
  46222. * @returns true if the loader can load the specified file
  46223. */
  46224. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46225. /**
  46226. * Transform the url before loading if required.
  46227. * @param rootUrl the url of the texture
  46228. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46229. * @returns the transformed texture
  46230. */
  46231. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46232. /**
  46233. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46234. * @param rootUrl the url of the texture
  46235. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46236. * @returns the fallback texture
  46237. */
  46238. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46239. /**
  46240. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46241. * @param data contains the texture data
  46242. * @param texture defines the BabylonJS internal texture
  46243. * @param createPolynomials will be true if polynomials have been requested
  46244. * @param onLoad defines the callback to trigger once the texture is ready
  46245. * @param onError defines the callback to trigger in case of error
  46246. */
  46247. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46248. /**
  46249. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46250. * @param data contains the texture data
  46251. * @param texture defines the BabylonJS internal texture
  46252. * @param callback defines the method to call once ready to upload
  46253. */
  46254. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46255. }
  46256. }
  46257. declare module BABYLON {
  46258. /**
  46259. * 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.
  46260. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  46261. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  46262. */
  46263. export class CustomProceduralTexture extends ProceduralTexture {
  46264. private _animate;
  46265. private _time;
  46266. private _config;
  46267. private _texturePath;
  46268. /**
  46269. * Instantiates a new Custom Procedural Texture.
  46270. * 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.
  46271. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  46272. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  46273. * @param name Define the name of the texture
  46274. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  46275. * @param size Define the size of the texture to create
  46276. * @param scene Define the scene the texture belongs to
  46277. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  46278. * @param generateMipMaps Define if the texture should creates mip maps or not
  46279. */
  46280. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  46281. private _loadJson;
  46282. /**
  46283. * Is the texture ready to be used ? (rendered at least once)
  46284. * @returns true if ready, otherwise, false.
  46285. */
  46286. isReady(): boolean;
  46287. /**
  46288. * Render the texture to its associated render target.
  46289. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  46290. */
  46291. render(useCameraPostProcess?: boolean): void;
  46292. /**
  46293. * Update the list of dependant textures samplers in the shader.
  46294. */
  46295. updateTextures(): void;
  46296. /**
  46297. * Update the uniform values of the procedural texture in the shader.
  46298. */
  46299. updateShaderUniforms(): void;
  46300. /**
  46301. * Define if the texture animates or not.
  46302. */
  46303. animate: boolean;
  46304. }
  46305. }
  46306. declare module BABYLON {
  46307. /** @hidden */
  46308. export var noisePixelShader: {
  46309. name: string;
  46310. shader: string;
  46311. };
  46312. }
  46313. declare module BABYLON {
  46314. /**
  46315. * Class used to generate noise procedural textures
  46316. */
  46317. export class NoiseProceduralTexture extends ProceduralTexture {
  46318. private _time;
  46319. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  46320. brightness: number;
  46321. /** Defines the number of octaves to process */
  46322. octaves: number;
  46323. /** Defines the level of persistence (0.8 by default) */
  46324. persistence: number;
  46325. /** Gets or sets animation speed factor (default is 1) */
  46326. animationSpeedFactor: number;
  46327. /**
  46328. * Creates a new NoiseProceduralTexture
  46329. * @param name defines the name fo the texture
  46330. * @param size defines the size of the texture (default is 256)
  46331. * @param scene defines the hosting scene
  46332. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  46333. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  46334. */
  46335. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  46336. private _updateShaderUniforms;
  46337. protected _getDefines(): string;
  46338. /** Generate the current state of the procedural texture */
  46339. render(useCameraPostProcess?: boolean): void;
  46340. /**
  46341. * Serializes this noise procedural texture
  46342. * @returns a serialized noise procedural texture object
  46343. */
  46344. serialize(): any;
  46345. /**
  46346. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  46347. * @param parsedTexture defines parsed texture data
  46348. * @param scene defines the current scene
  46349. * @param rootUrl defines the root URL containing noise procedural texture information
  46350. * @returns a parsed NoiseProceduralTexture
  46351. */
  46352. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  46353. }
  46354. }
  46355. declare module BABYLON {
  46356. /**
  46357. * Raw cube texture where the raw buffers are passed in
  46358. */
  46359. export class RawCubeTexture extends CubeTexture {
  46360. /**
  46361. * Creates a cube texture where the raw buffers are passed in.
  46362. * @param scene defines the scene the texture is attached to
  46363. * @param data defines the array of data to use to create each face
  46364. * @param size defines the size of the textures
  46365. * @param format defines the format of the data
  46366. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  46367. * @param generateMipMaps defines if the engine should generate the mip levels
  46368. * @param invertY defines if data must be stored with Y axis inverted
  46369. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46370. * @param compression defines the compression used (null by default)
  46371. */
  46372. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  46373. /**
  46374. * Updates the raw cube texture.
  46375. * @param data defines the data to store
  46376. * @param format defines the data format
  46377. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46378. * @param invertY defines if data must be stored with Y axis inverted
  46379. * @param compression defines the compression used (null by default)
  46380. * @param level defines which level of the texture to update
  46381. */
  46382. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  46383. /**
  46384. * Updates a raw cube texture with RGBD encoded data.
  46385. * @param data defines the array of data [mipmap][face] to use to create each face
  46386. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  46387. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46388. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46389. * @returns a promsie that resolves when the operation is complete
  46390. */
  46391. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  46392. /**
  46393. * Clones the raw cube texture.
  46394. * @return a new cube texture
  46395. */
  46396. clone(): CubeTexture;
  46397. /** @hidden */
  46398. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46399. }
  46400. }
  46401. declare module BABYLON {
  46402. /**
  46403. * Class used to store 3D textures containing user data
  46404. */
  46405. export class RawTexture3D extends Texture {
  46406. /** Gets or sets the texture format to use */
  46407. format: number;
  46408. private _engine;
  46409. /**
  46410. * Create a new RawTexture3D
  46411. * @param data defines the data of the texture
  46412. * @param width defines the width of the texture
  46413. * @param height defines the height of the texture
  46414. * @param depth defines the depth of the texture
  46415. * @param format defines the texture format to use
  46416. * @param scene defines the hosting scene
  46417. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  46418. * @param invertY defines if texture must be stored with Y axis inverted
  46419. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  46420. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46421. */
  46422. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  46423. /** Gets or sets the texture format to use */
  46424. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  46425. /**
  46426. * Update the texture with new data
  46427. * @param data defines the data to store in the texture
  46428. */
  46429. update(data: ArrayBufferView): void;
  46430. }
  46431. }
  46432. declare module BABYLON {
  46433. /**
  46434. * Creates a refraction texture used by refraction channel of the standard material.
  46435. * It is like a mirror but to see through a material.
  46436. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46437. */
  46438. export class RefractionTexture extends RenderTargetTexture {
  46439. /**
  46440. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  46441. * 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.
  46442. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46443. */
  46444. refractionPlane: Plane;
  46445. /**
  46446. * Define how deep under the surface we should see.
  46447. */
  46448. depth: number;
  46449. /**
  46450. * Creates a refraction texture used by refraction channel of the standard material.
  46451. * It is like a mirror but to see through a material.
  46452. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46453. * @param name Define the texture name
  46454. * @param size Define the size of the underlying texture
  46455. * @param scene Define the scene the refraction belongs to
  46456. * @param generateMipMaps Define if we need to generate mips level for the refraction
  46457. */
  46458. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  46459. /**
  46460. * Clone the refraction texture.
  46461. * @returns the cloned texture
  46462. */
  46463. clone(): RefractionTexture;
  46464. /**
  46465. * Serialize the texture to a JSON representation you could use in Parse later on
  46466. * @returns the serialized JSON representation
  46467. */
  46468. serialize(): any;
  46469. }
  46470. }
  46471. declare module BABYLON {
  46472. /**
  46473. * Configuration for Draco compression
  46474. */
  46475. export interface IDracoCompressionConfiguration {
  46476. /**
  46477. * Configuration for the decoder.
  46478. */
  46479. decoder?: {
  46480. /**
  46481. * The url to the WebAssembly module.
  46482. */
  46483. wasmUrl?: string;
  46484. /**
  46485. * The url to the WebAssembly binary.
  46486. */
  46487. wasmBinaryUrl?: string;
  46488. /**
  46489. * The url to the fallback JavaScript module.
  46490. */
  46491. fallbackUrl?: string;
  46492. };
  46493. }
  46494. /**
  46495. * Draco compression (https://google.github.io/draco/)
  46496. *
  46497. * This class wraps the Draco module.
  46498. *
  46499. * **Encoder**
  46500. *
  46501. * The encoder is not currently implemented.
  46502. *
  46503. * **Decoder**
  46504. *
  46505. * 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.
  46506. *
  46507. * To update the configuration, use the following code:
  46508. * ```javascript
  46509. * DracoCompression.Configuration = {
  46510. * decoder: {
  46511. * wasmUrl: "<url to the WebAssembly library>",
  46512. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  46513. * fallbackUrl: "<url to the fallback JavaScript library>",
  46514. * }
  46515. * };
  46516. * ```
  46517. *
  46518. * 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.
  46519. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  46520. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  46521. *
  46522. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  46523. * ```javascript
  46524. * var dracoCompression = new DracoCompression();
  46525. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  46526. * [VertexBuffer.PositionKind]: 0
  46527. * });
  46528. * ```
  46529. *
  46530. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  46531. */
  46532. export class DracoCompression implements IDisposable {
  46533. private static _DecoderModulePromise;
  46534. /**
  46535. * The configuration. Defaults to the following urls:
  46536. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  46537. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  46538. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  46539. */
  46540. static Configuration: IDracoCompressionConfiguration;
  46541. /**
  46542. * Returns true if the decoder is available.
  46543. */
  46544. static readonly DecoderAvailable: boolean;
  46545. /**
  46546. * Constructor
  46547. */
  46548. constructor();
  46549. /**
  46550. * Stop all async operations and release resources.
  46551. */
  46552. dispose(): void;
  46553. /**
  46554. * Decode Draco compressed mesh data to vertex data.
  46555. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  46556. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  46557. * @returns A promise that resolves with the decoded vertex data
  46558. */
  46559. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  46560. [kind: string]: number;
  46561. }): Promise<VertexData>;
  46562. private static _GetDecoderModule;
  46563. private static _LoadScriptAsync;
  46564. private static _LoadFileAsync;
  46565. }
  46566. }
  46567. declare module BABYLON {
  46568. /**
  46569. * Class for building Constructive Solid Geometry
  46570. */
  46571. export class CSG {
  46572. private polygons;
  46573. /**
  46574. * The world matrix
  46575. */
  46576. matrix: Matrix;
  46577. /**
  46578. * Stores the position
  46579. */
  46580. position: Vector3;
  46581. /**
  46582. * Stores the rotation
  46583. */
  46584. rotation: Vector3;
  46585. /**
  46586. * Stores the rotation quaternion
  46587. */
  46588. rotationQuaternion: Nullable<Quaternion>;
  46589. /**
  46590. * Stores the scaling vector
  46591. */
  46592. scaling: Vector3;
  46593. /**
  46594. * Convert the Mesh to CSG
  46595. * @param mesh The Mesh to convert to CSG
  46596. * @returns A new CSG from the Mesh
  46597. */
  46598. static FromMesh(mesh: Mesh): CSG;
  46599. /**
  46600. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  46601. * @param polygons Polygons used to construct a CSG solid
  46602. */
  46603. private static FromPolygons;
  46604. /**
  46605. * Clones, or makes a deep copy, of the CSG
  46606. * @returns A new CSG
  46607. */
  46608. clone(): CSG;
  46609. /**
  46610. * Unions this CSG with another CSG
  46611. * @param csg The CSG to union against this CSG
  46612. * @returns The unioned CSG
  46613. */
  46614. union(csg: CSG): CSG;
  46615. /**
  46616. * Unions this CSG with another CSG in place
  46617. * @param csg The CSG to union against this CSG
  46618. */
  46619. unionInPlace(csg: CSG): void;
  46620. /**
  46621. * Subtracts this CSG with another CSG
  46622. * @param csg The CSG to subtract against this CSG
  46623. * @returns A new CSG
  46624. */
  46625. subtract(csg: CSG): CSG;
  46626. /**
  46627. * Subtracts this CSG with another CSG in place
  46628. * @param csg The CSG to subtact against this CSG
  46629. */
  46630. subtractInPlace(csg: CSG): void;
  46631. /**
  46632. * Intersect this CSG with another CSG
  46633. * @param csg The CSG to intersect against this CSG
  46634. * @returns A new CSG
  46635. */
  46636. intersect(csg: CSG): CSG;
  46637. /**
  46638. * Intersects this CSG with another CSG in place
  46639. * @param csg The CSG to intersect against this CSG
  46640. */
  46641. intersectInPlace(csg: CSG): void;
  46642. /**
  46643. * Return a new CSG solid with solid and empty space switched. This solid is
  46644. * not modified.
  46645. * @returns A new CSG solid with solid and empty space switched
  46646. */
  46647. inverse(): CSG;
  46648. /**
  46649. * Inverses the CSG in place
  46650. */
  46651. inverseInPlace(): void;
  46652. /**
  46653. * This is used to keep meshes transformations so they can be restored
  46654. * when we build back a Babylon Mesh
  46655. * NB : All CSG operations are performed in world coordinates
  46656. * @param csg The CSG to copy the transform attributes from
  46657. * @returns This CSG
  46658. */
  46659. copyTransformAttributes(csg: CSG): CSG;
  46660. /**
  46661. * Build Raw mesh from CSG
  46662. * Coordinates here are in world space
  46663. * @param name The name of the mesh geometry
  46664. * @param scene The Scene
  46665. * @param keepSubMeshes Specifies if the submeshes should be kept
  46666. * @returns A new Mesh
  46667. */
  46668. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  46669. /**
  46670. * Build Mesh from CSG taking material and transforms into account
  46671. * @param name The name of the Mesh
  46672. * @param material The material of the Mesh
  46673. * @param scene The Scene
  46674. * @param keepSubMeshes Specifies if submeshes should be kept
  46675. * @returns The new Mesh
  46676. */
  46677. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  46678. }
  46679. }
  46680. declare module BABYLON {
  46681. /**
  46682. * Class containing static functions to help procedurally build meshes
  46683. */
  46684. export class RibbonBuilder {
  46685. /**
  46686. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  46687. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  46688. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  46689. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  46690. * * 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
  46691. * * 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
  46692. * * 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
  46693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46694. * * 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
  46695. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46696. * * 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
  46697. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  46698. * * 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
  46699. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  46700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46701. * @param name defines the name of the mesh
  46702. * @param options defines the options used to create the mesh
  46703. * @param scene defines the hosting scene
  46704. * @returns the ribbon mesh
  46705. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  46706. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46707. */
  46708. static CreateRibbon(name: string, options: {
  46709. pathArray: Vector3[][];
  46710. closeArray?: boolean;
  46711. closePath?: boolean;
  46712. offset?: number;
  46713. updatable?: boolean;
  46714. sideOrientation?: number;
  46715. frontUVs?: Vector4;
  46716. backUVs?: Vector4;
  46717. instance?: Mesh;
  46718. invertUV?: boolean;
  46719. uvs?: Vector2[];
  46720. colors?: Color4[];
  46721. }, scene?: Nullable<Scene>): Mesh;
  46722. }
  46723. }
  46724. declare module BABYLON {
  46725. /**
  46726. * Class containing static functions to help procedurally build meshes
  46727. */
  46728. export class TorusKnotBuilder {
  46729. /**
  46730. * Creates a torus knot mesh
  46731. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  46732. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  46733. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  46734. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  46735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46736. * * 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
  46737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46738. * @param name defines the name of the mesh
  46739. * @param options defines the options used to create the mesh
  46740. * @param scene defines the hosting scene
  46741. * @returns the torus knot mesh
  46742. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  46743. */
  46744. static CreateTorusKnot(name: string, options: {
  46745. radius?: number;
  46746. tube?: number;
  46747. radialSegments?: number;
  46748. tubularSegments?: number;
  46749. p?: number;
  46750. q?: number;
  46751. updatable?: boolean;
  46752. sideOrientation?: number;
  46753. frontUVs?: Vector4;
  46754. backUVs?: Vector4;
  46755. }, scene: any): Mesh;
  46756. }
  46757. }
  46758. declare module BABYLON {
  46759. /**
  46760. * Polygon
  46761. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  46762. */
  46763. export class Polygon {
  46764. /**
  46765. * Creates a rectangle
  46766. * @param xmin bottom X coord
  46767. * @param ymin bottom Y coord
  46768. * @param xmax top X coord
  46769. * @param ymax top Y coord
  46770. * @returns points that make the resulting rectation
  46771. */
  46772. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  46773. /**
  46774. * Creates a circle
  46775. * @param radius radius of circle
  46776. * @param cx scale in x
  46777. * @param cy scale in y
  46778. * @param numberOfSides number of sides that make up the circle
  46779. * @returns points that make the resulting circle
  46780. */
  46781. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  46782. /**
  46783. * Creates a polygon from input string
  46784. * @param input Input polygon data
  46785. * @returns the parsed points
  46786. */
  46787. static Parse(input: string): Vector2[];
  46788. /**
  46789. * Starts building a polygon from x and y coordinates
  46790. * @param x x coordinate
  46791. * @param y y coordinate
  46792. * @returns the started path2
  46793. */
  46794. static StartingAt(x: number, y: number): Path2;
  46795. }
  46796. /**
  46797. * Builds a polygon
  46798. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  46799. */
  46800. export class PolygonMeshBuilder {
  46801. private _points;
  46802. private _outlinepoints;
  46803. private _holes;
  46804. private _name;
  46805. private _scene;
  46806. private _epoints;
  46807. private _eholes;
  46808. private _addToepoint;
  46809. /**
  46810. * Babylon reference to the earcut plugin.
  46811. */
  46812. bjsEarcut: any;
  46813. /**
  46814. * Creates a PolygonMeshBuilder
  46815. * @param name name of the builder
  46816. * @param contours Path of the polygon
  46817. * @param scene scene to add to
  46818. * @param earcutInjection can be used to inject your own earcut reference
  46819. */
  46820. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  46821. /**
  46822. * Adds a whole within the polygon
  46823. * @param hole Array of points defining the hole
  46824. * @returns this
  46825. */
  46826. addHole(hole: Vector2[]): PolygonMeshBuilder;
  46827. /**
  46828. * Creates the polygon
  46829. * @param updatable If the mesh should be updatable
  46830. * @param depth The depth of the mesh created
  46831. * @returns the created mesh
  46832. */
  46833. build(updatable?: boolean, depth?: number): Mesh;
  46834. /**
  46835. * Adds a side to the polygon
  46836. * @param positions points that make the polygon
  46837. * @param normals normals of the polygon
  46838. * @param uvs uvs of the polygon
  46839. * @param indices indices of the polygon
  46840. * @param bounds bounds of the polygon
  46841. * @param points points of the polygon
  46842. * @param depth depth of the polygon
  46843. * @param flip flip of the polygon
  46844. */
  46845. private addSide;
  46846. }
  46847. }
  46848. declare module BABYLON {
  46849. /**
  46850. * Class containing static functions to help procedurally build meshes
  46851. */
  46852. export class PolygonBuilder {
  46853. /**
  46854. * Creates a polygon mesh
  46855. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  46856. * * 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
  46857. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  46858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46859. * * 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)
  46860. * * Remember you can only change the shape positions, not their number when updating a polygon
  46861. * @param name defines the name of the mesh
  46862. * @param options defines the options used to create the mesh
  46863. * @param scene defines the hosting scene
  46864. * @param earcutInjection can be used to inject your own earcut reference
  46865. * @returns the polygon mesh
  46866. */
  46867. static CreatePolygon(name: string, options: {
  46868. shape: Vector3[];
  46869. holes?: Vector3[][];
  46870. depth?: number;
  46871. faceUV?: Vector4[];
  46872. faceColors?: Color4[];
  46873. updatable?: boolean;
  46874. sideOrientation?: number;
  46875. frontUVs?: Vector4;
  46876. backUVs?: Vector4;
  46877. }, scene: Scene, earcutInjection?: any): Mesh;
  46878. /**
  46879. * Creates an extruded polygon mesh, with depth in the Y direction.
  46880. * * 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)
  46881. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46882. * @param name defines the name of the mesh
  46883. * @param options defines the options used to create the mesh
  46884. * @param scene defines the hosting scene
  46885. * @param earcutInjection can be used to inject your own earcut reference
  46886. * @returns the polygon mesh
  46887. */
  46888. static ExtrudePolygon(name: string, options: {
  46889. shape: Vector3[];
  46890. holes?: Vector3[][];
  46891. depth?: number;
  46892. faceUV?: Vector4[];
  46893. faceColors?: Color4[];
  46894. updatable?: boolean;
  46895. sideOrientation?: number;
  46896. frontUVs?: Vector4;
  46897. backUVs?: Vector4;
  46898. }, scene: Scene, earcutInjection?: any): Mesh;
  46899. }
  46900. }
  46901. declare module BABYLON {
  46902. /**
  46903. * Class containing static functions to help procedurally build meshes
  46904. */
  46905. export class ShapeBuilder {
  46906. /**
  46907. * 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.
  46908. * * 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.
  46909. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46910. * * 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.
  46911. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  46912. * * 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
  46913. * * 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
  46914. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  46915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46916. * * 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
  46917. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  46918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46919. * @param name defines the name of the mesh
  46920. * @param options defines the options used to create the mesh
  46921. * @param scene defines the hosting scene
  46922. * @returns the extruded shape mesh
  46923. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46924. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  46925. */
  46926. static ExtrudeShape(name: string, options: {
  46927. shape: Vector3[];
  46928. path: Vector3[];
  46929. scale?: number;
  46930. rotation?: number;
  46931. cap?: number;
  46932. updatable?: boolean;
  46933. sideOrientation?: number;
  46934. frontUVs?: Vector4;
  46935. backUVs?: Vector4;
  46936. instance?: Mesh;
  46937. invertUV?: boolean;
  46938. }, scene?: Nullable<Scene>): Mesh;
  46939. /**
  46940. * Creates an custom extruded shape mesh.
  46941. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  46942. * * 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.
  46943. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46944. * * 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
  46945. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  46946. * * 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
  46947. * * It must returns a float value that will be the scale value applied to the shape on each path point
  46948. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  46949. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  46950. * * 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
  46951. * * 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
  46952. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  46953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46954. * * 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
  46955. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46957. * @param name defines the name of the mesh
  46958. * @param options defines the options used to create the mesh
  46959. * @param scene defines the hosting scene
  46960. * @returns the custom extruded shape mesh
  46961. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  46962. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46963. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  46964. */
  46965. static ExtrudeShapeCustom(name: string, options: {
  46966. shape: Vector3[];
  46967. path: Vector3[];
  46968. scaleFunction?: any;
  46969. rotationFunction?: any;
  46970. ribbonCloseArray?: boolean;
  46971. ribbonClosePath?: boolean;
  46972. cap?: number;
  46973. updatable?: boolean;
  46974. sideOrientation?: number;
  46975. frontUVs?: Vector4;
  46976. backUVs?: Vector4;
  46977. instance?: Mesh;
  46978. invertUV?: boolean;
  46979. }, scene: Scene): Mesh;
  46980. private static _ExtrudeShapeGeneric;
  46981. }
  46982. }
  46983. declare module BABYLON {
  46984. /**
  46985. * Class containing static functions to help procedurally build meshes
  46986. */
  46987. export class LatheBuilder {
  46988. /**
  46989. * Creates lathe mesh.
  46990. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  46991. * * 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
  46992. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  46993. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  46994. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  46995. * * 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
  46996. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  46997. * * 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
  46998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46999. * * 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
  47000. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47002. * @param name defines the name of the mesh
  47003. * @param options defines the options used to create the mesh
  47004. * @param scene defines the hosting scene
  47005. * @returns the lathe mesh
  47006. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  47007. */
  47008. static CreateLathe(name: string, options: {
  47009. shape: Vector3[];
  47010. radius?: number;
  47011. tessellation?: number;
  47012. clip?: number;
  47013. arc?: number;
  47014. closed?: boolean;
  47015. updatable?: boolean;
  47016. sideOrientation?: number;
  47017. frontUVs?: Vector4;
  47018. backUVs?: Vector4;
  47019. cap?: number;
  47020. invertUV?: boolean;
  47021. }, scene: Scene): Mesh;
  47022. }
  47023. }
  47024. declare module BABYLON {
  47025. /**
  47026. * Class containing static functions to help procedurally build meshes
  47027. */
  47028. export class TubeBuilder {
  47029. /**
  47030. * Creates a tube mesh.
  47031. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47032. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  47033. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  47034. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  47035. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  47036. * * 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)
  47037. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  47038. * * 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
  47039. * * 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
  47040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47041. * * 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
  47042. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47044. * @param name defines the name of the mesh
  47045. * @param options defines the options used to create the mesh
  47046. * @param scene defines the hosting scene
  47047. * @returns the tube mesh
  47048. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47049. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  47050. */
  47051. static CreateTube(name: string, options: {
  47052. path: Vector3[];
  47053. radius?: number;
  47054. tessellation?: number;
  47055. radiusFunction?: {
  47056. (i: number, distance: number): number;
  47057. };
  47058. cap?: number;
  47059. arc?: number;
  47060. updatable?: boolean;
  47061. sideOrientation?: number;
  47062. frontUVs?: Vector4;
  47063. backUVs?: Vector4;
  47064. instance?: Mesh;
  47065. invertUV?: boolean;
  47066. }, scene: Scene): Mesh;
  47067. }
  47068. }
  47069. declare module BABYLON {
  47070. /**
  47071. * Class containing static functions to help procedurally build meshes
  47072. */
  47073. export class IcoSphereBuilder {
  47074. /**
  47075. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  47076. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  47077. * * 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`)
  47078. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  47079. * * 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
  47080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47081. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47083. * @param name defines the name of the mesh
  47084. * @param options defines the options used to create the mesh
  47085. * @param scene defines the hosting scene
  47086. * @returns the icosahedron mesh
  47087. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  47088. */
  47089. static CreateIcoSphere(name: string, options: {
  47090. radius?: number;
  47091. radiusX?: number;
  47092. radiusY?: number;
  47093. radiusZ?: number;
  47094. flat?: boolean;
  47095. subdivisions?: number;
  47096. sideOrientation?: number;
  47097. frontUVs?: Vector4;
  47098. backUVs?: Vector4;
  47099. updatable?: boolean;
  47100. }, scene: Scene): Mesh;
  47101. }
  47102. }
  47103. declare module BABYLON {
  47104. /**
  47105. * Class containing static functions to help procedurally build meshes
  47106. */
  47107. export class DecalBuilder {
  47108. /**
  47109. * Creates a decal mesh.
  47110. * 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
  47111. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  47112. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  47113. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  47114. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  47115. * @param name defines the name of the mesh
  47116. * @param sourceMesh defines the mesh where the decal must be applied
  47117. * @param options defines the options used to create the mesh
  47118. * @param scene defines the hosting scene
  47119. * @returns the decal mesh
  47120. * @see https://doc.babylonjs.com/how_to/decals
  47121. */
  47122. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  47123. position?: Vector3;
  47124. normal?: Vector3;
  47125. size?: Vector3;
  47126. angle?: number;
  47127. }): Mesh;
  47128. }
  47129. }
  47130. declare module BABYLON {
  47131. /**
  47132. * Class containing static functions to help procedurally build meshes
  47133. */
  47134. export class MeshBuilder {
  47135. /**
  47136. * Creates a box mesh
  47137. * * The parameter `size` sets the size (float) of each box side (default 1)
  47138. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47139. * * 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)
  47140. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47142. * * 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
  47143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47144. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47145. * @param name defines the name of the mesh
  47146. * @param options defines the options used to create the mesh
  47147. * @param scene defines the hosting scene
  47148. * @returns the box mesh
  47149. */
  47150. static CreateBox(name: string, options: {
  47151. size?: number;
  47152. width?: number;
  47153. height?: number;
  47154. depth?: number;
  47155. faceUV?: Vector4[];
  47156. faceColors?: Color4[];
  47157. sideOrientation?: number;
  47158. frontUVs?: Vector4;
  47159. backUVs?: Vector4;
  47160. updatable?: boolean;
  47161. }, scene?: Nullable<Scene>): Mesh;
  47162. /**
  47163. * Creates a sphere mesh
  47164. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47165. * * 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`)
  47166. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47167. * * 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
  47168. * * 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)
  47169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47170. * * 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
  47171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47172. * @param name defines the name of the mesh
  47173. * @param options defines the options used to create the mesh
  47174. * @param scene defines the hosting scene
  47175. * @returns the sphere mesh
  47176. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47177. */
  47178. static CreateSphere(name: string, options: {
  47179. segments?: number;
  47180. diameter?: number;
  47181. diameterX?: number;
  47182. diameterY?: number;
  47183. diameterZ?: number;
  47184. arc?: number;
  47185. slice?: number;
  47186. sideOrientation?: number;
  47187. frontUVs?: Vector4;
  47188. backUVs?: Vector4;
  47189. updatable?: boolean;
  47190. }, scene: any): Mesh;
  47191. /**
  47192. * Creates a plane polygonal mesh. By default, this is a disc
  47193. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  47194. * * 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
  47195. * * 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
  47196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47197. * * 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
  47198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47199. * @param name defines the name of the mesh
  47200. * @param options defines the options used to create the mesh
  47201. * @param scene defines the hosting scene
  47202. * @returns the plane polygonal mesh
  47203. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  47204. */
  47205. static CreateDisc(name: string, options: {
  47206. radius?: number;
  47207. tessellation?: number;
  47208. arc?: number;
  47209. updatable?: boolean;
  47210. sideOrientation?: number;
  47211. frontUVs?: Vector4;
  47212. backUVs?: Vector4;
  47213. }, scene?: Nullable<Scene>): Mesh;
  47214. /**
  47215. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  47216. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  47217. * * 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`)
  47218. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  47219. * * 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
  47220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47221. * * 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
  47222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47223. * @param name defines the name of the mesh
  47224. * @param options defines the options used to create the mesh
  47225. * @param scene defines the hosting scene
  47226. * @returns the icosahedron mesh
  47227. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  47228. */
  47229. static CreateIcoSphere(name: string, options: {
  47230. radius?: number;
  47231. radiusX?: number;
  47232. radiusY?: number;
  47233. radiusZ?: number;
  47234. flat?: boolean;
  47235. subdivisions?: number;
  47236. sideOrientation?: number;
  47237. frontUVs?: Vector4;
  47238. backUVs?: Vector4;
  47239. updatable?: boolean;
  47240. }, scene: Scene): Mesh;
  47241. /**
  47242. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47243. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47244. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47245. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47246. * * 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
  47247. * * 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
  47248. * * 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
  47249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47250. * * 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
  47251. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47252. * * 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
  47253. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47254. * * 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
  47255. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47257. * @param name defines the name of the mesh
  47258. * @param options defines the options used to create the mesh
  47259. * @param scene defines the hosting scene
  47260. * @returns the ribbon mesh
  47261. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47262. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47263. */
  47264. static CreateRibbon(name: string, options: {
  47265. pathArray: Vector3[][];
  47266. closeArray?: boolean;
  47267. closePath?: boolean;
  47268. offset?: number;
  47269. updatable?: boolean;
  47270. sideOrientation?: number;
  47271. frontUVs?: Vector4;
  47272. backUVs?: Vector4;
  47273. instance?: Mesh;
  47274. invertUV?: boolean;
  47275. uvs?: Vector2[];
  47276. colors?: Color4[];
  47277. }, scene?: Nullable<Scene>): Mesh;
  47278. /**
  47279. * Creates a cylinder or a cone mesh
  47280. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47281. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47282. * * 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.
  47283. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47284. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47285. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47286. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47287. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47288. * * 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).
  47289. * * 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
  47290. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47291. * * 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
  47292. * * 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.
  47293. * * If `enclose` is false, a ring surface is one element.
  47294. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47295. * * 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
  47296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47297. * * 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
  47298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47299. * @param name defines the name of the mesh
  47300. * @param options defines the options used to create the mesh
  47301. * @param scene defines the hosting scene
  47302. * @returns the cylinder mesh
  47303. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47304. */
  47305. static CreateCylinder(name: string, options: {
  47306. height?: number;
  47307. diameterTop?: number;
  47308. diameterBottom?: number;
  47309. diameter?: number;
  47310. tessellation?: number;
  47311. subdivisions?: number;
  47312. arc?: number;
  47313. faceColors?: Color4[];
  47314. faceUV?: Vector4[];
  47315. updatable?: boolean;
  47316. hasRings?: boolean;
  47317. enclose?: boolean;
  47318. sideOrientation?: number;
  47319. frontUVs?: Vector4;
  47320. backUVs?: Vector4;
  47321. }, scene: any): Mesh;
  47322. /**
  47323. * Creates a torus mesh
  47324. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47325. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47326. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47328. * * 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
  47329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47330. * @param name defines the name of the mesh
  47331. * @param options defines the options used to create the mesh
  47332. * @param scene defines the hosting scene
  47333. * @returns the torus mesh
  47334. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47335. */
  47336. static CreateTorus(name: string, options: {
  47337. diameter?: number;
  47338. thickness?: number;
  47339. tessellation?: number;
  47340. updatable?: boolean;
  47341. sideOrientation?: number;
  47342. frontUVs?: Vector4;
  47343. backUVs?: Vector4;
  47344. }, scene: any): Mesh;
  47345. /**
  47346. * Creates a torus knot mesh
  47347. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  47348. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  47349. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  47350. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  47351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47352. * * 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
  47353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47354. * @param name defines the name of the mesh
  47355. * @param options defines the options used to create the mesh
  47356. * @param scene defines the hosting scene
  47357. * @returns the torus knot mesh
  47358. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  47359. */
  47360. static CreateTorusKnot(name: string, options: {
  47361. radius?: number;
  47362. tube?: number;
  47363. radialSegments?: number;
  47364. tubularSegments?: number;
  47365. p?: number;
  47366. q?: number;
  47367. updatable?: boolean;
  47368. sideOrientation?: number;
  47369. frontUVs?: Vector4;
  47370. backUVs?: Vector4;
  47371. }, scene: any): Mesh;
  47372. /**
  47373. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47374. * * 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
  47375. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47376. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47377. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47378. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47379. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47380. * * 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
  47381. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47383. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47384. * @param name defines the name of the new line system
  47385. * @param options defines the options used to create the line system
  47386. * @param scene defines the hosting scene
  47387. * @returns a new line system mesh
  47388. */
  47389. static CreateLineSystem(name: string, options: {
  47390. lines: Vector3[][];
  47391. updatable?: boolean;
  47392. instance?: Nullable<LinesMesh>;
  47393. colors?: Nullable<Color4[][]>;
  47394. useVertexAlpha?: boolean;
  47395. }, scene: Nullable<Scene>): LinesMesh;
  47396. /**
  47397. * Creates a line mesh
  47398. * 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
  47399. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47400. * * The parameter `points` is an array successive Vector3
  47401. * * 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
  47402. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47403. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47404. * * When updating an instance, remember that only point positions can change, not the number of points
  47405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47406. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47407. * @param name defines the name of the new line system
  47408. * @param options defines the options used to create the line system
  47409. * @param scene defines the hosting scene
  47410. * @returns a new line mesh
  47411. */
  47412. static CreateLines(name: string, options: {
  47413. points: Vector3[];
  47414. updatable?: boolean;
  47415. instance?: Nullable<LinesMesh>;
  47416. colors?: Color4[];
  47417. useVertexAlpha?: boolean;
  47418. }, scene?: Nullable<Scene>): LinesMesh;
  47419. /**
  47420. * Creates a dashed line mesh
  47421. * * 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
  47422. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47423. * * The parameter `points` is an array successive Vector3
  47424. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47425. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47426. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47427. * * 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
  47428. * * When updating an instance, remember that only point positions can change, not the number of points
  47429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47430. * @param name defines the name of the mesh
  47431. * @param options defines the options used to create the mesh
  47432. * @param scene defines the hosting scene
  47433. * @returns the dashed line mesh
  47434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47435. */
  47436. static CreateDashedLines(name: string, options: {
  47437. points: Vector3[];
  47438. dashSize?: number;
  47439. gapSize?: number;
  47440. dashNb?: number;
  47441. updatable?: boolean;
  47442. instance?: LinesMesh;
  47443. }, scene?: Nullable<Scene>): LinesMesh;
  47444. /**
  47445. * 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.
  47446. * * 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.
  47447. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47448. * * 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.
  47449. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47450. * * 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
  47451. * * 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
  47452. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47454. * * 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
  47455. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47457. * @param name defines the name of the mesh
  47458. * @param options defines the options used to create the mesh
  47459. * @param scene defines the hosting scene
  47460. * @returns the extruded shape mesh
  47461. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47462. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47463. */
  47464. static ExtrudeShape(name: string, options: {
  47465. shape: Vector3[];
  47466. path: Vector3[];
  47467. scale?: number;
  47468. rotation?: number;
  47469. cap?: number;
  47470. updatable?: boolean;
  47471. sideOrientation?: number;
  47472. frontUVs?: Vector4;
  47473. backUVs?: Vector4;
  47474. instance?: Mesh;
  47475. invertUV?: boolean;
  47476. }, scene?: Nullable<Scene>): Mesh;
  47477. /**
  47478. * Creates an custom extruded shape mesh.
  47479. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47480. * * 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.
  47481. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47482. * * 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
  47483. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47484. * * 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
  47485. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47486. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47487. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47488. * * 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
  47489. * * 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
  47490. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47492. * * 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
  47493. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47495. * @param name defines the name of the mesh
  47496. * @param options defines the options used to create the mesh
  47497. * @param scene defines the hosting scene
  47498. * @returns the custom extruded shape mesh
  47499. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47500. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47501. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47502. */
  47503. static ExtrudeShapeCustom(name: string, options: {
  47504. shape: Vector3[];
  47505. path: Vector3[];
  47506. scaleFunction?: any;
  47507. rotationFunction?: any;
  47508. ribbonCloseArray?: boolean;
  47509. ribbonClosePath?: boolean;
  47510. cap?: number;
  47511. updatable?: boolean;
  47512. sideOrientation?: number;
  47513. frontUVs?: Vector4;
  47514. backUVs?: Vector4;
  47515. instance?: Mesh;
  47516. invertUV?: boolean;
  47517. }, scene: Scene): Mesh;
  47518. /**
  47519. * Creates lathe mesh.
  47520. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  47521. * * 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
  47522. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  47523. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  47524. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  47525. * * 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
  47526. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  47527. * * 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
  47528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47529. * * 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
  47530. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47532. * @param name defines the name of the mesh
  47533. * @param options defines the options used to create the mesh
  47534. * @param scene defines the hosting scene
  47535. * @returns the lathe mesh
  47536. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  47537. */
  47538. static CreateLathe(name: string, options: {
  47539. shape: Vector3[];
  47540. radius?: number;
  47541. tessellation?: number;
  47542. clip?: number;
  47543. arc?: number;
  47544. closed?: boolean;
  47545. updatable?: boolean;
  47546. sideOrientation?: number;
  47547. frontUVs?: Vector4;
  47548. backUVs?: Vector4;
  47549. cap?: number;
  47550. invertUV?: boolean;
  47551. }, scene: Scene): Mesh;
  47552. /**
  47553. * Creates a plane mesh
  47554. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  47555. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  47556. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  47557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47558. * * 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
  47559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47560. * @param name defines the name of the mesh
  47561. * @param options defines the options used to create the mesh
  47562. * @param scene defines the hosting scene
  47563. * @returns the plane mesh
  47564. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  47565. */
  47566. static CreatePlane(name: string, options: {
  47567. size?: number;
  47568. width?: number;
  47569. height?: number;
  47570. sideOrientation?: number;
  47571. frontUVs?: Vector4;
  47572. backUVs?: Vector4;
  47573. updatable?: boolean;
  47574. sourcePlane?: Plane;
  47575. }, scene: Scene): Mesh;
  47576. /**
  47577. * Creates a ground mesh
  47578. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47579. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47581. * @param name defines the name of the mesh
  47582. * @param options defines the options used to create the mesh
  47583. * @param scene defines the hosting scene
  47584. * @returns the ground mesh
  47585. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47586. */
  47587. static CreateGround(name: string, options: {
  47588. width?: number;
  47589. height?: number;
  47590. subdivisions?: number;
  47591. subdivisionsX?: number;
  47592. subdivisionsY?: number;
  47593. updatable?: boolean;
  47594. }, scene: any): Mesh;
  47595. /**
  47596. * Creates a tiled ground mesh
  47597. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47598. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47599. * * 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
  47600. * * 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
  47601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47602. * @param name defines the name of the mesh
  47603. * @param options defines the options used to create the mesh
  47604. * @param scene defines the hosting scene
  47605. * @returns the tiled ground mesh
  47606. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47607. */
  47608. static CreateTiledGround(name: string, options: {
  47609. xmin: number;
  47610. zmin: number;
  47611. xmax: number;
  47612. zmax: number;
  47613. subdivisions?: {
  47614. w: number;
  47615. h: number;
  47616. };
  47617. precision?: {
  47618. w: number;
  47619. h: number;
  47620. };
  47621. updatable?: boolean;
  47622. }, scene: Scene): Mesh;
  47623. /**
  47624. * Creates a ground mesh from a height map
  47625. * * The parameter `url` sets the URL of the height map image resource.
  47626. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47627. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47628. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47629. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47630. * * 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.
  47631. * * 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).
  47632. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47634. * @param name defines the name of the mesh
  47635. * @param url defines the url to the height map
  47636. * @param options defines the options used to create the mesh
  47637. * @param scene defines the hosting scene
  47638. * @returns the ground mesh
  47639. * @see https://doc.babylonjs.com/babylon101/height_map
  47640. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47641. */
  47642. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47643. width?: number;
  47644. height?: number;
  47645. subdivisions?: number;
  47646. minHeight?: number;
  47647. maxHeight?: number;
  47648. colorFilter?: Color3;
  47649. alphaFilter?: number;
  47650. updatable?: boolean;
  47651. onReady?: (mesh: GroundMesh) => void;
  47652. }, scene: Scene): GroundMesh;
  47653. /**
  47654. * Creates a polygon mesh
  47655. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  47656. * * 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
  47657. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  47658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47659. * * 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)
  47660. * * Remember you can only change the shape positions, not their number when updating a polygon
  47661. * @param name defines the name of the mesh
  47662. * @param options defines the options used to create the mesh
  47663. * @param scene defines the hosting scene
  47664. * @param earcutInjection can be used to inject your own earcut reference
  47665. * @returns the polygon mesh
  47666. */
  47667. static CreatePolygon(name: string, options: {
  47668. shape: Vector3[];
  47669. holes?: Vector3[][];
  47670. depth?: number;
  47671. faceUV?: Vector4[];
  47672. faceColors?: Color4[];
  47673. updatable?: boolean;
  47674. sideOrientation?: number;
  47675. frontUVs?: Vector4;
  47676. backUVs?: Vector4;
  47677. }, scene: Scene, earcutInjection?: any): Mesh;
  47678. /**
  47679. * Creates an extruded polygon mesh, with depth in the Y direction.
  47680. * * 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)
  47681. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47682. * @param name defines the name of the mesh
  47683. * @param options defines the options used to create the mesh
  47684. * @param scene defines the hosting scene
  47685. * @param earcutInjection can be used to inject your own earcut reference
  47686. * @returns the polygon mesh
  47687. */
  47688. static ExtrudePolygon(name: string, options: {
  47689. shape: Vector3[];
  47690. holes?: Vector3[][];
  47691. depth?: number;
  47692. faceUV?: Vector4[];
  47693. faceColors?: Color4[];
  47694. updatable?: boolean;
  47695. sideOrientation?: number;
  47696. frontUVs?: Vector4;
  47697. backUVs?: Vector4;
  47698. }, scene: Scene, earcutInjection?: any): Mesh;
  47699. /**
  47700. * Creates a tube mesh.
  47701. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47702. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  47703. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  47704. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  47705. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  47706. * * 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)
  47707. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  47708. * * 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
  47709. * * 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
  47710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47711. * * 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
  47712. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47714. * @param name defines the name of the mesh
  47715. * @param options defines the options used to create the mesh
  47716. * @param scene defines the hosting scene
  47717. * @returns the tube mesh
  47718. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47719. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  47720. */
  47721. static CreateTube(name: string, options: {
  47722. path: Vector3[];
  47723. radius?: number;
  47724. tessellation?: number;
  47725. radiusFunction?: {
  47726. (i: number, distance: number): number;
  47727. };
  47728. cap?: number;
  47729. arc?: number;
  47730. updatable?: boolean;
  47731. sideOrientation?: number;
  47732. frontUVs?: Vector4;
  47733. backUVs?: Vector4;
  47734. instance?: Mesh;
  47735. invertUV?: boolean;
  47736. }, scene: Scene): Mesh;
  47737. /**
  47738. * Creates a polyhedron mesh
  47739. * * 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
  47740. * * The parameter `size` (positive float, default 1) sets the polygon size
  47741. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47742. * * 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`
  47743. * * 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
  47744. * * 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)`)
  47745. * * 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
  47746. * * 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
  47747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47748. * * 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
  47749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47750. * @param name defines the name of the mesh
  47751. * @param options defines the options used to create the mesh
  47752. * @param scene defines the hosting scene
  47753. * @returns the polyhedron mesh
  47754. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47755. */
  47756. static CreatePolyhedron(name: string, options: {
  47757. type?: number;
  47758. size?: number;
  47759. sizeX?: number;
  47760. sizeY?: number;
  47761. sizeZ?: number;
  47762. custom?: any;
  47763. faceUV?: Vector4[];
  47764. faceColors?: Color4[];
  47765. flat?: boolean;
  47766. updatable?: boolean;
  47767. sideOrientation?: number;
  47768. frontUVs?: Vector4;
  47769. backUVs?: Vector4;
  47770. }, scene: Scene): Mesh;
  47771. /**
  47772. * Creates a decal mesh.
  47773. * 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
  47774. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  47775. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  47776. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  47777. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  47778. * @param name defines the name of the mesh
  47779. * @param sourceMesh defines the mesh where the decal must be applied
  47780. * @param options defines the options used to create the mesh
  47781. * @param scene defines the hosting scene
  47782. * @returns the decal mesh
  47783. * @see https://doc.babylonjs.com/how_to/decals
  47784. */
  47785. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  47786. position?: Vector3;
  47787. normal?: Vector3;
  47788. size?: Vector3;
  47789. angle?: number;
  47790. }): Mesh;
  47791. }
  47792. }
  47793. declare module BABYLON {
  47794. /**
  47795. * A simplifier interface for future simplification implementations
  47796. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47797. */
  47798. export interface ISimplifier {
  47799. /**
  47800. * Simplification of a given mesh according to the given settings.
  47801. * Since this requires computation, it is assumed that the function runs async.
  47802. * @param settings The settings of the simplification, including quality and distance
  47803. * @param successCallback A callback that will be called after the mesh was simplified.
  47804. * @param errorCallback in case of an error, this callback will be called. optional.
  47805. */
  47806. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  47807. }
  47808. /**
  47809. * Expected simplification settings.
  47810. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  47811. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47812. */
  47813. export interface ISimplificationSettings {
  47814. /**
  47815. * Gets or sets the expected quality
  47816. */
  47817. quality: number;
  47818. /**
  47819. * Gets or sets the distance when this optimized version should be used
  47820. */
  47821. distance: number;
  47822. /**
  47823. * Gets an already optimized mesh
  47824. */
  47825. optimizeMesh?: boolean;
  47826. }
  47827. /**
  47828. * Class used to specify simplification options
  47829. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47830. */
  47831. export class SimplificationSettings implements ISimplificationSettings {
  47832. /** expected quality */
  47833. quality: number;
  47834. /** distance when this optimized version should be used */
  47835. distance: number;
  47836. /** already optimized mesh */
  47837. optimizeMesh?: boolean | undefined;
  47838. /**
  47839. * Creates a SimplificationSettings
  47840. * @param quality expected quality
  47841. * @param distance distance when this optimized version should be used
  47842. * @param optimizeMesh already optimized mesh
  47843. */
  47844. constructor(
  47845. /** expected quality */
  47846. quality: number,
  47847. /** distance when this optimized version should be used */
  47848. distance: number,
  47849. /** already optimized mesh */
  47850. optimizeMesh?: boolean | undefined);
  47851. }
  47852. /**
  47853. * Interface used to define a simplification task
  47854. */
  47855. export interface ISimplificationTask {
  47856. /**
  47857. * Array of settings
  47858. */
  47859. settings: Array<ISimplificationSettings>;
  47860. /**
  47861. * Simplification type
  47862. */
  47863. simplificationType: SimplificationType;
  47864. /**
  47865. * Mesh to simplify
  47866. */
  47867. mesh: Mesh;
  47868. /**
  47869. * Callback called on success
  47870. */
  47871. successCallback?: () => void;
  47872. /**
  47873. * Defines if parallel processing can be used
  47874. */
  47875. parallelProcessing: boolean;
  47876. }
  47877. /**
  47878. * Queue used to order the simplification tasks
  47879. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47880. */
  47881. export class SimplificationQueue {
  47882. private _simplificationArray;
  47883. /**
  47884. * Gets a boolean indicating that the process is still running
  47885. */
  47886. running: boolean;
  47887. /**
  47888. * Creates a new queue
  47889. */
  47890. constructor();
  47891. /**
  47892. * Adds a new simplification task
  47893. * @param task defines a task to add
  47894. */
  47895. addTask(task: ISimplificationTask): void;
  47896. /**
  47897. * Execute next task
  47898. */
  47899. executeNext(): void;
  47900. /**
  47901. * Execute a simplification task
  47902. * @param task defines the task to run
  47903. */
  47904. runSimplification(task: ISimplificationTask): void;
  47905. private getSimplifier;
  47906. }
  47907. /**
  47908. * The implemented types of simplification
  47909. * At the moment only Quadratic Error Decimation is implemented
  47910. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47911. */
  47912. export enum SimplificationType {
  47913. /** Quadratic error decimation */
  47914. QUADRATIC = 0
  47915. }
  47916. }
  47917. declare module BABYLON {
  47918. interface Scene {
  47919. /** @hidden (Backing field) */
  47920. _simplificationQueue: SimplificationQueue;
  47921. /**
  47922. * Gets or sets the simplification queue attached to the scene
  47923. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47924. */
  47925. simplificationQueue: SimplificationQueue;
  47926. }
  47927. interface Mesh {
  47928. /**
  47929. * Simplify the mesh according to the given array of settings.
  47930. * Function will return immediately and will simplify async
  47931. * @param settings a collection of simplification settings
  47932. * @param parallelProcessing should all levels calculate parallel or one after the other
  47933. * @param simplificationType the type of simplification to run
  47934. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  47935. * @returns the current mesh
  47936. */
  47937. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  47938. }
  47939. /**
  47940. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  47941. * created in a scene
  47942. */
  47943. export class SimplicationQueueSceneComponent implements ISceneComponent {
  47944. /**
  47945. * The component name helpfull to identify the component in the list of scene components.
  47946. */
  47947. readonly name: string;
  47948. /**
  47949. * The scene the component belongs to.
  47950. */
  47951. scene: Scene;
  47952. /**
  47953. * Creates a new instance of the component for the given scene
  47954. * @param scene Defines the scene to register the component in
  47955. */
  47956. constructor(scene: Scene);
  47957. /**
  47958. * Registers the component in a given scene
  47959. */
  47960. register(): void;
  47961. /**
  47962. * Rebuilds the elements related to this component in case of
  47963. * context lost for instance.
  47964. */
  47965. rebuild(): void;
  47966. /**
  47967. * Disposes the component and the associated ressources
  47968. */
  47969. dispose(): void;
  47970. private _beforeCameraUpdate;
  47971. }
  47972. }
  47973. declare module BABYLON {
  47974. /**
  47975. * Class used to enable access to IndexedDB
  47976. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  47977. */
  47978. export class Database implements IOfflineProvider {
  47979. private _callbackManifestChecked;
  47980. private _currentSceneUrl;
  47981. private _db;
  47982. private _enableSceneOffline;
  47983. private _enableTexturesOffline;
  47984. private _manifestVersionFound;
  47985. private _mustUpdateRessources;
  47986. private _hasReachedQuota;
  47987. private _isSupported;
  47988. private _idbFactory;
  47989. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  47990. private static IsUASupportingBlobStorage;
  47991. /**
  47992. * Gets a boolean indicating if Database storate is enabled (off by default)
  47993. */
  47994. static IDBStorageEnabled: boolean;
  47995. /**
  47996. * Gets a boolean indicating if scene must be saved in the database
  47997. */
  47998. readonly enableSceneOffline: boolean;
  47999. /**
  48000. * Gets a boolean indicating if textures must be saved in the database
  48001. */
  48002. readonly enableTexturesOffline: boolean;
  48003. /**
  48004. * Creates a new Database
  48005. * @param urlToScene defines the url to load the scene
  48006. * @param callbackManifestChecked defines the callback to use when manifest is checked
  48007. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  48008. */
  48009. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  48010. private static _ParseURL;
  48011. private static _ReturnFullUrlLocation;
  48012. private _checkManifestFile;
  48013. /**
  48014. * Open the database and make it available
  48015. * @param successCallback defines the callback to call on success
  48016. * @param errorCallback defines the callback to call on error
  48017. */
  48018. open(successCallback: () => void, errorCallback: () => void): void;
  48019. /**
  48020. * Loads an image from the database
  48021. * @param url defines the url to load from
  48022. * @param image defines the target DOM image
  48023. */
  48024. loadImage(url: string, image: HTMLImageElement): void;
  48025. private _loadImageFromDBAsync;
  48026. private _saveImageIntoDBAsync;
  48027. private _checkVersionFromDB;
  48028. private _loadVersionFromDBAsync;
  48029. private _saveVersionIntoDBAsync;
  48030. /**
  48031. * Loads a file from database
  48032. * @param url defines the URL to load from
  48033. * @param sceneLoaded defines a callback to call on success
  48034. * @param progressCallBack defines a callback to call when progress changed
  48035. * @param errorCallback defines a callback to call on error
  48036. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  48037. */
  48038. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  48039. private _loadFileAsync;
  48040. private _saveFileAsync;
  48041. /**
  48042. * Validates if xhr data is correct
  48043. * @param xhr defines the request to validate
  48044. * @param dataType defines the expected data type
  48045. * @returns true if data is correct
  48046. */
  48047. private static _ValidateXHRData;
  48048. }
  48049. }
  48050. declare module BABYLON {
  48051. /** @hidden */
  48052. export var gpuUpdateParticlesPixelShader: {
  48053. name: string;
  48054. shader: string;
  48055. };
  48056. }
  48057. declare module BABYLON {
  48058. /** @hidden */
  48059. export var gpuUpdateParticlesVertexShader: {
  48060. name: string;
  48061. shader: string;
  48062. };
  48063. }
  48064. declare module BABYLON {
  48065. /** @hidden */
  48066. export var clipPlaneFragmentDeclaration2: {
  48067. name: string;
  48068. shader: string;
  48069. };
  48070. }
  48071. declare module BABYLON {
  48072. /** @hidden */
  48073. export var gpuRenderParticlesPixelShader: {
  48074. name: string;
  48075. shader: string;
  48076. };
  48077. }
  48078. declare module BABYLON {
  48079. /** @hidden */
  48080. export var clipPlaneVertexDeclaration2: {
  48081. name: string;
  48082. shader: string;
  48083. };
  48084. }
  48085. declare module BABYLON {
  48086. /** @hidden */
  48087. export var gpuRenderParticlesVertexShader: {
  48088. name: string;
  48089. shader: string;
  48090. };
  48091. }
  48092. declare module BABYLON {
  48093. /**
  48094. * This represents a GPU particle system in Babylon
  48095. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  48096. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  48097. */
  48098. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  48099. /**
  48100. * The layer mask we are rendering the particles through.
  48101. */
  48102. layerMask: number;
  48103. private _capacity;
  48104. private _activeCount;
  48105. private _currentActiveCount;
  48106. private _accumulatedCount;
  48107. private _renderEffect;
  48108. private _updateEffect;
  48109. private _buffer0;
  48110. private _buffer1;
  48111. private _spriteBuffer;
  48112. private _updateVAO;
  48113. private _renderVAO;
  48114. private _targetIndex;
  48115. private _sourceBuffer;
  48116. private _targetBuffer;
  48117. private _engine;
  48118. private _currentRenderId;
  48119. private _started;
  48120. private _stopped;
  48121. private _timeDelta;
  48122. private _randomTexture;
  48123. private _randomTexture2;
  48124. private _attributesStrideSize;
  48125. private _updateEffectOptions;
  48126. private _randomTextureSize;
  48127. private _actualFrame;
  48128. private readonly _rawTextureWidth;
  48129. /**
  48130. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  48131. */
  48132. static readonly IsSupported: boolean;
  48133. /**
  48134. * An event triggered when the system is disposed.
  48135. */
  48136. onDisposeObservable: Observable<GPUParticleSystem>;
  48137. /**
  48138. * Gets the maximum number of particles active at the same time.
  48139. * @returns The max number of active particles.
  48140. */
  48141. getCapacity(): number;
  48142. /**
  48143. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  48144. * to override the particles.
  48145. */
  48146. forceDepthWrite: boolean;
  48147. /**
  48148. * Gets or set the number of active particles
  48149. */
  48150. activeParticleCount: number;
  48151. private _preWarmDone;
  48152. /**
  48153. * Is this system ready to be used/rendered
  48154. * @return true if the system is ready
  48155. */
  48156. isReady(): boolean;
  48157. /**
  48158. * Gets if the system has been started. (Note: this will still be true after stop is called)
  48159. * @returns True if it has been started, otherwise false.
  48160. */
  48161. isStarted(): boolean;
  48162. /**
  48163. * Starts the particle system and begins to emit
  48164. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  48165. */
  48166. start(delay?: number): void;
  48167. /**
  48168. * Stops the particle system.
  48169. */
  48170. stop(): void;
  48171. /**
  48172. * Remove all active particles
  48173. */
  48174. reset(): void;
  48175. /**
  48176. * Returns the string "GPUParticleSystem"
  48177. * @returns a string containing the class name
  48178. */
  48179. getClassName(): string;
  48180. private _colorGradientsTexture;
  48181. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  48182. /**
  48183. * Adds a new color gradient
  48184. * @param gradient defines the gradient to use (between 0 and 1)
  48185. * @param color1 defines the color to affect to the specified gradient
  48186. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  48187. * @returns the current particle system
  48188. */
  48189. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  48190. /**
  48191. * Remove a specific color gradient
  48192. * @param gradient defines the gradient to remove
  48193. * @returns the current particle system
  48194. */
  48195. removeColorGradient(gradient: number): GPUParticleSystem;
  48196. private _angularSpeedGradientsTexture;
  48197. private _sizeGradientsTexture;
  48198. private _velocityGradientsTexture;
  48199. private _limitVelocityGradientsTexture;
  48200. private _dragGradientsTexture;
  48201. private _addFactorGradient;
  48202. /**
  48203. * Adds a new size gradient
  48204. * @param gradient defines the gradient to use (between 0 and 1)
  48205. * @param factor defines the size factor to affect to the specified gradient
  48206. * @returns the current particle system
  48207. */
  48208. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  48209. /**
  48210. * Remove a specific size gradient
  48211. * @param gradient defines the gradient to remove
  48212. * @returns the current particle system
  48213. */
  48214. removeSizeGradient(gradient: number): GPUParticleSystem;
  48215. /**
  48216. * Adds a new angular speed gradient
  48217. * @param gradient defines the gradient to use (between 0 and 1)
  48218. * @param factor defines the angular speed to affect to the specified gradient
  48219. * @returns the current particle system
  48220. */
  48221. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  48222. /**
  48223. * Remove a specific angular speed gradient
  48224. * @param gradient defines the gradient to remove
  48225. * @returns the current particle system
  48226. */
  48227. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  48228. /**
  48229. * Adds a new velocity gradient
  48230. * @param gradient defines the gradient to use (between 0 and 1)
  48231. * @param factor defines the velocity to affect to the specified gradient
  48232. * @returns the current particle system
  48233. */
  48234. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  48235. /**
  48236. * Remove a specific velocity gradient
  48237. * @param gradient defines the gradient to remove
  48238. * @returns the current particle system
  48239. */
  48240. removeVelocityGradient(gradient: number): GPUParticleSystem;
  48241. /**
  48242. * Adds a new limit velocity gradient
  48243. * @param gradient defines the gradient to use (between 0 and 1)
  48244. * @param factor defines the limit velocity value to affect to the specified gradient
  48245. * @returns the current particle system
  48246. */
  48247. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  48248. /**
  48249. * Remove a specific limit velocity gradient
  48250. * @param gradient defines the gradient to remove
  48251. * @returns the current particle system
  48252. */
  48253. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  48254. /**
  48255. * Adds a new drag gradient
  48256. * @param gradient defines the gradient to use (between 0 and 1)
  48257. * @param factor defines the drag value to affect to the specified gradient
  48258. * @returns the current particle system
  48259. */
  48260. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  48261. /**
  48262. * Remove a specific drag gradient
  48263. * @param gradient defines the gradient to remove
  48264. * @returns the current particle system
  48265. */
  48266. removeDragGradient(gradient: number): GPUParticleSystem;
  48267. /**
  48268. * Not supported by GPUParticleSystem
  48269. * @param gradient defines the gradient to use (between 0 and 1)
  48270. * @param factor defines the emit rate value to affect to the specified gradient
  48271. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  48272. * @returns the current particle system
  48273. */
  48274. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  48275. /**
  48276. * Not supported by GPUParticleSystem
  48277. * @param gradient defines the gradient to remove
  48278. * @returns the current particle system
  48279. */
  48280. removeEmitRateGradient(gradient: number): IParticleSystem;
  48281. /**
  48282. * Not supported by GPUParticleSystem
  48283. * @param gradient defines the gradient to use (between 0 and 1)
  48284. * @param factor defines the start size value to affect to the specified gradient
  48285. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  48286. * @returns the current particle system
  48287. */
  48288. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  48289. /**
  48290. * Not supported by GPUParticleSystem
  48291. * @param gradient defines the gradient to remove
  48292. * @returns the current particle system
  48293. */
  48294. removeStartSizeGradient(gradient: number): IParticleSystem;
  48295. /**
  48296. * Not supported by GPUParticleSystem
  48297. * @param gradient defines the gradient to use (between 0 and 1)
  48298. * @param min defines the color remap minimal range
  48299. * @param max defines the color remap maximal range
  48300. * @returns the current particle system
  48301. */
  48302. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  48303. /**
  48304. * Not supported by GPUParticleSystem
  48305. * @param gradient defines the gradient to remove
  48306. * @returns the current particle system
  48307. */
  48308. removeColorRemapGradient(): IParticleSystem;
  48309. /**
  48310. * Not supported by GPUParticleSystem
  48311. * @param gradient defines the gradient to use (between 0 and 1)
  48312. * @param min defines the alpha remap minimal range
  48313. * @param max defines the alpha remap maximal range
  48314. * @returns the current particle system
  48315. */
  48316. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  48317. /**
  48318. * Not supported by GPUParticleSystem
  48319. * @param gradient defines the gradient to remove
  48320. * @returns the current particle system
  48321. */
  48322. removeAlphaRemapGradient(): IParticleSystem;
  48323. /**
  48324. * Not supported by GPUParticleSystem
  48325. * @param gradient defines the gradient to use (between 0 and 1)
  48326. * @param color defines the color to affect to the specified gradient
  48327. * @returns the current particle system
  48328. */
  48329. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  48330. /**
  48331. * Not supported by GPUParticleSystem
  48332. * @param gradient defines the gradient to remove
  48333. * @returns the current particle system
  48334. */
  48335. removeRampGradient(): IParticleSystem;
  48336. /**
  48337. * Not supported by GPUParticleSystem
  48338. * @returns the list of ramp gradients
  48339. */
  48340. getRampGradients(): Nullable<Array<Color3Gradient>>;
  48341. /**
  48342. * Not supported by GPUParticleSystem
  48343. * Gets or sets a boolean indicating that ramp gradients must be used
  48344. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  48345. */
  48346. useRampGradients: boolean;
  48347. /**
  48348. * Not supported by GPUParticleSystem
  48349. * @param gradient defines the gradient to use (between 0 and 1)
  48350. * @param factor defines the life time factor to affect to the specified gradient
  48351. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  48352. * @returns the current particle system
  48353. */
  48354. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  48355. /**
  48356. * Not supported by GPUParticleSystem
  48357. * @param gradient defines the gradient to remove
  48358. * @returns the current particle system
  48359. */
  48360. removeLifeTimeGradient(gradient: number): IParticleSystem;
  48361. /**
  48362. * Instantiates a GPU particle system.
  48363. * 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.
  48364. * @param name The name of the particle system
  48365. * @param options The options used to create the system
  48366. * @param scene The scene the particle system belongs to
  48367. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  48368. */
  48369. constructor(name: string, options: Partial<{
  48370. capacity: number;
  48371. randomTextureSize: number;
  48372. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  48373. protected _reset(): void;
  48374. private _createUpdateVAO;
  48375. private _createRenderVAO;
  48376. private _initialize;
  48377. /** @hidden */
  48378. _recreateUpdateEffect(): void;
  48379. /** @hidden */
  48380. _recreateRenderEffect(): void;
  48381. /**
  48382. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  48383. * @param preWarm defines if we are in the pre-warmimg phase
  48384. */
  48385. animate(preWarm?: boolean): void;
  48386. private _createFactorGradientTexture;
  48387. private _createSizeGradientTexture;
  48388. private _createAngularSpeedGradientTexture;
  48389. private _createVelocityGradientTexture;
  48390. private _createLimitVelocityGradientTexture;
  48391. private _createDragGradientTexture;
  48392. private _createColorGradientTexture;
  48393. /**
  48394. * Renders the particle system in its current state
  48395. * @param preWarm defines if the system should only update the particles but not render them
  48396. * @returns the current number of particles
  48397. */
  48398. render(preWarm?: boolean): number;
  48399. /**
  48400. * Rebuilds the particle system
  48401. */
  48402. rebuild(): void;
  48403. private _releaseBuffers;
  48404. private _releaseVAOs;
  48405. /**
  48406. * Disposes the particle system and free the associated resources
  48407. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  48408. */
  48409. dispose(disposeTexture?: boolean): void;
  48410. /**
  48411. * Clones the particle system.
  48412. * @param name The name of the cloned object
  48413. * @param newEmitter The new emitter to use
  48414. * @returns the cloned particle system
  48415. */
  48416. clone(name: string, newEmitter: any): GPUParticleSystem;
  48417. /**
  48418. * Serializes the particle system to a JSON object.
  48419. * @returns the JSON object
  48420. */
  48421. serialize(): any;
  48422. /**
  48423. * Parses a JSON object to create a GPU particle system.
  48424. * @param parsedParticleSystem The JSON object to parse
  48425. * @param scene The scene to create the particle system in
  48426. * @param rootUrl The root url to use to load external dependencies like texture
  48427. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  48428. * @returns the parsed GPU particle system
  48429. */
  48430. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  48431. }
  48432. }
  48433. declare module BABYLON {
  48434. /**
  48435. * Represents a set of particle systems working together to create a specific effect
  48436. */
  48437. export class ParticleSystemSet implements IDisposable {
  48438. private _emitterCreationOptions;
  48439. private _emitterNode;
  48440. /**
  48441. * Gets the particle system list
  48442. */
  48443. systems: IParticleSystem[];
  48444. /**
  48445. * Gets the emitter node used with this set
  48446. */
  48447. readonly emitterNode: Nullable<TransformNode>;
  48448. /**
  48449. * Creates a new emitter mesh as a sphere
  48450. * @param options defines the options used to create the sphere
  48451. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  48452. * @param scene defines the hosting scene
  48453. */
  48454. setEmitterAsSphere(options: {
  48455. diameter: number;
  48456. segments: number;
  48457. color: Color3;
  48458. }, renderingGroupId: number, scene: Scene): void;
  48459. /**
  48460. * Starts all particle systems of the set
  48461. * @param emitter defines an optional mesh to use as emitter for the particle systems
  48462. */
  48463. start(emitter?: AbstractMesh): void;
  48464. /**
  48465. * Release all associated resources
  48466. */
  48467. dispose(): void;
  48468. /**
  48469. * Serialize the set into a JSON compatible object
  48470. * @returns a JSON compatible representation of the set
  48471. */
  48472. serialize(): any;
  48473. /**
  48474. * Parse a new ParticleSystemSet from a serialized source
  48475. * @param data defines a JSON compatible representation of the set
  48476. * @param scene defines the hosting scene
  48477. * @param gpu defines if we want GPU particles or CPU particles
  48478. * @returns a new ParticleSystemSet
  48479. */
  48480. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  48481. }
  48482. }
  48483. declare module BABYLON {
  48484. /**
  48485. * This class is made for on one-liner static method to help creating particle system set.
  48486. */
  48487. export class ParticleHelper {
  48488. /**
  48489. * Gets or sets base Assets URL
  48490. */
  48491. static BaseAssetsUrl: string;
  48492. /**
  48493. * Create a default particle system that you can tweak
  48494. * @param emitter defines the emitter to use
  48495. * @param capacity defines the system capacity (default is 500 particles)
  48496. * @param scene defines the hosting scene
  48497. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  48498. * @returns the new Particle system
  48499. */
  48500. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  48501. /**
  48502. * This is the main static method (one-liner) of this helper to create different particle systems
  48503. * @param type This string represents the type to the particle system to create
  48504. * @param scene The scene where the particle system should live
  48505. * @param gpu If the system will use gpu
  48506. * @returns the ParticleSystemSet created
  48507. */
  48508. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  48509. /**
  48510. * Static function used to export a particle system to a ParticleSystemSet variable.
  48511. * Please note that the emitter shape is not exported
  48512. * @param systems defines the particle systems to export
  48513. * @returns the created particle system set
  48514. */
  48515. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  48516. }
  48517. }
  48518. declare module BABYLON {
  48519. interface Engine {
  48520. /**
  48521. * Create an effect to use with particle systems.
  48522. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  48523. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  48524. * @param uniformsNames defines a list of attribute names
  48525. * @param samplers defines an array of string used to represent textures
  48526. * @param defines defines the string containing the defines to use to compile the shaders
  48527. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  48528. * @param onCompiled defines a function to call when the effect creation is successful
  48529. * @param onError defines a function to call when the effect creation has failed
  48530. * @returns the new Effect
  48531. */
  48532. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  48533. }
  48534. interface Mesh {
  48535. /**
  48536. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  48537. * @returns an array of IParticleSystem
  48538. */
  48539. getEmittedParticleSystems(): IParticleSystem[];
  48540. /**
  48541. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  48542. * @returns an array of IParticleSystem
  48543. */
  48544. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  48545. }
  48546. /**
  48547. * @hidden
  48548. */
  48549. export var _IDoNeedToBeInTheBuild: number;
  48550. }
  48551. declare module BABYLON {
  48552. interface Scene {
  48553. /** @hidden (Backing field) */
  48554. _physicsEngine: Nullable<IPhysicsEngine>;
  48555. /**
  48556. * Gets the current physics engine
  48557. * @returns a IPhysicsEngine or null if none attached
  48558. */
  48559. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  48560. /**
  48561. * Enables physics to the current scene
  48562. * @param gravity defines the scene's gravity for the physics engine
  48563. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  48564. * @return a boolean indicating if the physics engine was initialized
  48565. */
  48566. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  48567. /**
  48568. * Disables and disposes the physics engine associated with the scene
  48569. */
  48570. disablePhysicsEngine(): void;
  48571. /**
  48572. * Gets a boolean indicating if there is an active physics engine
  48573. * @returns a boolean indicating if there is an active physics engine
  48574. */
  48575. isPhysicsEnabled(): boolean;
  48576. /**
  48577. * Deletes a physics compound impostor
  48578. * @param compound defines the compound to delete
  48579. */
  48580. deleteCompoundImpostor(compound: any): void;
  48581. /**
  48582. * An event triggered when physic simulation is about to be run
  48583. */
  48584. onBeforePhysicsObservable: Observable<Scene>;
  48585. /**
  48586. * An event triggered when physic simulation has been done
  48587. */
  48588. onAfterPhysicsObservable: Observable<Scene>;
  48589. }
  48590. interface AbstractMesh {
  48591. /** @hidden */
  48592. _physicsImpostor: Nullable<PhysicsImpostor>;
  48593. /**
  48594. * Gets or sets impostor used for physic simulation
  48595. * @see http://doc.babylonjs.com/features/physics_engine
  48596. */
  48597. physicsImpostor: Nullable<PhysicsImpostor>;
  48598. /**
  48599. * Gets the current physics impostor
  48600. * @see http://doc.babylonjs.com/features/physics_engine
  48601. * @returns a physics impostor or null
  48602. */
  48603. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  48604. /** Apply a physic impulse to the mesh
  48605. * @param force defines the force to apply
  48606. * @param contactPoint defines where to apply the force
  48607. * @returns the current mesh
  48608. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48609. */
  48610. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  48611. /**
  48612. * Creates a physic joint between two meshes
  48613. * @param otherMesh defines the other mesh to use
  48614. * @param pivot1 defines the pivot to use on this mesh
  48615. * @param pivot2 defines the pivot to use on the other mesh
  48616. * @param options defines additional options (can be plugin dependent)
  48617. * @returns the current mesh
  48618. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  48619. */
  48620. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  48621. /** @hidden */
  48622. _disposePhysicsObserver: Nullable<Observer<Node>>;
  48623. }
  48624. /**
  48625. * Defines the physics engine scene component responsible to manage a physics engine
  48626. */
  48627. export class PhysicsEngineSceneComponent implements ISceneComponent {
  48628. /**
  48629. * The component name helpful to identify the component in the list of scene components.
  48630. */
  48631. readonly name: string;
  48632. /**
  48633. * The scene the component belongs to.
  48634. */
  48635. scene: Scene;
  48636. /**
  48637. * Creates a new instance of the component for the given scene
  48638. * @param scene Defines the scene to register the component in
  48639. */
  48640. constructor(scene: Scene);
  48641. /**
  48642. * Registers the component in a given scene
  48643. */
  48644. register(): void;
  48645. /**
  48646. * Rebuilds the elements related to this component in case of
  48647. * context lost for instance.
  48648. */
  48649. rebuild(): void;
  48650. /**
  48651. * Disposes the component and the associated ressources
  48652. */
  48653. dispose(): void;
  48654. }
  48655. }
  48656. declare module BABYLON {
  48657. /**
  48658. * A helper for physics simulations
  48659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48660. */
  48661. export class PhysicsHelper {
  48662. private _scene;
  48663. private _physicsEngine;
  48664. /**
  48665. * Initializes the Physics helper
  48666. * @param scene Babylon.js scene
  48667. */
  48668. constructor(scene: Scene);
  48669. /**
  48670. * Applies a radial explosion impulse
  48671. * @param origin the origin of the explosion
  48672. * @param radius the explosion radius
  48673. * @param strength the explosion strength
  48674. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48675. * @returns A physics radial explosion event, or null
  48676. */
  48677. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  48678. /**
  48679. * Applies a radial explosion force
  48680. * @param origin the origin of the explosion
  48681. * @param radius the explosion radius
  48682. * @param strength the explosion strength
  48683. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48684. * @returns A physics radial explosion event, or null
  48685. */
  48686. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  48687. /**
  48688. * Creates a gravitational field
  48689. * @param origin the origin of the explosion
  48690. * @param radius the explosion radius
  48691. * @param strength the explosion strength
  48692. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48693. * @returns A physics gravitational field event, or null
  48694. */
  48695. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  48696. /**
  48697. * Creates a physics updraft event
  48698. * @param origin the origin of the updraft
  48699. * @param radius the radius of the updraft
  48700. * @param strength the strength of the updraft
  48701. * @param height the height of the updraft
  48702. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  48703. * @returns A physics updraft event, or null
  48704. */
  48705. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  48706. /**
  48707. * Creates a physics vortex event
  48708. * @param origin the of the vortex
  48709. * @param radius the radius of the vortex
  48710. * @param strength the strength of the vortex
  48711. * @param height the height of the vortex
  48712. * @returns a Physics vortex event, or null
  48713. * A physics vortex event or null
  48714. */
  48715. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  48716. }
  48717. /**
  48718. * Represents a physics radial explosion event
  48719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48720. */
  48721. export class PhysicsRadialExplosionEvent {
  48722. private _scene;
  48723. private _sphere;
  48724. private _sphereOptions;
  48725. private _rays;
  48726. private _dataFetched;
  48727. /**
  48728. * Initializes a radial explosioin event
  48729. * @param scene BabylonJS scene
  48730. */
  48731. constructor(scene: Scene);
  48732. /**
  48733. * Returns the data related to the radial explosion event (sphere & rays).
  48734. * @returns The radial explosion event data
  48735. */
  48736. getData(): PhysicsRadialExplosionEventData;
  48737. /**
  48738. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  48739. * @param impostor A physics imposter
  48740. * @param origin the origin of the explosion
  48741. * @param radius the explosion radius
  48742. * @param strength the explosion strength
  48743. * @param falloff possible options: Constant & Linear
  48744. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  48745. */
  48746. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  48747. /**
  48748. * Disposes the sphere.
  48749. * @param force Specifies if the sphere should be disposed by force
  48750. */
  48751. dispose(force?: boolean): void;
  48752. /*** Helpers ***/
  48753. private _prepareSphere;
  48754. private _intersectsWithSphere;
  48755. }
  48756. /**
  48757. * Represents a gravitational field event
  48758. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48759. */
  48760. export class PhysicsGravitationalFieldEvent {
  48761. private _physicsHelper;
  48762. private _scene;
  48763. private _origin;
  48764. private _radius;
  48765. private _strength;
  48766. private _falloff;
  48767. private _tickCallback;
  48768. private _sphere;
  48769. private _dataFetched;
  48770. /**
  48771. * Initializes the physics gravitational field event
  48772. * @param physicsHelper A physics helper
  48773. * @param scene BabylonJS scene
  48774. * @param origin The origin position of the gravitational field event
  48775. * @param radius The radius of the gravitational field event
  48776. * @param strength The strength of the gravitational field event
  48777. * @param falloff The falloff for the gravitational field event
  48778. */
  48779. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  48780. /**
  48781. * Returns the data related to the gravitational field event (sphere).
  48782. * @returns A gravitational field event
  48783. */
  48784. getData(): PhysicsGravitationalFieldEventData;
  48785. /**
  48786. * Enables the gravitational field.
  48787. */
  48788. enable(): void;
  48789. /**
  48790. * Disables the gravitational field.
  48791. */
  48792. disable(): void;
  48793. /**
  48794. * Disposes the sphere.
  48795. * @param force The force to dispose from the gravitational field event
  48796. */
  48797. dispose(force?: boolean): void;
  48798. private _tick;
  48799. }
  48800. /**
  48801. * Represents a physics updraft event
  48802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48803. */
  48804. export class PhysicsUpdraftEvent {
  48805. private _scene;
  48806. private _origin;
  48807. private _radius;
  48808. private _strength;
  48809. private _height;
  48810. private _updraftMode;
  48811. private _physicsEngine;
  48812. private _originTop;
  48813. private _originDirection;
  48814. private _tickCallback;
  48815. private _cylinder;
  48816. private _cylinderPosition;
  48817. private _dataFetched;
  48818. /**
  48819. * Initializes the physics updraft event
  48820. * @param _scene BabylonJS scene
  48821. * @param _origin The origin position of the updraft
  48822. * @param _radius The radius of the updraft
  48823. * @param _strength The strength of the updraft
  48824. * @param _height The height of the updraft
  48825. * @param _updraftMode The mode of the updraft
  48826. */
  48827. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  48828. /**
  48829. * Returns the data related to the updraft event (cylinder).
  48830. * @returns A physics updraft event
  48831. */
  48832. getData(): PhysicsUpdraftEventData;
  48833. /**
  48834. * Enables the updraft.
  48835. */
  48836. enable(): void;
  48837. /**
  48838. * Disables the cortex.
  48839. */
  48840. disable(): void;
  48841. /**
  48842. * Disposes the sphere.
  48843. * @param force Specifies if the updraft should be disposed by force
  48844. */
  48845. dispose(force?: boolean): void;
  48846. private getImpostorForceAndContactPoint;
  48847. private _tick;
  48848. /*** Helpers ***/
  48849. private _prepareCylinder;
  48850. private _intersectsWithCylinder;
  48851. }
  48852. /**
  48853. * Represents a physics vortex event
  48854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48855. */
  48856. export class PhysicsVortexEvent {
  48857. private _scene;
  48858. private _origin;
  48859. private _radius;
  48860. private _strength;
  48861. private _height;
  48862. private _physicsEngine;
  48863. private _originTop;
  48864. private _centripetalForceThreshold;
  48865. private _updraftMultiplier;
  48866. private _tickCallback;
  48867. private _cylinder;
  48868. private _cylinderPosition;
  48869. private _dataFetched;
  48870. /**
  48871. * Initializes the physics vortex event
  48872. * @param _scene The BabylonJS scene
  48873. * @param _origin The origin position of the vortex
  48874. * @param _radius The radius of the vortex
  48875. * @param _strength The strength of the vortex
  48876. * @param _height The height of the vortex
  48877. */
  48878. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  48879. /**
  48880. * Returns the data related to the vortex event (cylinder).
  48881. * @returns The physics vortex event data
  48882. */
  48883. getData(): PhysicsVortexEventData;
  48884. /**
  48885. * Enables the vortex.
  48886. */
  48887. enable(): void;
  48888. /**
  48889. * Disables the cortex.
  48890. */
  48891. disable(): void;
  48892. /**
  48893. * Disposes the sphere.
  48894. * @param force
  48895. */
  48896. dispose(force?: boolean): void;
  48897. private getImpostorForceAndContactPoint;
  48898. private _tick;
  48899. /*** Helpers ***/
  48900. private _prepareCylinder;
  48901. private _intersectsWithCylinder;
  48902. }
  48903. /**
  48904. * The strenght of the force in correspondence to the distance of the affected object
  48905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48906. */
  48907. export enum PhysicsRadialImpulseFalloff {
  48908. /** Defines that impulse is constant in strength across it's whole radius */
  48909. Constant = 0,
  48910. /** DEfines that impulse gets weaker if it's further from the origin */
  48911. Linear = 1
  48912. }
  48913. /**
  48914. * The strength of the force in correspondence to the distance of the affected object
  48915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48916. */
  48917. export enum PhysicsUpdraftMode {
  48918. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  48919. Center = 0,
  48920. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  48921. Perpendicular = 1
  48922. }
  48923. /**
  48924. * Interface for a physics force and contact point
  48925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48926. */
  48927. export interface PhysicsForceAndContactPoint {
  48928. /**
  48929. * The force applied at the contact point
  48930. */
  48931. force: Vector3;
  48932. /**
  48933. * The contact point
  48934. */
  48935. contactPoint: Vector3;
  48936. }
  48937. /**
  48938. * Interface for radial explosion event data
  48939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48940. */
  48941. export interface PhysicsRadialExplosionEventData {
  48942. /**
  48943. * A sphere used for the radial explosion event
  48944. */
  48945. sphere: Mesh;
  48946. /**
  48947. * An array of rays for the radial explosion event
  48948. */
  48949. rays: Array<Ray>;
  48950. }
  48951. /**
  48952. * Interface for gravitational field event data
  48953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48954. */
  48955. export interface PhysicsGravitationalFieldEventData {
  48956. /**
  48957. * A sphere mesh used for the gravitational field event
  48958. */
  48959. sphere: Mesh;
  48960. }
  48961. /**
  48962. * Interface for updraft event data
  48963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48964. */
  48965. export interface PhysicsUpdraftEventData {
  48966. /**
  48967. * A cylinder used for the updraft event
  48968. */
  48969. cylinder: Mesh;
  48970. }
  48971. /**
  48972. * Interface for vortex event data
  48973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48974. */
  48975. export interface PhysicsVortexEventData {
  48976. /**
  48977. * A cylinder used for the vortex event
  48978. */
  48979. cylinder: Mesh;
  48980. }
  48981. }
  48982. declare module BABYLON {
  48983. /**
  48984. * AmmoJS Physics plugin
  48985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48986. * @see https://github.com/kripken/ammo.js/
  48987. */
  48988. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48989. private _useDeltaForWorldStep;
  48990. /**
  48991. * Reference to the Ammo library
  48992. */
  48993. bjsAMMO: any;
  48994. /**
  48995. * Created ammoJS world which physics bodies are added to
  48996. */
  48997. world: any;
  48998. /**
  48999. * Name of the plugin
  49000. */
  49001. name: string;
  49002. private _timeStep;
  49003. private _fixedTimeStep;
  49004. private _maxSteps;
  49005. private _tmpQuaternion;
  49006. private _tmpAmmoTransform;
  49007. private _tmpAmmoQuaternion;
  49008. private _tmpAmmoConcreteContactResultCallback;
  49009. private _collisionConfiguration;
  49010. private _dispatcher;
  49011. private _overlappingPairCache;
  49012. private _solver;
  49013. private _tmpAmmoVectorA;
  49014. private _tmpAmmoVectorB;
  49015. private _tmpAmmoVectorC;
  49016. private _tmpContactCallbackResult;
  49017. private static readonly DISABLE_COLLISION_FLAG;
  49018. private static readonly KINEMATIC_FLAG;
  49019. private static readonly DISABLE_DEACTIVATION_FLAG;
  49020. /**
  49021. * Initializes the ammoJS plugin
  49022. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49023. * @param ammoInjection can be used to inject your own ammo reference
  49024. */
  49025. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  49026. /**
  49027. * Sets the gravity of the physics world (m/(s^2))
  49028. * @param gravity Gravity to set
  49029. */
  49030. setGravity(gravity: Vector3): void;
  49031. /**
  49032. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49033. * @param timeStep timestep to use in seconds
  49034. */
  49035. setTimeStep(timeStep: number): void;
  49036. /**
  49037. * 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)
  49038. * @param fixedTimeStep fixedTimeStep to use in seconds
  49039. */
  49040. setFixedTimeStep(fixedTimeStep: number): void;
  49041. /**
  49042. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49043. * @param maxSteps the maximum number of steps by the physics engine per frame
  49044. */
  49045. setMaxSteps(maxSteps: number): void;
  49046. /**
  49047. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49048. * @returns the current timestep in seconds
  49049. */
  49050. getTimeStep(): number;
  49051. private _isImpostorInContact;
  49052. private _isImpostorPairInContact;
  49053. private _stepSimulation;
  49054. /**
  49055. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49056. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49057. * After the step the babylon meshes are set to the position of the physics imposters
  49058. * @param delta amount of time to step forward
  49059. * @param impostors array of imposters to update before/after the step
  49060. */
  49061. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49062. private _tmpVector;
  49063. private _tmpMatrix;
  49064. /**
  49065. * Applies an implulse on the imposter
  49066. * @param impostor imposter to apply impulse
  49067. * @param force amount of force to be applied to the imposter
  49068. * @param contactPoint the location to apply the impulse on the imposter
  49069. */
  49070. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49071. /**
  49072. * Applies a force on the imposter
  49073. * @param impostor imposter to apply force
  49074. * @param force amount of force to be applied to the imposter
  49075. * @param contactPoint the location to apply the force on the imposter
  49076. */
  49077. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49078. /**
  49079. * Creates a physics body using the plugin
  49080. * @param impostor the imposter to create the physics body on
  49081. */
  49082. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49083. /**
  49084. * Removes the physics body from the imposter and disposes of the body's memory
  49085. * @param impostor imposter to remove the physics body from
  49086. */
  49087. removePhysicsBody(impostor: PhysicsImpostor): void;
  49088. /**
  49089. * Generates a joint
  49090. * @param impostorJoint the imposter joint to create the joint with
  49091. */
  49092. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49093. /**
  49094. * Removes a joint
  49095. * @param impostorJoint the imposter joint to remove the joint from
  49096. */
  49097. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49098. private _addMeshVerts;
  49099. private _createShape;
  49100. /**
  49101. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49102. * @param impostor imposter containing the physics body and babylon object
  49103. */
  49104. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49105. /**
  49106. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49107. * @param impostor imposter containing the physics body and babylon object
  49108. * @param newPosition new position
  49109. * @param newRotation new rotation
  49110. */
  49111. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49112. /**
  49113. * If this plugin is supported
  49114. * @returns true if its supported
  49115. */
  49116. isSupported(): boolean;
  49117. /**
  49118. * Sets the linear velocity of the physics body
  49119. * @param impostor imposter to set the velocity on
  49120. * @param velocity velocity to set
  49121. */
  49122. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49123. /**
  49124. * Sets the angular velocity of the physics body
  49125. * @param impostor imposter to set the velocity on
  49126. * @param velocity velocity to set
  49127. */
  49128. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49129. /**
  49130. * gets the linear velocity
  49131. * @param impostor imposter to get linear velocity from
  49132. * @returns linear velocity
  49133. */
  49134. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49135. /**
  49136. * gets the angular velocity
  49137. * @param impostor imposter to get angular velocity from
  49138. * @returns angular velocity
  49139. */
  49140. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49141. /**
  49142. * Sets the mass of physics body
  49143. * @param impostor imposter to set the mass on
  49144. * @param mass mass to set
  49145. */
  49146. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49147. /**
  49148. * Gets the mass of the physics body
  49149. * @param impostor imposter to get the mass from
  49150. * @returns mass
  49151. */
  49152. getBodyMass(impostor: PhysicsImpostor): number;
  49153. /**
  49154. * Gets friction of the impostor
  49155. * @param impostor impostor to get friction from
  49156. * @returns friction value
  49157. */
  49158. getBodyFriction(impostor: PhysicsImpostor): number;
  49159. /**
  49160. * Sets friction of the impostor
  49161. * @param impostor impostor to set friction on
  49162. * @param friction friction value
  49163. */
  49164. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49165. /**
  49166. * Gets restitution of the impostor
  49167. * @param impostor impostor to get restitution from
  49168. * @returns restitution value
  49169. */
  49170. getBodyRestitution(impostor: PhysicsImpostor): number;
  49171. /**
  49172. * Sets resitution of the impostor
  49173. * @param impostor impostor to set resitution on
  49174. * @param restitution resitution value
  49175. */
  49176. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49177. /**
  49178. * Sleeps the physics body and stops it from being active
  49179. * @param impostor impostor to sleep
  49180. */
  49181. sleepBody(impostor: PhysicsImpostor): void;
  49182. /**
  49183. * Activates the physics body
  49184. * @param impostor impostor to activate
  49185. */
  49186. wakeUpBody(impostor: PhysicsImpostor): void;
  49187. /**
  49188. * Updates the distance parameters of the joint
  49189. * @param joint joint to update
  49190. * @param maxDistance maximum distance of the joint
  49191. * @param minDistance minimum distance of the joint
  49192. */
  49193. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49194. /**
  49195. * Sets a motor on the joint
  49196. * @param joint joint to set motor on
  49197. * @param speed speed of the motor
  49198. * @param maxForce maximum force of the motor
  49199. * @param motorIndex index of the motor
  49200. */
  49201. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49202. /**
  49203. * Sets the motors limit
  49204. * @param joint joint to set limit on
  49205. * @param upperLimit upper limit
  49206. * @param lowerLimit lower limit
  49207. */
  49208. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49209. /**
  49210. * Syncs the position and rotation of a mesh with the impostor
  49211. * @param mesh mesh to sync
  49212. * @param impostor impostor to update the mesh with
  49213. */
  49214. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49215. /**
  49216. * Gets the radius of the impostor
  49217. * @param impostor impostor to get radius from
  49218. * @returns the radius
  49219. */
  49220. getRadius(impostor: PhysicsImpostor): number;
  49221. /**
  49222. * Gets the box size of the impostor
  49223. * @param impostor impostor to get box size from
  49224. * @param result the resulting box size
  49225. */
  49226. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49227. /**
  49228. * Disposes of the impostor
  49229. */
  49230. dispose(): void;
  49231. }
  49232. }
  49233. declare module BABYLON {
  49234. /** @hidden */
  49235. export var blackAndWhitePixelShader: {
  49236. name: string;
  49237. shader: string;
  49238. };
  49239. }
  49240. declare module BABYLON {
  49241. /**
  49242. * Post process used to render in black and white
  49243. */
  49244. export class BlackAndWhitePostProcess extends PostProcess {
  49245. /**
  49246. * Linear about to convert he result to black and white (default: 1)
  49247. */
  49248. degree: number;
  49249. /**
  49250. * Creates a black and white post process
  49251. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  49252. * @param name The name of the effect.
  49253. * @param options The required width/height ratio to downsize to before computing the render pass.
  49254. * @param camera The camera to apply the render pass to.
  49255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49256. * @param engine The engine which the post process will be applied. (default: current engine)
  49257. * @param reusable If the post process can be reused on the same frame. (default: false)
  49258. */
  49259. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49260. }
  49261. }
  49262. declare module BABYLON {
  49263. /**
  49264. * This represents a set of one or more post processes in Babylon.
  49265. * A post process can be used to apply a shader to a texture after it is rendered.
  49266. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49267. */
  49268. export class PostProcessRenderEffect {
  49269. private _postProcesses;
  49270. private _getPostProcesses;
  49271. private _singleInstance;
  49272. private _cameras;
  49273. private _indicesForCamera;
  49274. /**
  49275. * Name of the effect
  49276. * @hidden
  49277. */
  49278. _name: string;
  49279. /**
  49280. * Instantiates a post process render effect.
  49281. * A post process can be used to apply a shader to a texture after it is rendered.
  49282. * @param engine The engine the effect is tied to
  49283. * @param name The name of the effect
  49284. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49285. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49286. */
  49287. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49288. /**
  49289. * Checks if all the post processes in the effect are supported.
  49290. */
  49291. readonly isSupported: boolean;
  49292. /**
  49293. * Updates the current state of the effect
  49294. * @hidden
  49295. */
  49296. _update(): void;
  49297. /**
  49298. * Attaches the effect on cameras
  49299. * @param cameras The camera to attach to.
  49300. * @hidden
  49301. */
  49302. _attachCameras(cameras: Camera): void;
  49303. /**
  49304. * Attaches the effect on cameras
  49305. * @param cameras The camera to attach to.
  49306. * @hidden
  49307. */
  49308. _attachCameras(cameras: Camera[]): void;
  49309. /**
  49310. * Detatches the effect on cameras
  49311. * @param cameras The camera to detatch from.
  49312. * @hidden
  49313. */
  49314. _detachCameras(cameras: Camera): void;
  49315. /**
  49316. * Detatches the effect on cameras
  49317. * @param cameras The camera to detatch from.
  49318. * @hidden
  49319. */
  49320. _detachCameras(cameras: Camera[]): void;
  49321. /**
  49322. * Enables the effect on given cameras
  49323. * @param cameras The camera to enable.
  49324. * @hidden
  49325. */
  49326. _enable(cameras: Camera): void;
  49327. /**
  49328. * Enables the effect on given cameras
  49329. * @param cameras The camera to enable.
  49330. * @hidden
  49331. */
  49332. _enable(cameras: Nullable<Camera[]>): void;
  49333. /**
  49334. * Disables the effect on the given cameras
  49335. * @param cameras The camera to disable.
  49336. * @hidden
  49337. */
  49338. _disable(cameras: Camera): void;
  49339. /**
  49340. * Disables the effect on the given cameras
  49341. * @param cameras The camera to disable.
  49342. * @hidden
  49343. */
  49344. _disable(cameras: Nullable<Camera[]>): void;
  49345. /**
  49346. * Gets a list of the post processes contained in the effect.
  49347. * @param camera The camera to get the post processes on.
  49348. * @returns The list of the post processes in the effect.
  49349. */
  49350. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49351. }
  49352. }
  49353. declare module BABYLON {
  49354. /** @hidden */
  49355. export var extractHighlightsPixelShader: {
  49356. name: string;
  49357. shader: string;
  49358. };
  49359. }
  49360. declare module BABYLON {
  49361. /**
  49362. * 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.
  49363. */
  49364. export class ExtractHighlightsPostProcess extends PostProcess {
  49365. /**
  49366. * The luminance threshold, pixels below this value will be set to black.
  49367. */
  49368. threshold: number;
  49369. /** @hidden */
  49370. _exposure: number;
  49371. /**
  49372. * Post process which has the input texture to be used when performing highlight extraction
  49373. * @hidden
  49374. */
  49375. _inputPostProcess: Nullable<PostProcess>;
  49376. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49377. }
  49378. }
  49379. declare module BABYLON {
  49380. /** @hidden */
  49381. export var bloomMergePixelShader: {
  49382. name: string;
  49383. shader: string;
  49384. };
  49385. }
  49386. declare module BABYLON {
  49387. /**
  49388. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  49389. */
  49390. export class BloomMergePostProcess extends PostProcess {
  49391. /** Weight of the bloom to be added to the original input. */
  49392. weight: number;
  49393. /**
  49394. * Creates a new instance of @see BloomMergePostProcess
  49395. * @param name The name of the effect.
  49396. * @param originalFromInput Post process which's input will be used for the merge.
  49397. * @param blurred Blurred highlights post process which's output will be used.
  49398. * @param weight Weight of the bloom to be added to the original input.
  49399. * @param options The required width/height ratio to downsize to before computing the render pass.
  49400. * @param camera The camera to apply the render pass to.
  49401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49402. * @param engine The engine which the post process will be applied. (default: current engine)
  49403. * @param reusable If the post process can be reused on the same frame. (default: false)
  49404. * @param textureType Type of textures used when performing the post process. (default: 0)
  49405. * @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)
  49406. */
  49407. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  49408. /** Weight of the bloom to be added to the original input. */
  49409. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49410. }
  49411. }
  49412. declare module BABYLON {
  49413. /**
  49414. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  49415. */
  49416. export class BloomEffect extends PostProcessRenderEffect {
  49417. private bloomScale;
  49418. /**
  49419. * @hidden Internal
  49420. */
  49421. _effects: Array<PostProcess>;
  49422. /**
  49423. * @hidden Internal
  49424. */
  49425. _downscale: ExtractHighlightsPostProcess;
  49426. private _blurX;
  49427. private _blurY;
  49428. private _merge;
  49429. /**
  49430. * The luminance threshold to find bright areas of the image to bloom.
  49431. */
  49432. threshold: number;
  49433. /**
  49434. * The strength of the bloom.
  49435. */
  49436. weight: number;
  49437. /**
  49438. * Specifies the size of the bloom blur kernel, relative to the final output size
  49439. */
  49440. kernel: number;
  49441. /**
  49442. * Creates a new instance of @see BloomEffect
  49443. * @param scene The scene the effect belongs to.
  49444. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  49445. * @param bloomKernel The size of the kernel to be used when applying the blur.
  49446. * @param bloomWeight The the strength of bloom.
  49447. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  49448. * @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)
  49449. */
  49450. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  49451. /**
  49452. * Disposes each of the internal effects for a given camera.
  49453. * @param camera The camera to dispose the effect on.
  49454. */
  49455. disposeEffects(camera: Camera): void;
  49456. /**
  49457. * @hidden Internal
  49458. */
  49459. _updateEffects(): void;
  49460. /**
  49461. * Internal
  49462. * @returns if all the contained post processes are ready.
  49463. * @hidden
  49464. */
  49465. _isReady(): boolean;
  49466. }
  49467. }
  49468. declare module BABYLON {
  49469. /** @hidden */
  49470. export var chromaticAberrationPixelShader: {
  49471. name: string;
  49472. shader: string;
  49473. };
  49474. }
  49475. declare module BABYLON {
  49476. /**
  49477. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  49478. */
  49479. export class ChromaticAberrationPostProcess extends PostProcess {
  49480. /**
  49481. * The amount of seperation of rgb channels (default: 30)
  49482. */
  49483. aberrationAmount: number;
  49484. /**
  49485. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  49486. */
  49487. radialIntensity: number;
  49488. /**
  49489. * 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))
  49490. */
  49491. direction: Vector2;
  49492. /**
  49493. * 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))
  49494. */
  49495. centerPosition: Vector2;
  49496. /**
  49497. * Creates a new instance ChromaticAberrationPostProcess
  49498. * @param name The name of the effect.
  49499. * @param screenWidth The width of the screen to apply the effect on.
  49500. * @param screenHeight The height of the screen to apply the effect on.
  49501. * @param options The required width/height ratio to downsize to before computing the render pass.
  49502. * @param camera The camera to apply the render pass to.
  49503. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49504. * @param engine The engine which the post process will be applied. (default: current engine)
  49505. * @param reusable If the post process can be reused on the same frame. (default: false)
  49506. * @param textureType Type of textures used when performing the post process. (default: 0)
  49507. * @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)
  49508. */
  49509. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49510. }
  49511. }
  49512. declare module BABYLON {
  49513. /** @hidden */
  49514. export var circleOfConfusionPixelShader: {
  49515. name: string;
  49516. shader: string;
  49517. };
  49518. }
  49519. declare module BABYLON {
  49520. /**
  49521. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  49522. */
  49523. export class CircleOfConfusionPostProcess extends PostProcess {
  49524. /**
  49525. * 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.
  49526. */
  49527. lensSize: number;
  49528. /**
  49529. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  49530. */
  49531. fStop: number;
  49532. /**
  49533. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  49534. */
  49535. focusDistance: number;
  49536. /**
  49537. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  49538. */
  49539. focalLength: number;
  49540. private _depthTexture;
  49541. /**
  49542. * Creates a new instance CircleOfConfusionPostProcess
  49543. * @param name The name of the effect.
  49544. * @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.
  49545. * @param options The required width/height ratio to downsize to before computing the render pass.
  49546. * @param camera The camera to apply the render pass to.
  49547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49548. * @param engine The engine which the post process will be applied. (default: current engine)
  49549. * @param reusable If the post process can be reused on the same frame. (default: false)
  49550. * @param textureType Type of textures used when performing the post process. (default: 0)
  49551. * @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)
  49552. */
  49553. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49554. /**
  49555. * 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.
  49556. */
  49557. depthTexture: RenderTargetTexture;
  49558. }
  49559. }
  49560. declare module BABYLON {
  49561. /** @hidden */
  49562. export var colorCorrectionPixelShader: {
  49563. name: string;
  49564. shader: string;
  49565. };
  49566. }
  49567. declare module BABYLON {
  49568. /**
  49569. *
  49570. * This post-process allows the modification of rendered colors by using
  49571. * a 'look-up table' (LUT). This effect is also called Color Grading.
  49572. *
  49573. * The object needs to be provided an url to a texture containing the color
  49574. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  49575. * Use an image editing software to tweak the LUT to match your needs.
  49576. *
  49577. * For an example of a color LUT, see here:
  49578. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  49579. * For explanations on color grading, see here:
  49580. * @see http://udn.epicgames.com/Three/ColorGrading.html
  49581. *
  49582. */
  49583. export class ColorCorrectionPostProcess extends PostProcess {
  49584. private _colorTableTexture;
  49585. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49586. }
  49587. }
  49588. declare module BABYLON {
  49589. /** @hidden */
  49590. export var convolutionPixelShader: {
  49591. name: string;
  49592. shader: string;
  49593. };
  49594. }
  49595. declare module BABYLON {
  49596. /**
  49597. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  49598. * input texture to perform effects such as edge detection or sharpening
  49599. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  49600. */
  49601. export class ConvolutionPostProcess extends PostProcess {
  49602. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  49603. kernel: number[];
  49604. /**
  49605. * Creates a new instance ConvolutionPostProcess
  49606. * @param name The name of the effect.
  49607. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  49608. * @param options The required width/height ratio to downsize to before computing the render pass.
  49609. * @param camera The camera to apply the render pass to.
  49610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49611. * @param engine The engine which the post process will be applied. (default: current engine)
  49612. * @param reusable If the post process can be reused on the same frame. (default: false)
  49613. * @param textureType Type of textures used when performing the post process. (default: 0)
  49614. */
  49615. constructor(name: string,
  49616. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  49617. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49618. /**
  49619. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49620. */
  49621. static EdgeDetect0Kernel: number[];
  49622. /**
  49623. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49624. */
  49625. static EdgeDetect1Kernel: number[];
  49626. /**
  49627. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49628. */
  49629. static EdgeDetect2Kernel: number[];
  49630. /**
  49631. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49632. */
  49633. static SharpenKernel: number[];
  49634. /**
  49635. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49636. */
  49637. static EmbossKernel: number[];
  49638. /**
  49639. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49640. */
  49641. static GaussianKernel: number[];
  49642. }
  49643. }
  49644. declare module BABYLON {
  49645. /**
  49646. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  49647. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  49648. * based on samples that have a large difference in distance than the center pixel.
  49649. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  49650. */
  49651. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  49652. direction: Vector2;
  49653. /**
  49654. * Creates a new instance CircleOfConfusionPostProcess
  49655. * @param name The name of the effect.
  49656. * @param scene The scene the effect belongs to.
  49657. * @param direction The direction the blur should be applied.
  49658. * @param kernel The size of the kernel used to blur.
  49659. * @param options The required width/height ratio to downsize to before computing the render pass.
  49660. * @param camera The camera to apply the render pass to.
  49661. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  49662. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  49663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49664. * @param engine The engine which the post process will be applied. (default: current engine)
  49665. * @param reusable If the post process can be reused on the same frame. (default: false)
  49666. * @param textureType Type of textures used when performing the post process. (default: 0)
  49667. * @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)
  49668. */
  49669. 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);
  49670. }
  49671. }
  49672. declare module BABYLON {
  49673. /** @hidden */
  49674. export var depthOfFieldMergePixelShader: {
  49675. name: string;
  49676. shader: string;
  49677. };
  49678. }
  49679. declare module BABYLON {
  49680. /**
  49681. * Options to be set when merging outputs from the default pipeline.
  49682. */
  49683. export class DepthOfFieldMergePostProcessOptions {
  49684. /**
  49685. * The original image to merge on top of
  49686. */
  49687. originalFromInput: PostProcess;
  49688. /**
  49689. * Parameters to perform the merge of the depth of field effect
  49690. */
  49691. depthOfField?: {
  49692. circleOfConfusion: PostProcess;
  49693. blurSteps: Array<PostProcess>;
  49694. };
  49695. /**
  49696. * Parameters to perform the merge of bloom effect
  49697. */
  49698. bloom?: {
  49699. blurred: PostProcess;
  49700. weight: number;
  49701. };
  49702. }
  49703. /**
  49704. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  49705. */
  49706. export class DepthOfFieldMergePostProcess extends PostProcess {
  49707. private blurSteps;
  49708. /**
  49709. * Creates a new instance of DepthOfFieldMergePostProcess
  49710. * @param name The name of the effect.
  49711. * @param originalFromInput Post process which's input will be used for the merge.
  49712. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  49713. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  49714. * @param options The required width/height ratio to downsize to before computing the render pass.
  49715. * @param camera The camera to apply the render pass to.
  49716. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49717. * @param engine The engine which the post process will be applied. (default: current engine)
  49718. * @param reusable If the post process can be reused on the same frame. (default: false)
  49719. * @param textureType Type of textures used when performing the post process. (default: 0)
  49720. * @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)
  49721. */
  49722. 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);
  49723. /**
  49724. * Updates the effect with the current post process compile time values and recompiles the shader.
  49725. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  49726. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  49727. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  49728. * @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
  49729. * @param onCompiled Called when the shader has been compiled.
  49730. * @param onError Called if there is an error when compiling a shader.
  49731. */
  49732. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  49733. }
  49734. }
  49735. declare module BABYLON {
  49736. /**
  49737. * Specifies the level of max blur that should be applied when using the depth of field effect
  49738. */
  49739. export enum DepthOfFieldEffectBlurLevel {
  49740. /**
  49741. * Subtle blur
  49742. */
  49743. Low = 0,
  49744. /**
  49745. * Medium blur
  49746. */
  49747. Medium = 1,
  49748. /**
  49749. * Large blur
  49750. */
  49751. High = 2
  49752. }
  49753. /**
  49754. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  49755. */
  49756. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  49757. private _circleOfConfusion;
  49758. /**
  49759. * @hidden Internal, blurs from high to low
  49760. */
  49761. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  49762. private _depthOfFieldBlurY;
  49763. private _dofMerge;
  49764. /**
  49765. * @hidden Internal post processes in depth of field effect
  49766. */
  49767. _effects: Array<PostProcess>;
  49768. /**
  49769. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  49770. */
  49771. focalLength: number;
  49772. /**
  49773. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  49774. */
  49775. fStop: number;
  49776. /**
  49777. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  49778. */
  49779. focusDistance: number;
  49780. /**
  49781. * 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.
  49782. */
  49783. lensSize: number;
  49784. /**
  49785. * Creates a new instance DepthOfFieldEffect
  49786. * @param scene The scene the effect belongs to.
  49787. * @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.
  49788. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  49789. * @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)
  49790. */
  49791. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  49792. /**
  49793. * 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.
  49794. */
  49795. depthTexture: RenderTargetTexture;
  49796. /**
  49797. * Disposes each of the internal effects for a given camera.
  49798. * @param camera The camera to dispose the effect on.
  49799. */
  49800. disposeEffects(camera: Camera): void;
  49801. /**
  49802. * @hidden Internal
  49803. */
  49804. _updateEffects(): void;
  49805. /**
  49806. * Internal
  49807. * @returns if all the contained post processes are ready.
  49808. * @hidden
  49809. */
  49810. _isReady(): boolean;
  49811. }
  49812. }
  49813. declare module BABYLON {
  49814. /** @hidden */
  49815. export var displayPassPixelShader: {
  49816. name: string;
  49817. shader: string;
  49818. };
  49819. }
  49820. declare module BABYLON {
  49821. /**
  49822. * DisplayPassPostProcess which produces an output the same as it's input
  49823. */
  49824. export class DisplayPassPostProcess extends PostProcess {
  49825. /**
  49826. * Creates the DisplayPassPostProcess
  49827. * @param name The name of the effect.
  49828. * @param options The required width/height ratio to downsize to before computing the render pass.
  49829. * @param camera The camera to apply the render pass to.
  49830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49831. * @param engine The engine which the post process will be applied. (default: current engine)
  49832. * @param reusable If the post process can be reused on the same frame. (default: false)
  49833. */
  49834. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49835. }
  49836. }
  49837. declare module BABYLON {
  49838. /** @hidden */
  49839. export var filterPixelShader: {
  49840. name: string;
  49841. shader: string;
  49842. };
  49843. }
  49844. declare module BABYLON {
  49845. /**
  49846. * Applies a kernel filter to the image
  49847. */
  49848. export class FilterPostProcess extends PostProcess {
  49849. /** The matrix to be applied to the image */
  49850. kernelMatrix: Matrix;
  49851. /**
  49852. *
  49853. * @param name The name of the effect.
  49854. * @param kernelMatrix The matrix to be applied to the image
  49855. * @param options The required width/height ratio to downsize to before computing the render pass.
  49856. * @param camera The camera to apply the render pass to.
  49857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49858. * @param engine The engine which the post process will be applied. (default: current engine)
  49859. * @param reusable If the post process can be reused on the same frame. (default: false)
  49860. */
  49861. constructor(name: string,
  49862. /** The matrix to be applied to the image */
  49863. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49864. }
  49865. }
  49866. declare module BABYLON {
  49867. /** @hidden */
  49868. export var fxaaPixelShader: {
  49869. name: string;
  49870. shader: string;
  49871. };
  49872. }
  49873. declare module BABYLON {
  49874. /** @hidden */
  49875. export var fxaaVertexShader: {
  49876. name: string;
  49877. shader: string;
  49878. };
  49879. }
  49880. declare module BABYLON {
  49881. /**
  49882. * Fxaa post process
  49883. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  49884. */
  49885. export class FxaaPostProcess extends PostProcess {
  49886. /** @hidden */
  49887. texelWidth: number;
  49888. /** @hidden */
  49889. texelHeight: number;
  49890. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49891. private _getDefines;
  49892. }
  49893. }
  49894. declare module BABYLON {
  49895. /** @hidden */
  49896. export var grainPixelShader: {
  49897. name: string;
  49898. shader: string;
  49899. };
  49900. }
  49901. declare module BABYLON {
  49902. /**
  49903. * The GrainPostProcess adds noise to the image at mid luminance levels
  49904. */
  49905. export class GrainPostProcess extends PostProcess {
  49906. /**
  49907. * The intensity of the grain added (default: 30)
  49908. */
  49909. intensity: number;
  49910. /**
  49911. * If the grain should be randomized on every frame
  49912. */
  49913. animated: boolean;
  49914. /**
  49915. * Creates a new instance of @see GrainPostProcess
  49916. * @param name The name of the effect.
  49917. * @param options The required width/height ratio to downsize to before computing the render pass.
  49918. * @param camera The camera to apply the render pass to.
  49919. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49920. * @param engine The engine which the post process will be applied. (default: current engine)
  49921. * @param reusable If the post process can be reused on the same frame. (default: false)
  49922. * @param textureType Type of textures used when performing the post process. (default: 0)
  49923. * @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)
  49924. */
  49925. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49926. }
  49927. }
  49928. declare module BABYLON {
  49929. /** @hidden */
  49930. export var highlightsPixelShader: {
  49931. name: string;
  49932. shader: string;
  49933. };
  49934. }
  49935. declare module BABYLON {
  49936. /**
  49937. * Extracts highlights from the image
  49938. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  49939. */
  49940. export class HighlightsPostProcess extends PostProcess {
  49941. /**
  49942. * Extracts highlights from the image
  49943. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  49944. * @param name The name of the effect.
  49945. * @param options The required width/height ratio to downsize to before computing the render pass.
  49946. * @param camera The camera to apply the render pass to.
  49947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49948. * @param engine The engine which the post process will be applied. (default: current engine)
  49949. * @param reusable If the post process can be reused on the same frame. (default: false)
  49950. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  49951. */
  49952. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49953. }
  49954. }
  49955. declare module BABYLON {
  49956. /** @hidden */
  49957. export var mrtFragmentDeclaration: {
  49958. name: string;
  49959. shader: string;
  49960. };
  49961. }
  49962. declare module BABYLON {
  49963. /** @hidden */
  49964. export var geometryPixelShader: {
  49965. name: string;
  49966. shader: string;
  49967. };
  49968. }
  49969. declare module BABYLON {
  49970. /** @hidden */
  49971. export var geometryVertexShader: {
  49972. name: string;
  49973. shader: string;
  49974. };
  49975. }
  49976. declare module BABYLON {
  49977. /**
  49978. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  49979. */
  49980. export class GeometryBufferRenderer {
  49981. /**
  49982. * Constant used to retrieve the position texture index in the G-Buffer textures array
  49983. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  49984. */
  49985. static readonly POSITION_TEXTURE_TYPE: number;
  49986. /**
  49987. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  49988. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  49989. */
  49990. static readonly VELOCITY_TEXTURE_TYPE: number;
  49991. /**
  49992. * Dictionary used to store the previous transformation matrices of each rendered mesh
  49993. * in order to compute objects velocities when enableVelocity is set to "true"
  49994. * @hidden
  49995. */
  49996. _previousTransformationMatrices: {
  49997. [index: number]: Matrix;
  49998. };
  49999. private _scene;
  50000. private _multiRenderTarget;
  50001. private _ratio;
  50002. private _enablePosition;
  50003. private _enableVelocity;
  50004. private _positionIndex;
  50005. private _velocityIndex;
  50006. protected _effect: Effect;
  50007. protected _cachedDefines: string;
  50008. /**
  50009. * Set the render list (meshes to be rendered) used in the G buffer.
  50010. */
  50011. renderList: Mesh[];
  50012. /**
  50013. * Gets wether or not G buffer are supported by the running hardware.
  50014. * This requires draw buffer supports
  50015. */
  50016. readonly isSupported: boolean;
  50017. /**
  50018. * Returns the index of the given texture type in the G-Buffer textures array
  50019. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  50020. * @returns the index of the given texture type in the G-Buffer textures array
  50021. */
  50022. getTextureIndex(textureType: number): number;
  50023. /**
  50024. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  50025. */
  50026. /**
  50027. * Sets whether or not objects positions are enabled for the G buffer.
  50028. */
  50029. enablePosition: boolean;
  50030. /**
  50031. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  50032. */
  50033. /**
  50034. * Sets wether or not objects velocities are enabled for the G buffer.
  50035. */
  50036. enableVelocity: boolean;
  50037. /**
  50038. * Gets the scene associated with the buffer.
  50039. */
  50040. readonly scene: Scene;
  50041. /**
  50042. * Gets the ratio used by the buffer during its creation.
  50043. * How big is the buffer related to the main canvas.
  50044. */
  50045. readonly ratio: number;
  50046. /** @hidden */
  50047. static _SceneComponentInitialization: (scene: Scene) => void;
  50048. /**
  50049. * Creates a new G Buffer for the scene
  50050. * @param scene The scene the buffer belongs to
  50051. * @param ratio How big is the buffer related to the main canvas.
  50052. */
  50053. constructor(scene: Scene, ratio?: number);
  50054. /**
  50055. * Checks wether everything is ready to render a submesh to the G buffer.
  50056. * @param subMesh the submesh to check readiness for
  50057. * @param useInstances is the mesh drawn using instance or not
  50058. * @returns true if ready otherwise false
  50059. */
  50060. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50061. /**
  50062. * Gets the current underlying G Buffer.
  50063. * @returns the buffer
  50064. */
  50065. getGBuffer(): MultiRenderTarget;
  50066. /**
  50067. * Gets the number of samples used to render the buffer (anti aliasing).
  50068. */
  50069. /**
  50070. * Sets the number of samples used to render the buffer (anti aliasing).
  50071. */
  50072. samples: number;
  50073. /**
  50074. * Disposes the renderer and frees up associated resources.
  50075. */
  50076. dispose(): void;
  50077. protected _createRenderTargets(): void;
  50078. }
  50079. }
  50080. declare module BABYLON {
  50081. /** @hidden */
  50082. export var motionBlurPixelShader: {
  50083. name: string;
  50084. shader: string;
  50085. };
  50086. }
  50087. declare module BABYLON {
  50088. /**
  50089. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  50090. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  50091. * As an example, all you have to do is to create the post-process:
  50092. * var mb = new BABYLON.MotionBlurPostProcess(
  50093. * 'mb', // The name of the effect.
  50094. * scene, // The scene containing the objects to blur according to their velocity.
  50095. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  50096. * camera // The camera to apply the render pass to.
  50097. * );
  50098. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  50099. */
  50100. export class MotionBlurPostProcess extends PostProcess {
  50101. /**
  50102. * Defines how much the image is blurred by the movement. Default value is equal to 1
  50103. */
  50104. motionStrength: number;
  50105. /**
  50106. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  50107. */
  50108. /**
  50109. * Sets the number of iterations to be used for motion blur quality
  50110. */
  50111. motionBlurSamples: number;
  50112. private _motionBlurSamples;
  50113. private _geometryBufferRenderer;
  50114. /**
  50115. * Creates a new instance MotionBlurPostProcess
  50116. * @param name The name of the effect.
  50117. * @param scene The scene containing the objects to blur according to their velocity.
  50118. * @param options The required width/height ratio to downsize to before computing the render pass.
  50119. * @param camera The camera to apply the render pass to.
  50120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50121. * @param engine The engine which the post process will be applied. (default: current engine)
  50122. * @param reusable If the post process can be reused on the same frame. (default: false)
  50123. * @param textureType Type of textures used when performing the post process. (default: 0)
  50124. * @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)
  50125. */
  50126. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50127. /**
  50128. * Disposes the post process.
  50129. * @param camera The camera to dispose the post process on.
  50130. */
  50131. dispose(camera?: Camera): void;
  50132. }
  50133. }
  50134. declare module BABYLON {
  50135. /** @hidden */
  50136. export var refractionPixelShader: {
  50137. name: string;
  50138. shader: string;
  50139. };
  50140. }
  50141. declare module BABYLON {
  50142. /**
  50143. * Post process which applies a refractin texture
  50144. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  50145. */
  50146. export class RefractionPostProcess extends PostProcess {
  50147. /** the base color of the refraction (used to taint the rendering) */
  50148. color: Color3;
  50149. /** simulated refraction depth */
  50150. depth: number;
  50151. /** the coefficient of the base color (0 to remove base color tainting) */
  50152. colorLevel: number;
  50153. private _refTexture;
  50154. private _ownRefractionTexture;
  50155. /**
  50156. * Gets or sets the refraction texture
  50157. * Please note that you are responsible for disposing the texture if you set it manually
  50158. */
  50159. refractionTexture: Texture;
  50160. /**
  50161. * Initializes the RefractionPostProcess
  50162. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  50163. * @param name The name of the effect.
  50164. * @param refractionTextureUrl Url of the refraction texture to use
  50165. * @param color the base color of the refraction (used to taint the rendering)
  50166. * @param depth simulated refraction depth
  50167. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  50168. * @param camera The camera to apply the render pass to.
  50169. * @param options The required width/height ratio to downsize to before computing the render pass.
  50170. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50171. * @param engine The engine which the post process will be applied. (default: current engine)
  50172. * @param reusable If the post process can be reused on the same frame. (default: false)
  50173. */
  50174. constructor(name: string, refractionTextureUrl: string,
  50175. /** the base color of the refraction (used to taint the rendering) */
  50176. color: Color3,
  50177. /** simulated refraction depth */
  50178. depth: number,
  50179. /** the coefficient of the base color (0 to remove base color tainting) */
  50180. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50181. /**
  50182. * Disposes of the post process
  50183. * @param camera Camera to dispose post process on
  50184. */
  50185. dispose(camera: Camera): void;
  50186. }
  50187. }
  50188. declare module BABYLON {
  50189. /** @hidden */
  50190. export var sharpenPixelShader: {
  50191. name: string;
  50192. shader: string;
  50193. };
  50194. }
  50195. declare module BABYLON {
  50196. /**
  50197. * The SharpenPostProcess applies a sharpen kernel to every pixel
  50198. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  50199. */
  50200. export class SharpenPostProcess extends PostProcess {
  50201. /**
  50202. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  50203. */
  50204. colorAmount: number;
  50205. /**
  50206. * How much sharpness should be applied (default: 0.3)
  50207. */
  50208. edgeAmount: number;
  50209. /**
  50210. * Creates a new instance ConvolutionPostProcess
  50211. * @param name The name of the effect.
  50212. * @param options The required width/height ratio to downsize to before computing the render pass.
  50213. * @param camera The camera to apply the render pass to.
  50214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50215. * @param engine The engine which the post process will be applied. (default: current engine)
  50216. * @param reusable If the post process can be reused on the same frame. (default: false)
  50217. * @param textureType Type of textures used when performing the post process. (default: 0)
  50218. * @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)
  50219. */
  50220. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50221. }
  50222. }
  50223. declare module BABYLON {
  50224. /**
  50225. * PostProcessRenderPipeline
  50226. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50227. */
  50228. export class PostProcessRenderPipeline {
  50229. private engine;
  50230. private _renderEffects;
  50231. private _renderEffectsForIsolatedPass;
  50232. /**
  50233. * @hidden
  50234. */
  50235. protected _cameras: Camera[];
  50236. /** @hidden */
  50237. _name: string;
  50238. /**
  50239. * Initializes a PostProcessRenderPipeline
  50240. * @param engine engine to add the pipeline to
  50241. * @param name name of the pipeline
  50242. */
  50243. constructor(engine: Engine, name: string);
  50244. /**
  50245. * "PostProcessRenderPipeline"
  50246. * @returns "PostProcessRenderPipeline"
  50247. */
  50248. getClassName(): string;
  50249. /**
  50250. * If all the render effects in the pipeline are support
  50251. */
  50252. readonly isSupported: boolean;
  50253. /**
  50254. * Adds an effect to the pipeline
  50255. * @param renderEffect the effect to add
  50256. */
  50257. addEffect(renderEffect: PostProcessRenderEffect): void;
  50258. /** @hidden */
  50259. _rebuild(): void;
  50260. /** @hidden */
  50261. _enableEffect(renderEffectName: string, cameras: Camera): void;
  50262. /** @hidden */
  50263. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  50264. /** @hidden */
  50265. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  50266. /** @hidden */
  50267. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  50268. /** @hidden */
  50269. _attachCameras(cameras: Camera, unique: boolean): void;
  50270. /** @hidden */
  50271. _attachCameras(cameras: Camera[], unique: boolean): void;
  50272. /** @hidden */
  50273. _detachCameras(cameras: Camera): void;
  50274. /** @hidden */
  50275. _detachCameras(cameras: Nullable<Camera[]>): void;
  50276. /** @hidden */
  50277. _update(): void;
  50278. /** @hidden */
  50279. _reset(): void;
  50280. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  50281. /**
  50282. * Disposes of the pipeline
  50283. */
  50284. dispose(): void;
  50285. }
  50286. }
  50287. declare module BABYLON {
  50288. /**
  50289. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  50290. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50291. */
  50292. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50293. private _scene;
  50294. private _camerasToBeAttached;
  50295. /**
  50296. * ID of the sharpen post process,
  50297. */
  50298. private readonly SharpenPostProcessId;
  50299. /**
  50300. * @ignore
  50301. * ID of the image processing post process;
  50302. */
  50303. readonly ImageProcessingPostProcessId: string;
  50304. /**
  50305. * @ignore
  50306. * ID of the Fast Approximate Anti-Aliasing post process;
  50307. */
  50308. readonly FxaaPostProcessId: string;
  50309. /**
  50310. * ID of the chromatic aberration post process,
  50311. */
  50312. private readonly ChromaticAberrationPostProcessId;
  50313. /**
  50314. * ID of the grain post process
  50315. */
  50316. private readonly GrainPostProcessId;
  50317. /**
  50318. * Sharpen post process which will apply a sharpen convolution to enhance edges
  50319. */
  50320. sharpen: SharpenPostProcess;
  50321. private _sharpenEffect;
  50322. private bloom;
  50323. /**
  50324. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  50325. */
  50326. depthOfField: DepthOfFieldEffect;
  50327. /**
  50328. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50329. */
  50330. fxaa: FxaaPostProcess;
  50331. /**
  50332. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50333. */
  50334. imageProcessing: ImageProcessingPostProcess;
  50335. /**
  50336. * Chromatic aberration post process which will shift rgb colors in the image
  50337. */
  50338. chromaticAberration: ChromaticAberrationPostProcess;
  50339. private _chromaticAberrationEffect;
  50340. /**
  50341. * Grain post process which add noise to the image
  50342. */
  50343. grain: GrainPostProcess;
  50344. private _grainEffect;
  50345. /**
  50346. * Glow post process which adds a glow to emmisive areas of the image
  50347. */
  50348. private _glowLayer;
  50349. /**
  50350. * Animations which can be used to tweak settings over a period of time
  50351. */
  50352. animations: Animation[];
  50353. private _imageProcessingConfigurationObserver;
  50354. private _sharpenEnabled;
  50355. private _bloomEnabled;
  50356. private _depthOfFieldEnabled;
  50357. private _depthOfFieldBlurLevel;
  50358. private _fxaaEnabled;
  50359. private _imageProcessingEnabled;
  50360. private _defaultPipelineTextureType;
  50361. private _bloomScale;
  50362. private _chromaticAberrationEnabled;
  50363. private _grainEnabled;
  50364. private _buildAllowed;
  50365. /**
  50366. * Enable or disable the sharpen process from the pipeline
  50367. */
  50368. sharpenEnabled: boolean;
  50369. private _resizeObserver;
  50370. private _hardwareScaleLevel;
  50371. private _bloomKernel;
  50372. /**
  50373. * Specifies the size of the bloom blur kernel, relative to the final output size
  50374. */
  50375. bloomKernel: number;
  50376. /**
  50377. * Specifies the weight of the bloom in the final rendering
  50378. */
  50379. private _bloomWeight;
  50380. /**
  50381. * Specifies the luma threshold for the area that will be blurred by the bloom
  50382. */
  50383. private _bloomThreshold;
  50384. private _hdr;
  50385. /**
  50386. * The strength of the bloom.
  50387. */
  50388. bloomWeight: number;
  50389. /**
  50390. * The strength of the bloom.
  50391. */
  50392. bloomThreshold: number;
  50393. /**
  50394. * The scale of the bloom, lower value will provide better performance.
  50395. */
  50396. bloomScale: number;
  50397. /**
  50398. * Enable or disable the bloom from the pipeline
  50399. */
  50400. bloomEnabled: boolean;
  50401. private _rebuildBloom;
  50402. /**
  50403. * If the depth of field is enabled.
  50404. */
  50405. depthOfFieldEnabled: boolean;
  50406. /**
  50407. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50408. */
  50409. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50410. /**
  50411. * If the anti aliasing is enabled.
  50412. */
  50413. fxaaEnabled: boolean;
  50414. private _samples;
  50415. /**
  50416. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50417. */
  50418. samples: number;
  50419. /**
  50420. * If image processing is enabled.
  50421. */
  50422. imageProcessingEnabled: boolean;
  50423. /**
  50424. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50425. */
  50426. glowLayerEnabled: boolean;
  50427. /**
  50428. * Enable or disable the chromaticAberration process from the pipeline
  50429. */
  50430. chromaticAberrationEnabled: boolean;
  50431. /**
  50432. * Enable or disable the grain process from the pipeline
  50433. */
  50434. grainEnabled: boolean;
  50435. /**
  50436. * @constructor
  50437. * @param name - The rendering pipeline name (default: "")
  50438. * @param hdr - If high dynamic range textures should be used (default: true)
  50439. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50440. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50441. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50442. */
  50443. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50444. /**
  50445. * Force the compilation of the entire pipeline.
  50446. */
  50447. prepare(): void;
  50448. private _hasCleared;
  50449. private _prevPostProcess;
  50450. private _prevPrevPostProcess;
  50451. private _setAutoClearAndTextureSharing;
  50452. private _depthOfFieldSceneObserver;
  50453. private _buildPipeline;
  50454. private _disposePostProcesses;
  50455. /**
  50456. * Adds a camera to the pipeline
  50457. * @param camera the camera to be added
  50458. */
  50459. addCamera(camera: Camera): void;
  50460. /**
  50461. * Removes a camera from the pipeline
  50462. * @param camera the camera to remove
  50463. */
  50464. removeCamera(camera: Camera): void;
  50465. /**
  50466. * Dispose of the pipeline and stop all post processes
  50467. */
  50468. dispose(): void;
  50469. /**
  50470. * Serialize the rendering pipeline (Used when exporting)
  50471. * @returns the serialized object
  50472. */
  50473. serialize(): any;
  50474. /**
  50475. * Parse the serialized pipeline
  50476. * @param source Source pipeline.
  50477. * @param scene The scene to load the pipeline to.
  50478. * @param rootUrl The URL of the serialized pipeline.
  50479. * @returns An instantiated pipeline from the serialized object.
  50480. */
  50481. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50482. }
  50483. }
  50484. declare module BABYLON {
  50485. /** @hidden */
  50486. export var lensHighlightsPixelShader: {
  50487. name: string;
  50488. shader: string;
  50489. };
  50490. }
  50491. declare module BABYLON {
  50492. /** @hidden */
  50493. export var depthOfFieldPixelShader: {
  50494. name: string;
  50495. shader: string;
  50496. };
  50497. }
  50498. declare module BABYLON {
  50499. /**
  50500. * BABYLON.JS Chromatic Aberration GLSL Shader
  50501. * Author: Olivier Guyot
  50502. * Separates very slightly R, G and B colors on the edges of the screen
  50503. * Inspired by Francois Tarlier & Martins Upitis
  50504. */
  50505. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  50506. /**
  50507. * @ignore
  50508. * The chromatic aberration PostProcess id in the pipeline
  50509. */
  50510. LensChromaticAberrationEffect: string;
  50511. /**
  50512. * @ignore
  50513. * The highlights enhancing PostProcess id in the pipeline
  50514. */
  50515. HighlightsEnhancingEffect: string;
  50516. /**
  50517. * @ignore
  50518. * The depth-of-field PostProcess id in the pipeline
  50519. */
  50520. LensDepthOfFieldEffect: string;
  50521. private _scene;
  50522. private _depthTexture;
  50523. private _grainTexture;
  50524. private _chromaticAberrationPostProcess;
  50525. private _highlightsPostProcess;
  50526. private _depthOfFieldPostProcess;
  50527. private _edgeBlur;
  50528. private _grainAmount;
  50529. private _chromaticAberration;
  50530. private _distortion;
  50531. private _highlightsGain;
  50532. private _highlightsThreshold;
  50533. private _dofDistance;
  50534. private _dofAperture;
  50535. private _dofDarken;
  50536. private _dofPentagon;
  50537. private _blurNoise;
  50538. /**
  50539. * @constructor
  50540. *
  50541. * Effect parameters are as follow:
  50542. * {
  50543. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50544. * edge_blur: number; // from 0 to x (1 for realism)
  50545. * distortion: number; // from 0 to x (1 for realism)
  50546. * grain_amount: number; // from 0 to 1
  50547. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50548. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50549. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50550. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50551. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50552. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50553. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50554. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50555. * }
  50556. * Note: if an effect parameter is unset, effect is disabled
  50557. *
  50558. * @param name The rendering pipeline name
  50559. * @param parameters - An object containing all parameters (see above)
  50560. * @param scene The scene linked to this pipeline
  50561. * @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)
  50562. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50563. */
  50564. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50565. /**
  50566. * Sets the amount of blur at the edges
  50567. * @param amount blur amount
  50568. */
  50569. setEdgeBlur(amount: number): void;
  50570. /**
  50571. * Sets edge blur to 0
  50572. */
  50573. disableEdgeBlur(): void;
  50574. /**
  50575. * Sets the amout of grain
  50576. * @param amount Amount of grain
  50577. */
  50578. setGrainAmount(amount: number): void;
  50579. /**
  50580. * Set grain amount to 0
  50581. */
  50582. disableGrain(): void;
  50583. /**
  50584. * Sets the chromatic aberration amount
  50585. * @param amount amount of chromatic aberration
  50586. */
  50587. setChromaticAberration(amount: number): void;
  50588. /**
  50589. * Sets chromatic aberration amount to 0
  50590. */
  50591. disableChromaticAberration(): void;
  50592. /**
  50593. * Sets the EdgeDistortion amount
  50594. * @param amount amount of EdgeDistortion
  50595. */
  50596. setEdgeDistortion(amount: number): void;
  50597. /**
  50598. * Sets edge distortion to 0
  50599. */
  50600. disableEdgeDistortion(): void;
  50601. /**
  50602. * Sets the FocusDistance amount
  50603. * @param amount amount of FocusDistance
  50604. */
  50605. setFocusDistance(amount: number): void;
  50606. /**
  50607. * Disables depth of field
  50608. */
  50609. disableDepthOfField(): void;
  50610. /**
  50611. * Sets the Aperture amount
  50612. * @param amount amount of Aperture
  50613. */
  50614. setAperture(amount: number): void;
  50615. /**
  50616. * Sets the DarkenOutOfFocus amount
  50617. * @param amount amount of DarkenOutOfFocus
  50618. */
  50619. setDarkenOutOfFocus(amount: number): void;
  50620. /**
  50621. * Creates a pentagon bokeh effect
  50622. */
  50623. enablePentagonBokeh(): void;
  50624. /**
  50625. * Disables the pentagon bokeh effect
  50626. */
  50627. disablePentagonBokeh(): void;
  50628. /**
  50629. * Enables noise blur
  50630. */
  50631. enableNoiseBlur(): void;
  50632. /**
  50633. * Disables noise blur
  50634. */
  50635. disableNoiseBlur(): void;
  50636. /**
  50637. * Sets the HighlightsGain amount
  50638. * @param amount amount of HighlightsGain
  50639. */
  50640. setHighlightsGain(amount: number): void;
  50641. /**
  50642. * Sets the HighlightsThreshold amount
  50643. * @param amount amount of HighlightsThreshold
  50644. */
  50645. setHighlightsThreshold(amount: number): void;
  50646. /**
  50647. * Disables highlights
  50648. */
  50649. disableHighlights(): void;
  50650. /**
  50651. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50652. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50653. */
  50654. dispose(disableDepthRender?: boolean): void;
  50655. private _createChromaticAberrationPostProcess;
  50656. private _createHighlightsPostProcess;
  50657. private _createDepthOfFieldPostProcess;
  50658. private _createGrainTexture;
  50659. }
  50660. }
  50661. declare module BABYLON {
  50662. /** @hidden */
  50663. export var ssao2PixelShader: {
  50664. name: string;
  50665. shader: string;
  50666. };
  50667. }
  50668. declare module BABYLON {
  50669. /** @hidden */
  50670. export var ssaoCombinePixelShader: {
  50671. name: string;
  50672. shader: string;
  50673. };
  50674. }
  50675. declare module BABYLON {
  50676. /**
  50677. * Render pipeline to produce ssao effect
  50678. */
  50679. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50680. /**
  50681. * @ignore
  50682. * The PassPostProcess id in the pipeline that contains the original scene color
  50683. */
  50684. SSAOOriginalSceneColorEffect: string;
  50685. /**
  50686. * @ignore
  50687. * The SSAO PostProcess id in the pipeline
  50688. */
  50689. SSAORenderEffect: string;
  50690. /**
  50691. * @ignore
  50692. * The horizontal blur PostProcess id in the pipeline
  50693. */
  50694. SSAOBlurHRenderEffect: string;
  50695. /**
  50696. * @ignore
  50697. * The vertical blur PostProcess id in the pipeline
  50698. */
  50699. SSAOBlurVRenderEffect: string;
  50700. /**
  50701. * @ignore
  50702. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50703. */
  50704. SSAOCombineRenderEffect: string;
  50705. /**
  50706. * The output strength of the SSAO post-process. Default value is 1.0.
  50707. */
  50708. totalStrength: number;
  50709. /**
  50710. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50711. */
  50712. maxZ: number;
  50713. /**
  50714. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50715. */
  50716. minZAspect: number;
  50717. private _samples;
  50718. /**
  50719. * Number of samples used for the SSAO calculations. Default value is 8
  50720. */
  50721. samples: number;
  50722. private _textureSamples;
  50723. /**
  50724. * Number of samples to use for antialiasing
  50725. */
  50726. textureSamples: number;
  50727. /**
  50728. * Ratio object used for SSAO ratio and blur ratio
  50729. */
  50730. private _ratio;
  50731. /**
  50732. * Dynamically generated sphere sampler.
  50733. */
  50734. private _sampleSphere;
  50735. /**
  50736. * Blur filter offsets
  50737. */
  50738. private _samplerOffsets;
  50739. private _expensiveBlur;
  50740. /**
  50741. * If bilateral blur should be used
  50742. */
  50743. expensiveBlur: boolean;
  50744. /**
  50745. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50746. */
  50747. radius: number;
  50748. /**
  50749. * The base color of the SSAO post-process
  50750. * The final result is "base + ssao" between [0, 1]
  50751. */
  50752. base: number;
  50753. /**
  50754. * Support test.
  50755. */
  50756. static readonly IsSupported: boolean;
  50757. private _scene;
  50758. private _depthTexture;
  50759. private _normalTexture;
  50760. private _randomTexture;
  50761. private _originalColorPostProcess;
  50762. private _ssaoPostProcess;
  50763. private _blurHPostProcess;
  50764. private _blurVPostProcess;
  50765. private _ssaoCombinePostProcess;
  50766. private _firstUpdate;
  50767. /**
  50768. * @constructor
  50769. * @param name The rendering pipeline name
  50770. * @param scene The scene linked to this pipeline
  50771. * @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 }
  50772. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50773. */
  50774. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50775. /**
  50776. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50777. */
  50778. dispose(disableGeometryBufferRenderer?: boolean): void;
  50779. private _createBlurPostProcess;
  50780. /** @hidden */
  50781. _rebuild(): void;
  50782. private _bits;
  50783. private _radicalInverse_VdC;
  50784. private _hammersley;
  50785. private _hemisphereSample_uniform;
  50786. private _generateHemisphere;
  50787. private _createSSAOPostProcess;
  50788. private _createSSAOCombinePostProcess;
  50789. private _createRandomTexture;
  50790. /**
  50791. * Serialize the rendering pipeline (Used when exporting)
  50792. * @returns the serialized object
  50793. */
  50794. serialize(): any;
  50795. /**
  50796. * Parse the serialized pipeline
  50797. * @param source Source pipeline.
  50798. * @param scene The scene to load the pipeline to.
  50799. * @param rootUrl The URL of the serialized pipeline.
  50800. * @returns An instantiated pipeline from the serialized object.
  50801. */
  50802. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50803. }
  50804. }
  50805. declare module BABYLON {
  50806. /** @hidden */
  50807. export var ssaoPixelShader: {
  50808. name: string;
  50809. shader: string;
  50810. };
  50811. }
  50812. declare module BABYLON {
  50813. /**
  50814. * Render pipeline to produce ssao effect
  50815. */
  50816. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50817. /**
  50818. * @ignore
  50819. * The PassPostProcess id in the pipeline that contains the original scene color
  50820. */
  50821. SSAOOriginalSceneColorEffect: string;
  50822. /**
  50823. * @ignore
  50824. * The SSAO PostProcess id in the pipeline
  50825. */
  50826. SSAORenderEffect: string;
  50827. /**
  50828. * @ignore
  50829. * The horizontal blur PostProcess id in the pipeline
  50830. */
  50831. SSAOBlurHRenderEffect: string;
  50832. /**
  50833. * @ignore
  50834. * The vertical blur PostProcess id in the pipeline
  50835. */
  50836. SSAOBlurVRenderEffect: string;
  50837. /**
  50838. * @ignore
  50839. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50840. */
  50841. SSAOCombineRenderEffect: string;
  50842. /**
  50843. * The output strength of the SSAO post-process. Default value is 1.0.
  50844. */
  50845. totalStrength: number;
  50846. /**
  50847. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50848. */
  50849. radius: number;
  50850. /**
  50851. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50852. * Must not be equal to fallOff and superior to fallOff.
  50853. * Default value is 0.975
  50854. */
  50855. area: number;
  50856. /**
  50857. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50858. * Must not be equal to area and inferior to area.
  50859. * Default value is 0.0
  50860. */
  50861. fallOff: number;
  50862. /**
  50863. * The base color of the SSAO post-process
  50864. * The final result is "base + ssao" between [0, 1]
  50865. */
  50866. base: number;
  50867. private _scene;
  50868. private _depthTexture;
  50869. private _randomTexture;
  50870. private _originalColorPostProcess;
  50871. private _ssaoPostProcess;
  50872. private _blurHPostProcess;
  50873. private _blurVPostProcess;
  50874. private _ssaoCombinePostProcess;
  50875. private _firstUpdate;
  50876. /**
  50877. * @constructor
  50878. * @param name - The rendering pipeline name
  50879. * @param scene - The scene linked to this pipeline
  50880. * @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 }
  50881. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50882. */
  50883. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50884. /**
  50885. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50886. */
  50887. dispose(disableDepthRender?: boolean): void;
  50888. private _createBlurPostProcess;
  50889. /** @hidden */
  50890. _rebuild(): void;
  50891. private _createSSAOPostProcess;
  50892. private _createSSAOCombinePostProcess;
  50893. private _createRandomTexture;
  50894. }
  50895. }
  50896. declare module BABYLON {
  50897. /** @hidden */
  50898. export var standardPixelShader: {
  50899. name: string;
  50900. shader: string;
  50901. };
  50902. }
  50903. declare module BABYLON {
  50904. /**
  50905. * Standard rendering pipeline
  50906. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50907. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50908. */
  50909. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50910. /**
  50911. * Public members
  50912. */
  50913. /**
  50914. * Post-process which contains the original scene color before the pipeline applies all the effects
  50915. */
  50916. originalPostProcess: Nullable<PostProcess>;
  50917. /**
  50918. * Post-process used to down scale an image x4
  50919. */
  50920. downSampleX4PostProcess: Nullable<PostProcess>;
  50921. /**
  50922. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50923. */
  50924. brightPassPostProcess: Nullable<PostProcess>;
  50925. /**
  50926. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50927. */
  50928. blurHPostProcesses: PostProcess[];
  50929. /**
  50930. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50931. */
  50932. blurVPostProcesses: PostProcess[];
  50933. /**
  50934. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50935. */
  50936. textureAdderPostProcess: Nullable<PostProcess>;
  50937. /**
  50938. * Post-process used to create volumetric lighting effect
  50939. */
  50940. volumetricLightPostProcess: Nullable<PostProcess>;
  50941. /**
  50942. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50943. */
  50944. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50945. /**
  50946. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50947. */
  50948. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50949. /**
  50950. * Post-process used to merge the volumetric light effect and the real scene color
  50951. */
  50952. volumetricLightMergePostProces: Nullable<PostProcess>;
  50953. /**
  50954. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50955. */
  50956. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50957. /**
  50958. * Base post-process used to calculate the average luminance of the final image for HDR
  50959. */
  50960. luminancePostProcess: Nullable<PostProcess>;
  50961. /**
  50962. * Post-processes used to create down sample post-processes in order to get
  50963. * the average luminance of the final image for HDR
  50964. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50965. */
  50966. luminanceDownSamplePostProcesses: PostProcess[];
  50967. /**
  50968. * Post-process used to create a HDR effect (light adaptation)
  50969. */
  50970. hdrPostProcess: Nullable<PostProcess>;
  50971. /**
  50972. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50973. */
  50974. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50975. /**
  50976. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50977. */
  50978. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50979. /**
  50980. * Post-process used to merge the final HDR post-process and the real scene color
  50981. */
  50982. hdrFinalPostProcess: Nullable<PostProcess>;
  50983. /**
  50984. * Post-process used to create a lens flare effect
  50985. */
  50986. lensFlarePostProcess: Nullable<PostProcess>;
  50987. /**
  50988. * Post-process that merges the result of the lens flare post-process and the real scene color
  50989. */
  50990. lensFlareComposePostProcess: Nullable<PostProcess>;
  50991. /**
  50992. * Post-process used to create a motion blur effect
  50993. */
  50994. motionBlurPostProcess: Nullable<PostProcess>;
  50995. /**
  50996. * Post-process used to create a depth of field effect
  50997. */
  50998. depthOfFieldPostProcess: Nullable<PostProcess>;
  50999. /**
  51000. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  51001. */
  51002. fxaaPostProcess: Nullable<FxaaPostProcess>;
  51003. /**
  51004. * Represents the brightness threshold in order to configure the illuminated surfaces
  51005. */
  51006. brightThreshold: number;
  51007. /**
  51008. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  51009. */
  51010. blurWidth: number;
  51011. /**
  51012. * Sets if the blur for highlighted surfaces must be only horizontal
  51013. */
  51014. horizontalBlur: boolean;
  51015. /**
  51016. * Sets the overall exposure used by the pipeline
  51017. */
  51018. exposure: number;
  51019. /**
  51020. * Texture used typically to simulate "dirty" on camera lens
  51021. */
  51022. lensTexture: Nullable<Texture>;
  51023. /**
  51024. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  51025. */
  51026. volumetricLightCoefficient: number;
  51027. /**
  51028. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  51029. */
  51030. volumetricLightPower: number;
  51031. /**
  51032. * Used the set the blur intensity to smooth the volumetric lights
  51033. */
  51034. volumetricLightBlurScale: number;
  51035. /**
  51036. * Light (spot or directional) used to generate the volumetric lights rays
  51037. * The source light must have a shadow generate so the pipeline can get its
  51038. * depth map
  51039. */
  51040. sourceLight: Nullable<SpotLight | DirectionalLight>;
  51041. /**
  51042. * For eye adaptation, represents the minimum luminance the eye can see
  51043. */
  51044. hdrMinimumLuminance: number;
  51045. /**
  51046. * For eye adaptation, represents the decrease luminance speed
  51047. */
  51048. hdrDecreaseRate: number;
  51049. /**
  51050. * For eye adaptation, represents the increase luminance speed
  51051. */
  51052. hdrIncreaseRate: number;
  51053. /**
  51054. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  51055. */
  51056. lensColorTexture: Nullable<Texture>;
  51057. /**
  51058. * The overall strengh for the lens flare effect
  51059. */
  51060. lensFlareStrength: number;
  51061. /**
  51062. * Dispersion coefficient for lens flare ghosts
  51063. */
  51064. lensFlareGhostDispersal: number;
  51065. /**
  51066. * Main lens flare halo width
  51067. */
  51068. lensFlareHaloWidth: number;
  51069. /**
  51070. * Based on the lens distortion effect, defines how much the lens flare result
  51071. * is distorted
  51072. */
  51073. lensFlareDistortionStrength: number;
  51074. /**
  51075. * Lens star texture must be used to simulate rays on the flares and is available
  51076. * in the documentation
  51077. */
  51078. lensStarTexture: Nullable<Texture>;
  51079. /**
  51080. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  51081. * flare effect by taking account of the dirt texture
  51082. */
  51083. lensFlareDirtTexture: Nullable<Texture>;
  51084. /**
  51085. * Represents the focal length for the depth of field effect
  51086. */
  51087. depthOfFieldDistance: number;
  51088. /**
  51089. * Represents the blur intensity for the blurred part of the depth of field effect
  51090. */
  51091. depthOfFieldBlurWidth: number;
  51092. /**
  51093. * For motion blur, defines how much the image is blurred by the movement
  51094. */
  51095. motionStrength: number;
  51096. /**
  51097. * List of animations for the pipeline (IAnimatable implementation)
  51098. */
  51099. animations: Animation[];
  51100. /**
  51101. * Private members
  51102. */
  51103. private _scene;
  51104. private _currentDepthOfFieldSource;
  51105. private _basePostProcess;
  51106. private _hdrCurrentLuminance;
  51107. private _floatTextureType;
  51108. private _ratio;
  51109. private _bloomEnabled;
  51110. private _depthOfFieldEnabled;
  51111. private _vlsEnabled;
  51112. private _lensFlareEnabled;
  51113. private _hdrEnabled;
  51114. private _motionBlurEnabled;
  51115. private _fxaaEnabled;
  51116. private _motionBlurSamples;
  51117. private _volumetricLightStepsCount;
  51118. private _samples;
  51119. /**
  51120. * @ignore
  51121. * Specifies if the bloom pipeline is enabled
  51122. */
  51123. BloomEnabled: boolean;
  51124. /**
  51125. * @ignore
  51126. * Specifies if the depth of field pipeline is enabed
  51127. */
  51128. DepthOfFieldEnabled: boolean;
  51129. /**
  51130. * @ignore
  51131. * Specifies if the lens flare pipeline is enabed
  51132. */
  51133. LensFlareEnabled: boolean;
  51134. /**
  51135. * @ignore
  51136. * Specifies if the HDR pipeline is enabled
  51137. */
  51138. HDREnabled: boolean;
  51139. /**
  51140. * @ignore
  51141. * Specifies if the volumetric lights scattering effect is enabled
  51142. */
  51143. VLSEnabled: boolean;
  51144. /**
  51145. * @ignore
  51146. * Specifies if the motion blur effect is enabled
  51147. */
  51148. MotionBlurEnabled: boolean;
  51149. /**
  51150. * Specifies if anti-aliasing is enabled
  51151. */
  51152. fxaaEnabled: boolean;
  51153. /**
  51154. * Specifies the number of steps used to calculate the volumetric lights
  51155. * Typically in interval [50, 200]
  51156. */
  51157. volumetricLightStepsCount: number;
  51158. /**
  51159. * Specifies the number of samples used for the motion blur effect
  51160. * Typically in interval [16, 64]
  51161. */
  51162. motionBlurSamples: number;
  51163. /**
  51164. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  51165. */
  51166. samples: number;
  51167. /**
  51168. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51169. * @constructor
  51170. * @param name The rendering pipeline name
  51171. * @param scene The scene linked to this pipeline
  51172. * @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)
  51173. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  51174. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51175. */
  51176. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  51177. private _buildPipeline;
  51178. private _createDownSampleX4PostProcess;
  51179. private _createBrightPassPostProcess;
  51180. private _createBlurPostProcesses;
  51181. private _createTextureAdderPostProcess;
  51182. private _createVolumetricLightPostProcess;
  51183. private _createLuminancePostProcesses;
  51184. private _createHdrPostProcess;
  51185. private _createLensFlarePostProcess;
  51186. private _createDepthOfFieldPostProcess;
  51187. private _createMotionBlurPostProcess;
  51188. private _getDepthTexture;
  51189. private _disposePostProcesses;
  51190. /**
  51191. * Dispose of the pipeline and stop all post processes
  51192. */
  51193. dispose(): void;
  51194. /**
  51195. * Serialize the rendering pipeline (Used when exporting)
  51196. * @returns the serialized object
  51197. */
  51198. serialize(): any;
  51199. /**
  51200. * Parse the serialized pipeline
  51201. * @param source Source pipeline.
  51202. * @param scene The scene to load the pipeline to.
  51203. * @param rootUrl The URL of the serialized pipeline.
  51204. * @returns An instantiated pipeline from the serialized object.
  51205. */
  51206. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  51207. /**
  51208. * Luminance steps
  51209. */
  51210. static LuminanceSteps: number;
  51211. }
  51212. }
  51213. declare module BABYLON {
  51214. /**
  51215. * PostProcessRenderPipelineManager class
  51216. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51217. */
  51218. export class PostProcessRenderPipelineManager {
  51219. private _renderPipelines;
  51220. /**
  51221. * Initializes a PostProcessRenderPipelineManager
  51222. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51223. */
  51224. constructor();
  51225. /**
  51226. * Adds a pipeline to the manager
  51227. * @param renderPipeline The pipeline to add
  51228. */
  51229. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  51230. /**
  51231. * Attaches a camera to the pipeline
  51232. * @param renderPipelineName The name of the pipeline to attach to
  51233. * @param cameras the camera to attach
  51234. * @param unique if the camera can be attached multiple times to the pipeline
  51235. */
  51236. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  51237. /**
  51238. * Detaches a camera from the pipeline
  51239. * @param renderPipelineName The name of the pipeline to detach from
  51240. * @param cameras the camera to detach
  51241. */
  51242. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  51243. /**
  51244. * Enables an effect by name on a pipeline
  51245. * @param renderPipelineName the name of the pipeline to enable the effect in
  51246. * @param renderEffectName the name of the effect to enable
  51247. * @param cameras the cameras that the effect should be enabled on
  51248. */
  51249. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  51250. /**
  51251. * Disables an effect by name on a pipeline
  51252. * @param renderPipelineName the name of the pipeline to disable the effect in
  51253. * @param renderEffectName the name of the effect to disable
  51254. * @param cameras the cameras that the effect should be disabled on
  51255. */
  51256. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  51257. /**
  51258. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  51259. */
  51260. update(): void;
  51261. /** @hidden */
  51262. _rebuild(): void;
  51263. /**
  51264. * Disposes of the manager and pipelines
  51265. */
  51266. dispose(): void;
  51267. }
  51268. }
  51269. declare module BABYLON {
  51270. interface Scene {
  51271. /** @hidden (Backing field) */
  51272. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  51273. /**
  51274. * Gets the postprocess render pipeline manager
  51275. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51276. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  51277. */
  51278. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  51279. }
  51280. /**
  51281. * Defines the Render Pipeline scene component responsible to rendering pipelines
  51282. */
  51283. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  51284. /**
  51285. * The component name helpfull to identify the component in the list of scene components.
  51286. */
  51287. readonly name: string;
  51288. /**
  51289. * The scene the component belongs to.
  51290. */
  51291. scene: Scene;
  51292. /**
  51293. * Creates a new instance of the component for the given scene
  51294. * @param scene Defines the scene to register the component in
  51295. */
  51296. constructor(scene: Scene);
  51297. /**
  51298. * Registers the component in a given scene
  51299. */
  51300. register(): void;
  51301. /**
  51302. * Rebuilds the elements related to this component in case of
  51303. * context lost for instance.
  51304. */
  51305. rebuild(): void;
  51306. /**
  51307. * Disposes the component and the associated ressources
  51308. */
  51309. dispose(): void;
  51310. private _gatherRenderTargets;
  51311. }
  51312. }
  51313. declare module BABYLON {
  51314. /** @hidden */
  51315. export var tonemapPixelShader: {
  51316. name: string;
  51317. shader: string;
  51318. };
  51319. }
  51320. declare module BABYLON {
  51321. /** Defines operator used for tonemapping */
  51322. export enum TonemappingOperator {
  51323. /** Hable */
  51324. Hable = 0,
  51325. /** Reinhard */
  51326. Reinhard = 1,
  51327. /** HejiDawson */
  51328. HejiDawson = 2,
  51329. /** Photographic */
  51330. Photographic = 3
  51331. }
  51332. /**
  51333. * Defines a post process to apply tone mapping
  51334. */
  51335. export class TonemapPostProcess extends PostProcess {
  51336. private _operator;
  51337. /** Defines the required exposure adjustement */
  51338. exposureAdjustment: number;
  51339. /**
  51340. * Creates a new TonemapPostProcess
  51341. * @param name defines the name of the postprocess
  51342. * @param _operator defines the operator to use
  51343. * @param exposureAdjustment defines the required exposure adjustement
  51344. * @param camera defines the camera to use (can be null)
  51345. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  51346. * @param engine defines the hosting engine (can be ignore if camera is set)
  51347. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51348. */
  51349. constructor(name: string, _operator: TonemappingOperator,
  51350. /** Defines the required exposure adjustement */
  51351. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  51352. }
  51353. }
  51354. declare module BABYLON {
  51355. /** @hidden */
  51356. export var depthVertexShader: {
  51357. name: string;
  51358. shader: string;
  51359. };
  51360. }
  51361. declare module BABYLON {
  51362. /** @hidden */
  51363. export var volumetricLightScatteringPixelShader: {
  51364. name: string;
  51365. shader: string;
  51366. };
  51367. }
  51368. declare module BABYLON {
  51369. /** @hidden */
  51370. export var volumetricLightScatteringPassPixelShader: {
  51371. name: string;
  51372. shader: string;
  51373. };
  51374. }
  51375. declare module BABYLON {
  51376. /**
  51377. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  51378. */
  51379. export class VolumetricLightScatteringPostProcess extends PostProcess {
  51380. private _volumetricLightScatteringPass;
  51381. private _volumetricLightScatteringRTT;
  51382. private _viewPort;
  51383. private _screenCoordinates;
  51384. private _cachedDefines;
  51385. /**
  51386. * If not undefined, the mesh position is computed from the attached node position
  51387. */
  51388. attachedNode: {
  51389. position: Vector3;
  51390. };
  51391. /**
  51392. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  51393. */
  51394. customMeshPosition: Vector3;
  51395. /**
  51396. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  51397. */
  51398. useCustomMeshPosition: boolean;
  51399. /**
  51400. * If the post-process should inverse the light scattering direction
  51401. */
  51402. invert: boolean;
  51403. /**
  51404. * The internal mesh used by the post-process
  51405. */
  51406. mesh: Mesh;
  51407. /**
  51408. * @hidden
  51409. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  51410. */
  51411. useDiffuseColor: boolean;
  51412. /**
  51413. * Array containing the excluded meshes not rendered in the internal pass
  51414. */
  51415. excludedMeshes: AbstractMesh[];
  51416. /**
  51417. * Controls the overall intensity of the post-process
  51418. */
  51419. exposure: number;
  51420. /**
  51421. * Dissipates each sample's contribution in range [0, 1]
  51422. */
  51423. decay: number;
  51424. /**
  51425. * Controls the overall intensity of each sample
  51426. */
  51427. weight: number;
  51428. /**
  51429. * Controls the density of each sample
  51430. */
  51431. density: number;
  51432. /**
  51433. * @constructor
  51434. * @param name The post-process name
  51435. * @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)
  51436. * @param camera The camera that the post-process will be attached to
  51437. * @param mesh The mesh used to create the light scattering
  51438. * @param samples The post-process quality, default 100
  51439. * @param samplingModeThe post-process filtering mode
  51440. * @param engine The babylon engine
  51441. * @param reusable If the post-process is reusable
  51442. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  51443. */
  51444. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  51445. /**
  51446. * Returns the string "VolumetricLightScatteringPostProcess"
  51447. * @returns "VolumetricLightScatteringPostProcess"
  51448. */
  51449. getClassName(): string;
  51450. private _isReady;
  51451. /**
  51452. * Sets the new light position for light scattering effect
  51453. * @param position The new custom light position
  51454. */
  51455. setCustomMeshPosition(position: Vector3): void;
  51456. /**
  51457. * Returns the light position for light scattering effect
  51458. * @return Vector3 The custom light position
  51459. */
  51460. getCustomMeshPosition(): Vector3;
  51461. /**
  51462. * Disposes the internal assets and detaches the post-process from the camera
  51463. */
  51464. dispose(camera: Camera): void;
  51465. /**
  51466. * Returns the render target texture used by the post-process
  51467. * @return the render target texture used by the post-process
  51468. */
  51469. getPass(): RenderTargetTexture;
  51470. private _meshExcluded;
  51471. private _createPass;
  51472. private _updateMeshScreenCoordinates;
  51473. /**
  51474. * Creates a default mesh for the Volumeric Light Scattering post-process
  51475. * @param name The mesh name
  51476. * @param scene The scene where to create the mesh
  51477. * @return the default mesh
  51478. */
  51479. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  51480. }
  51481. }
  51482. declare module BABYLON {
  51483. interface Scene {
  51484. /** @hidden (Backing field) */
  51485. _boundingBoxRenderer: BoundingBoxRenderer;
  51486. /** @hidden (Backing field) */
  51487. _forceShowBoundingBoxes: boolean;
  51488. /**
  51489. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  51490. */
  51491. forceShowBoundingBoxes: boolean;
  51492. /**
  51493. * Gets the bounding box renderer associated with the scene
  51494. * @returns a BoundingBoxRenderer
  51495. */
  51496. getBoundingBoxRenderer(): BoundingBoxRenderer;
  51497. }
  51498. interface AbstractMesh {
  51499. /** @hidden (Backing field) */
  51500. _showBoundingBox: boolean;
  51501. /**
  51502. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  51503. */
  51504. showBoundingBox: boolean;
  51505. }
  51506. /**
  51507. * Component responsible of rendering the bounding box of the meshes in a scene.
  51508. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  51509. */
  51510. export class BoundingBoxRenderer implements ISceneComponent {
  51511. /**
  51512. * The component name helpfull to identify the component in the list of scene components.
  51513. */
  51514. readonly name: string;
  51515. /**
  51516. * The scene the component belongs to.
  51517. */
  51518. scene: Scene;
  51519. /**
  51520. * Color of the bounding box lines placed in front of an object
  51521. */
  51522. frontColor: Color3;
  51523. /**
  51524. * Color of the bounding box lines placed behind an object
  51525. */
  51526. backColor: Color3;
  51527. /**
  51528. * Defines if the renderer should show the back lines or not
  51529. */
  51530. showBackLines: boolean;
  51531. /**
  51532. * @hidden
  51533. */
  51534. renderList: SmartArray<BoundingBox>;
  51535. private _colorShader;
  51536. private _vertexBuffers;
  51537. private _indexBuffer;
  51538. /**
  51539. * Instantiates a new bounding box renderer in a scene.
  51540. * @param scene the scene the renderer renders in
  51541. */
  51542. constructor(scene: Scene);
  51543. /**
  51544. * Registers the component in a given scene
  51545. */
  51546. register(): void;
  51547. private _evaluateSubMesh;
  51548. private _activeMesh;
  51549. private _prepareRessources;
  51550. private _createIndexBuffer;
  51551. /**
  51552. * Rebuilds the elements related to this component in case of
  51553. * context lost for instance.
  51554. */
  51555. rebuild(): void;
  51556. /**
  51557. * @hidden
  51558. */
  51559. reset(): void;
  51560. /**
  51561. * Render the bounding boxes of a specific rendering group
  51562. * @param renderingGroupId defines the rendering group to render
  51563. */
  51564. render(renderingGroupId: number): void;
  51565. /**
  51566. * In case of occlusion queries, we can render the occlusion bounding box through this method
  51567. * @param mesh Define the mesh to render the occlusion bounding box for
  51568. */
  51569. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  51570. /**
  51571. * Dispose and release the resources attached to this renderer.
  51572. */
  51573. dispose(): void;
  51574. }
  51575. }
  51576. declare module BABYLON {
  51577. /** @hidden */
  51578. export var depthPixelShader: {
  51579. name: string;
  51580. shader: string;
  51581. };
  51582. }
  51583. declare module BABYLON {
  51584. /**
  51585. * This represents a depth renderer in Babylon.
  51586. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  51587. */
  51588. export class DepthRenderer {
  51589. private _scene;
  51590. private _depthMap;
  51591. private _effect;
  51592. private _cachedDefines;
  51593. private _camera;
  51594. /**
  51595. * Specifiess that the depth renderer will only be used within
  51596. * the camera it is created for.
  51597. * This can help forcing its rendering during the camera processing.
  51598. */
  51599. useOnlyInActiveCamera: boolean;
  51600. /** @hidden */
  51601. static _SceneComponentInitialization: (scene: Scene) => void;
  51602. /**
  51603. * Instantiates a depth renderer
  51604. * @param scene The scene the renderer belongs to
  51605. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  51606. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  51607. */
  51608. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  51609. /**
  51610. * Creates the depth rendering effect and checks if the effect is ready.
  51611. * @param subMesh The submesh to be used to render the depth map of
  51612. * @param useInstances If multiple world instances should be used
  51613. * @returns if the depth renderer is ready to render the depth map
  51614. */
  51615. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51616. /**
  51617. * Gets the texture which the depth map will be written to.
  51618. * @returns The depth map texture
  51619. */
  51620. getDepthMap(): RenderTargetTexture;
  51621. /**
  51622. * Disposes of the depth renderer.
  51623. */
  51624. dispose(): void;
  51625. }
  51626. }
  51627. declare module BABYLON {
  51628. interface Scene {
  51629. /** @hidden (Backing field) */
  51630. _depthRenderer: {
  51631. [id: string]: DepthRenderer;
  51632. };
  51633. /**
  51634. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  51635. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  51636. * @returns the created depth renderer
  51637. */
  51638. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  51639. /**
  51640. * Disables a depth renderer for a given camera
  51641. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  51642. */
  51643. disableDepthRenderer(camera?: Nullable<Camera>): void;
  51644. }
  51645. /**
  51646. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  51647. * in several rendering techniques.
  51648. */
  51649. export class DepthRendererSceneComponent implements ISceneComponent {
  51650. /**
  51651. * The component name helpfull to identify the component in the list of scene components.
  51652. */
  51653. readonly name: string;
  51654. /**
  51655. * The scene the component belongs to.
  51656. */
  51657. scene: Scene;
  51658. /**
  51659. * Creates a new instance of the component for the given scene
  51660. * @param scene Defines the scene to register the component in
  51661. */
  51662. constructor(scene: Scene);
  51663. /**
  51664. * Registers the component in a given scene
  51665. */
  51666. register(): void;
  51667. /**
  51668. * Rebuilds the elements related to this component in case of
  51669. * context lost for instance.
  51670. */
  51671. rebuild(): void;
  51672. /**
  51673. * Disposes the component and the associated ressources
  51674. */
  51675. dispose(): void;
  51676. private _gatherRenderTargets;
  51677. private _gatherActiveCameraRenderTargets;
  51678. }
  51679. }
  51680. declare module BABYLON {
  51681. interface Scene {
  51682. /** @hidden (Backing field) */
  51683. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51684. /**
  51685. * Gets or Sets the current geometry buffer associated to the scene.
  51686. */
  51687. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51688. /**
  51689. * Enables a GeometryBufferRender and associates it with the scene
  51690. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  51691. * @returns the GeometryBufferRenderer
  51692. */
  51693. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  51694. /**
  51695. * Disables the GeometryBufferRender associated with the scene
  51696. */
  51697. disableGeometryBufferRenderer(): void;
  51698. }
  51699. /**
  51700. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  51701. * in several rendering techniques.
  51702. */
  51703. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  51704. /**
  51705. * The component name helpful to identify the component in the list of scene components.
  51706. */
  51707. readonly name: string;
  51708. /**
  51709. * The scene the component belongs to.
  51710. */
  51711. scene: Scene;
  51712. /**
  51713. * Creates a new instance of the component for the given scene
  51714. * @param scene Defines the scene to register the component in
  51715. */
  51716. constructor(scene: Scene);
  51717. /**
  51718. * Registers the component in a given scene
  51719. */
  51720. register(): void;
  51721. /**
  51722. * Rebuilds the elements related to this component in case of
  51723. * context lost for instance.
  51724. */
  51725. rebuild(): void;
  51726. /**
  51727. * Disposes the component and the associated ressources
  51728. */
  51729. dispose(): void;
  51730. private _gatherRenderTargets;
  51731. }
  51732. }
  51733. declare module BABYLON {
  51734. /** @hidden */
  51735. export var outlinePixelShader: {
  51736. name: string;
  51737. shader: string;
  51738. };
  51739. }
  51740. declare module BABYLON {
  51741. /** @hidden */
  51742. export var outlineVertexShader: {
  51743. name: string;
  51744. shader: string;
  51745. };
  51746. }
  51747. declare module BABYLON {
  51748. interface Scene {
  51749. /** @hidden */
  51750. _outlineRenderer: OutlineRenderer;
  51751. /**
  51752. * Gets the outline renderer associated with the scene
  51753. * @returns a OutlineRenderer
  51754. */
  51755. getOutlineRenderer(): OutlineRenderer;
  51756. }
  51757. interface AbstractMesh {
  51758. /** @hidden (Backing field) */
  51759. _renderOutline: boolean;
  51760. /**
  51761. * Gets or sets a boolean indicating if the outline must be rendered as well
  51762. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  51763. */
  51764. renderOutline: boolean;
  51765. /** @hidden (Backing field) */
  51766. _renderOverlay: boolean;
  51767. /**
  51768. * Gets or sets a boolean indicating if the overlay must be rendered as well
  51769. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  51770. */
  51771. renderOverlay: boolean;
  51772. }
  51773. /**
  51774. * This class is responsible to draw bothe outline/overlay of meshes.
  51775. * It should not be used directly but through the available method on mesh.
  51776. */
  51777. export class OutlineRenderer implements ISceneComponent {
  51778. /**
  51779. * The name of the component. Each component must have a unique name.
  51780. */
  51781. name: string;
  51782. /**
  51783. * The scene the component belongs to.
  51784. */
  51785. scene: Scene;
  51786. /**
  51787. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  51788. */
  51789. zOffset: number;
  51790. private _engine;
  51791. private _effect;
  51792. private _cachedDefines;
  51793. private _savedDepthWrite;
  51794. /**
  51795. * Instantiates a new outline renderer. (There could be only one per scene).
  51796. * @param scene Defines the scene it belongs to
  51797. */
  51798. constructor(scene: Scene);
  51799. /**
  51800. * Register the component to one instance of a scene.
  51801. */
  51802. register(): void;
  51803. /**
  51804. * Rebuilds the elements related to this component in case of
  51805. * context lost for instance.
  51806. */
  51807. rebuild(): void;
  51808. /**
  51809. * Disposes the component and the associated ressources.
  51810. */
  51811. dispose(): void;
  51812. /**
  51813. * Renders the outline in the canvas.
  51814. * @param subMesh Defines the sumesh to render
  51815. * @param batch Defines the batch of meshes in case of instances
  51816. * @param useOverlay Defines if the rendering is for the overlay or the outline
  51817. */
  51818. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  51819. /**
  51820. * Returns whether or not the outline renderer is ready for a given submesh.
  51821. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  51822. * @param subMesh Defines the submesh to check readyness for
  51823. * @param useInstances Defines wheter wee are trying to render instances or not
  51824. * @returns true if ready otherwise false
  51825. */
  51826. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51827. private _beforeRenderingMesh;
  51828. private _afterRenderingMesh;
  51829. }
  51830. }
  51831. declare module BABYLON {
  51832. /**
  51833. * Defines the list of states available for a task inside a AssetsManager
  51834. */
  51835. export enum AssetTaskState {
  51836. /**
  51837. * Initialization
  51838. */
  51839. INIT = 0,
  51840. /**
  51841. * Running
  51842. */
  51843. RUNNING = 1,
  51844. /**
  51845. * Done
  51846. */
  51847. DONE = 2,
  51848. /**
  51849. * Error
  51850. */
  51851. ERROR = 3
  51852. }
  51853. /**
  51854. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  51855. */
  51856. export abstract class AbstractAssetTask {
  51857. /**
  51858. * Task name
  51859. */ name: string;
  51860. /**
  51861. * Callback called when the task is successful
  51862. */
  51863. onSuccess: (task: any) => void;
  51864. /**
  51865. * Callback called when the task is not successful
  51866. */
  51867. onError: (task: any, message?: string, exception?: any) => void;
  51868. /**
  51869. * Creates a new AssetsManager
  51870. * @param name defines the name of the task
  51871. */
  51872. constructor(
  51873. /**
  51874. * Task name
  51875. */ name: string);
  51876. private _isCompleted;
  51877. private _taskState;
  51878. private _errorObject;
  51879. /**
  51880. * Get if the task is completed
  51881. */
  51882. readonly isCompleted: boolean;
  51883. /**
  51884. * Gets the current state of the task
  51885. */
  51886. readonly taskState: AssetTaskState;
  51887. /**
  51888. * Gets the current error object (if task is in error)
  51889. */
  51890. readonly errorObject: {
  51891. message?: string;
  51892. exception?: any;
  51893. };
  51894. /**
  51895. * Internal only
  51896. * @hidden
  51897. */
  51898. _setErrorObject(message?: string, exception?: any): void;
  51899. /**
  51900. * Execute the current task
  51901. * @param scene defines the scene where you want your assets to be loaded
  51902. * @param onSuccess is a callback called when the task is successfully executed
  51903. * @param onError is a callback called if an error occurs
  51904. */
  51905. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51906. /**
  51907. * Execute the current task
  51908. * @param scene defines the scene where you want your assets to be loaded
  51909. * @param onSuccess is a callback called when the task is successfully executed
  51910. * @param onError is a callback called if an error occurs
  51911. */
  51912. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51913. /**
  51914. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  51915. * This can be used with failed tasks that have the reason for failure fixed.
  51916. */
  51917. reset(): void;
  51918. private onErrorCallback;
  51919. private onDoneCallback;
  51920. }
  51921. /**
  51922. * Define the interface used by progress events raised during assets loading
  51923. */
  51924. export interface IAssetsProgressEvent {
  51925. /**
  51926. * Defines the number of remaining tasks to process
  51927. */
  51928. remainingCount: number;
  51929. /**
  51930. * Defines the total number of tasks
  51931. */
  51932. totalCount: number;
  51933. /**
  51934. * Defines the task that was just processed
  51935. */
  51936. task: AbstractAssetTask;
  51937. }
  51938. /**
  51939. * Class used to share progress information about assets loading
  51940. */
  51941. export class AssetsProgressEvent implements IAssetsProgressEvent {
  51942. /**
  51943. * Defines the number of remaining tasks to process
  51944. */
  51945. remainingCount: number;
  51946. /**
  51947. * Defines the total number of tasks
  51948. */
  51949. totalCount: number;
  51950. /**
  51951. * Defines the task that was just processed
  51952. */
  51953. task: AbstractAssetTask;
  51954. /**
  51955. * Creates a AssetsProgressEvent
  51956. * @param remainingCount defines the number of remaining tasks to process
  51957. * @param totalCount defines the total number of tasks
  51958. * @param task defines the task that was just processed
  51959. */
  51960. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  51961. }
  51962. /**
  51963. * Define a task used by AssetsManager to load meshes
  51964. */
  51965. export class MeshAssetTask extends AbstractAssetTask {
  51966. /**
  51967. * Defines the name of the task
  51968. */
  51969. name: string;
  51970. /**
  51971. * Defines the list of mesh's names you want to load
  51972. */
  51973. meshesNames: any;
  51974. /**
  51975. * Defines the root url to use as a base to load your meshes and associated resources
  51976. */
  51977. rootUrl: string;
  51978. /**
  51979. * Defines the filename of the scene to load from
  51980. */
  51981. sceneFilename: string;
  51982. /**
  51983. * Gets the list of loaded meshes
  51984. */
  51985. loadedMeshes: Array<AbstractMesh>;
  51986. /**
  51987. * Gets the list of loaded particle systems
  51988. */
  51989. loadedParticleSystems: Array<IParticleSystem>;
  51990. /**
  51991. * Gets the list of loaded skeletons
  51992. */
  51993. loadedSkeletons: Array<Skeleton>;
  51994. /**
  51995. * Gets the list of loaded animation groups
  51996. */
  51997. loadedAnimationGroups: Array<AnimationGroup>;
  51998. /**
  51999. * Callback called when the task is successful
  52000. */
  52001. onSuccess: (task: MeshAssetTask) => void;
  52002. /**
  52003. * Callback called when the task is successful
  52004. */
  52005. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  52006. /**
  52007. * Creates a new MeshAssetTask
  52008. * @param name defines the name of the task
  52009. * @param meshesNames defines the list of mesh's names you want to load
  52010. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  52011. * @param sceneFilename defines the filename of the scene to load from
  52012. */
  52013. constructor(
  52014. /**
  52015. * Defines the name of the task
  52016. */
  52017. name: string,
  52018. /**
  52019. * Defines the list of mesh's names you want to load
  52020. */
  52021. meshesNames: any,
  52022. /**
  52023. * Defines the root url to use as a base to load your meshes and associated resources
  52024. */
  52025. rootUrl: string,
  52026. /**
  52027. * Defines the filename of the scene to load from
  52028. */
  52029. sceneFilename: string);
  52030. /**
  52031. * Execute the current task
  52032. * @param scene defines the scene where you want your assets to be loaded
  52033. * @param onSuccess is a callback called when the task is successfully executed
  52034. * @param onError is a callback called if an error occurs
  52035. */
  52036. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52037. }
  52038. /**
  52039. * Define a task used by AssetsManager to load text content
  52040. */
  52041. export class TextFileAssetTask extends AbstractAssetTask {
  52042. /**
  52043. * Defines the name of the task
  52044. */
  52045. name: string;
  52046. /**
  52047. * Defines the location of the file to load
  52048. */
  52049. url: string;
  52050. /**
  52051. * Gets the loaded text string
  52052. */
  52053. text: string;
  52054. /**
  52055. * Callback called when the task is successful
  52056. */
  52057. onSuccess: (task: TextFileAssetTask) => void;
  52058. /**
  52059. * Callback called when the task is successful
  52060. */
  52061. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  52062. /**
  52063. * Creates a new TextFileAssetTask object
  52064. * @param name defines the name of the task
  52065. * @param url defines the location of the file to load
  52066. */
  52067. constructor(
  52068. /**
  52069. * Defines the name of the task
  52070. */
  52071. name: string,
  52072. /**
  52073. * Defines the location of the file to load
  52074. */
  52075. url: string);
  52076. /**
  52077. * Execute the current task
  52078. * @param scene defines the scene where you want your assets to be loaded
  52079. * @param onSuccess is a callback called when the task is successfully executed
  52080. * @param onError is a callback called if an error occurs
  52081. */
  52082. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52083. }
  52084. /**
  52085. * Define a task used by AssetsManager to load binary data
  52086. */
  52087. export class BinaryFileAssetTask extends AbstractAssetTask {
  52088. /**
  52089. * Defines the name of the task
  52090. */
  52091. name: string;
  52092. /**
  52093. * Defines the location of the file to load
  52094. */
  52095. url: string;
  52096. /**
  52097. * Gets the lodaded data (as an array buffer)
  52098. */
  52099. data: ArrayBuffer;
  52100. /**
  52101. * Callback called when the task is successful
  52102. */
  52103. onSuccess: (task: BinaryFileAssetTask) => void;
  52104. /**
  52105. * Callback called when the task is successful
  52106. */
  52107. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  52108. /**
  52109. * Creates a new BinaryFileAssetTask object
  52110. * @param name defines the name of the new task
  52111. * @param url defines the location of the file to load
  52112. */
  52113. constructor(
  52114. /**
  52115. * Defines the name of the task
  52116. */
  52117. name: string,
  52118. /**
  52119. * Defines the location of the file to load
  52120. */
  52121. url: string);
  52122. /**
  52123. * Execute the current task
  52124. * @param scene defines the scene where you want your assets to be loaded
  52125. * @param onSuccess is a callback called when the task is successfully executed
  52126. * @param onError is a callback called if an error occurs
  52127. */
  52128. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52129. }
  52130. /**
  52131. * Define a task used by AssetsManager to load images
  52132. */
  52133. export class ImageAssetTask extends AbstractAssetTask {
  52134. /**
  52135. * Defines the name of the task
  52136. */
  52137. name: string;
  52138. /**
  52139. * Defines the location of the image to load
  52140. */
  52141. url: string;
  52142. /**
  52143. * Gets the loaded images
  52144. */
  52145. image: HTMLImageElement;
  52146. /**
  52147. * Callback called when the task is successful
  52148. */
  52149. onSuccess: (task: ImageAssetTask) => void;
  52150. /**
  52151. * Callback called when the task is successful
  52152. */
  52153. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  52154. /**
  52155. * Creates a new ImageAssetTask
  52156. * @param name defines the name of the task
  52157. * @param url defines the location of the image to load
  52158. */
  52159. constructor(
  52160. /**
  52161. * Defines the name of the task
  52162. */
  52163. name: string,
  52164. /**
  52165. * Defines the location of the image to load
  52166. */
  52167. url: string);
  52168. /**
  52169. * Execute the current task
  52170. * @param scene defines the scene where you want your assets to be loaded
  52171. * @param onSuccess is a callback called when the task is successfully executed
  52172. * @param onError is a callback called if an error occurs
  52173. */
  52174. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52175. }
  52176. /**
  52177. * Defines the interface used by texture loading tasks
  52178. */
  52179. export interface ITextureAssetTask<TEX extends BaseTexture> {
  52180. /**
  52181. * Gets the loaded texture
  52182. */
  52183. texture: TEX;
  52184. }
  52185. /**
  52186. * Define a task used by AssetsManager to load 2D textures
  52187. */
  52188. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  52189. /**
  52190. * Defines the name of the task
  52191. */
  52192. name: string;
  52193. /**
  52194. * Defines the location of the file to load
  52195. */
  52196. url: string;
  52197. /**
  52198. * Defines if mipmap should not be generated (default is false)
  52199. */
  52200. noMipmap?: boolean | undefined;
  52201. /**
  52202. * Defines if texture must be inverted on Y axis (default is false)
  52203. */
  52204. invertY?: boolean | undefined;
  52205. /**
  52206. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52207. */
  52208. samplingMode: number;
  52209. /**
  52210. * Gets the loaded texture
  52211. */
  52212. texture: Texture;
  52213. /**
  52214. * Callback called when the task is successful
  52215. */
  52216. onSuccess: (task: TextureAssetTask) => void;
  52217. /**
  52218. * Callback called when the task is successful
  52219. */
  52220. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  52221. /**
  52222. * Creates a new TextureAssetTask object
  52223. * @param name defines the name of the task
  52224. * @param url defines the location of the file to load
  52225. * @param noMipmap defines if mipmap should not be generated (default is false)
  52226. * @param invertY defines if texture must be inverted on Y axis (default is false)
  52227. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52228. */
  52229. constructor(
  52230. /**
  52231. * Defines the name of the task
  52232. */
  52233. name: string,
  52234. /**
  52235. * Defines the location of the file to load
  52236. */
  52237. url: string,
  52238. /**
  52239. * Defines if mipmap should not be generated (default is false)
  52240. */
  52241. noMipmap?: boolean | undefined,
  52242. /**
  52243. * Defines if texture must be inverted on Y axis (default is false)
  52244. */
  52245. invertY?: boolean | undefined,
  52246. /**
  52247. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52248. */
  52249. samplingMode?: number);
  52250. /**
  52251. * Execute the current task
  52252. * @param scene defines the scene where you want your assets to be loaded
  52253. * @param onSuccess is a callback called when the task is successfully executed
  52254. * @param onError is a callback called if an error occurs
  52255. */
  52256. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52257. }
  52258. /**
  52259. * Define a task used by AssetsManager to load cube textures
  52260. */
  52261. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  52262. /**
  52263. * Defines the name of the task
  52264. */
  52265. name: string;
  52266. /**
  52267. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  52268. */
  52269. url: string;
  52270. /**
  52271. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  52272. */
  52273. extensions?: string[] | undefined;
  52274. /**
  52275. * Defines if mipmaps should not be generated (default is false)
  52276. */
  52277. noMipmap?: boolean | undefined;
  52278. /**
  52279. * Defines the explicit list of files (undefined by default)
  52280. */
  52281. files?: string[] | undefined;
  52282. /**
  52283. * Gets the loaded texture
  52284. */
  52285. texture: CubeTexture;
  52286. /**
  52287. * Callback called when the task is successful
  52288. */
  52289. onSuccess: (task: CubeTextureAssetTask) => void;
  52290. /**
  52291. * Callback called when the task is successful
  52292. */
  52293. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  52294. /**
  52295. * Creates a new CubeTextureAssetTask
  52296. * @param name defines the name of the task
  52297. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  52298. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  52299. * @param noMipmap defines if mipmaps should not be generated (default is false)
  52300. * @param files defines the explicit list of files (undefined by default)
  52301. */
  52302. constructor(
  52303. /**
  52304. * Defines the name of the task
  52305. */
  52306. name: string,
  52307. /**
  52308. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  52309. */
  52310. url: string,
  52311. /**
  52312. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  52313. */
  52314. extensions?: string[] | undefined,
  52315. /**
  52316. * Defines if mipmaps should not be generated (default is false)
  52317. */
  52318. noMipmap?: boolean | undefined,
  52319. /**
  52320. * Defines the explicit list of files (undefined by default)
  52321. */
  52322. files?: string[] | undefined);
  52323. /**
  52324. * Execute the current task
  52325. * @param scene defines the scene where you want your assets to be loaded
  52326. * @param onSuccess is a callback called when the task is successfully executed
  52327. * @param onError is a callback called if an error occurs
  52328. */
  52329. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52330. }
  52331. /**
  52332. * Define a task used by AssetsManager to load HDR cube textures
  52333. */
  52334. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  52335. /**
  52336. * Defines the name of the task
  52337. */
  52338. name: string;
  52339. /**
  52340. * Defines the location of the file to load
  52341. */
  52342. url: string;
  52343. /**
  52344. * Defines the desired size (the more it increases the longer the generation will be)
  52345. */
  52346. size: number;
  52347. /**
  52348. * Defines if mipmaps should not be generated (default is false)
  52349. */
  52350. noMipmap: boolean;
  52351. /**
  52352. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  52353. */
  52354. generateHarmonics: boolean;
  52355. /**
  52356. * 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)
  52357. */
  52358. gammaSpace: boolean;
  52359. /**
  52360. * Internal Use Only
  52361. */
  52362. reserved: boolean;
  52363. /**
  52364. * Gets the loaded texture
  52365. */
  52366. texture: HDRCubeTexture;
  52367. /**
  52368. * Callback called when the task is successful
  52369. */
  52370. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  52371. /**
  52372. * Callback called when the task is successful
  52373. */
  52374. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  52375. /**
  52376. * Creates a new HDRCubeTextureAssetTask object
  52377. * @param name defines the name of the task
  52378. * @param url defines the location of the file to load
  52379. * @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.
  52380. * @param noMipmap defines if mipmaps should not be generated (default is false)
  52381. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  52382. * @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)
  52383. * @param reserved Internal use only
  52384. */
  52385. constructor(
  52386. /**
  52387. * Defines the name of the task
  52388. */
  52389. name: string,
  52390. /**
  52391. * Defines the location of the file to load
  52392. */
  52393. url: string,
  52394. /**
  52395. * Defines the desired size (the more it increases the longer the generation will be)
  52396. */
  52397. size: number,
  52398. /**
  52399. * Defines if mipmaps should not be generated (default is false)
  52400. */
  52401. noMipmap?: boolean,
  52402. /**
  52403. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  52404. */
  52405. generateHarmonics?: boolean,
  52406. /**
  52407. * 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)
  52408. */
  52409. gammaSpace?: boolean,
  52410. /**
  52411. * Internal Use Only
  52412. */
  52413. reserved?: boolean);
  52414. /**
  52415. * Execute the current task
  52416. * @param scene defines the scene where you want your assets to be loaded
  52417. * @param onSuccess is a callback called when the task is successfully executed
  52418. * @param onError is a callback called if an error occurs
  52419. */
  52420. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52421. }
  52422. /**
  52423. * This class can be used to easily import assets into a scene
  52424. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  52425. */
  52426. export class AssetsManager {
  52427. private _scene;
  52428. private _isLoading;
  52429. protected _tasks: AbstractAssetTask[];
  52430. protected _waitingTasksCount: number;
  52431. protected _totalTasksCount: number;
  52432. /**
  52433. * Callback called when all tasks are processed
  52434. */
  52435. onFinish: (tasks: AbstractAssetTask[]) => void;
  52436. /**
  52437. * Callback called when a task is successful
  52438. */
  52439. onTaskSuccess: (task: AbstractAssetTask) => void;
  52440. /**
  52441. * Callback called when a task had an error
  52442. */
  52443. onTaskError: (task: AbstractAssetTask) => void;
  52444. /**
  52445. * Callback called when a task is done (whatever the result is)
  52446. */
  52447. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  52448. /**
  52449. * Observable called when all tasks are processed
  52450. */
  52451. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  52452. /**
  52453. * Observable called when a task had an error
  52454. */
  52455. onTaskErrorObservable: Observable<AbstractAssetTask>;
  52456. /**
  52457. * Observable called when a task is successful
  52458. */
  52459. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  52460. /**
  52461. * Observable called when a task is done (whatever the result is)
  52462. */
  52463. onProgressObservable: Observable<IAssetsProgressEvent>;
  52464. /**
  52465. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  52466. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  52467. */
  52468. useDefaultLoadingScreen: boolean;
  52469. /**
  52470. * Creates a new AssetsManager
  52471. * @param scene defines the scene to work on
  52472. */
  52473. constructor(scene: Scene);
  52474. /**
  52475. * Add a MeshAssetTask to the list of active tasks
  52476. * @param taskName defines the name of the new task
  52477. * @param meshesNames defines the name of meshes to load
  52478. * @param rootUrl defines the root url to use to locate files
  52479. * @param sceneFilename defines the filename of the scene file
  52480. * @returns a new MeshAssetTask object
  52481. */
  52482. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  52483. /**
  52484. * Add a TextFileAssetTask to the list of active tasks
  52485. * @param taskName defines the name of the new task
  52486. * @param url defines the url of the file to load
  52487. * @returns a new TextFileAssetTask object
  52488. */
  52489. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  52490. /**
  52491. * Add a BinaryFileAssetTask to the list of active tasks
  52492. * @param taskName defines the name of the new task
  52493. * @param url defines the url of the file to load
  52494. * @returns a new BinaryFileAssetTask object
  52495. */
  52496. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  52497. /**
  52498. * Add a ImageAssetTask to the list of active tasks
  52499. * @param taskName defines the name of the new task
  52500. * @param url defines the url of the file to load
  52501. * @returns a new ImageAssetTask object
  52502. */
  52503. addImageTask(taskName: string, url: string): ImageAssetTask;
  52504. /**
  52505. * Add a TextureAssetTask to the list of active tasks
  52506. * @param taskName defines the name of the new task
  52507. * @param url defines the url of the file to load
  52508. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  52509. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  52510. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52511. * @returns a new TextureAssetTask object
  52512. */
  52513. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  52514. /**
  52515. * Add a CubeTextureAssetTask to the list of active tasks
  52516. * @param taskName defines the name of the new task
  52517. * @param url defines the url of the file to load
  52518. * @param extensions defines the extension to use to load the cube map (can be null)
  52519. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  52520. * @param files defines the list of files to load (can be null)
  52521. * @returns a new CubeTextureAssetTask object
  52522. */
  52523. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  52524. /**
  52525. *
  52526. * Add a HDRCubeTextureAssetTask to the list of active tasks
  52527. * @param taskName defines the name of the new task
  52528. * @param url defines the url of the file to load
  52529. * @param size defines the size you want for the cubemap (can be null)
  52530. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  52531. * @param generateHarmonics defines if you want to automatically generate (true by default)
  52532. * @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)
  52533. * @param reserved Internal use only
  52534. * @returns a new HDRCubeTextureAssetTask object
  52535. */
  52536. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  52537. /**
  52538. * Remove a task from the assets manager.
  52539. * @param task the task to remove
  52540. */
  52541. removeTask(task: AbstractAssetTask): void;
  52542. private _decreaseWaitingTasksCount;
  52543. private _runTask;
  52544. /**
  52545. * Reset the AssetsManager and remove all tasks
  52546. * @return the current instance of the AssetsManager
  52547. */
  52548. reset(): AssetsManager;
  52549. /**
  52550. * Start the loading process
  52551. * @return the current instance of the AssetsManager
  52552. */
  52553. load(): AssetsManager;
  52554. }
  52555. }
  52556. declare module BABYLON {
  52557. /**
  52558. * Wrapper class for promise with external resolve and reject.
  52559. */
  52560. export class Deferred<T> {
  52561. /**
  52562. * The promise associated with this deferred object.
  52563. */
  52564. readonly promise: Promise<T>;
  52565. private _resolve;
  52566. private _reject;
  52567. /**
  52568. * The resolve method of the promise associated with this deferred object.
  52569. */
  52570. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  52571. /**
  52572. * The reject method of the promise associated with this deferred object.
  52573. */
  52574. readonly reject: (reason?: any) => void;
  52575. /**
  52576. * Constructor for this deferred object.
  52577. */
  52578. constructor();
  52579. }
  52580. }
  52581. declare module BABYLON {
  52582. /**
  52583. * Class used to help managing file picking and drag'n'drop
  52584. */
  52585. export class FilesInput {
  52586. /**
  52587. * List of files ready to be loaded
  52588. */
  52589. static readonly FilesToLoad: {
  52590. [key: string]: File;
  52591. };
  52592. /**
  52593. * Callback called when a file is processed
  52594. */
  52595. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  52596. private _engine;
  52597. private _currentScene;
  52598. private _sceneLoadedCallback;
  52599. private _progressCallback;
  52600. private _additionalRenderLoopLogicCallback;
  52601. private _textureLoadingCallback;
  52602. private _startingProcessingFilesCallback;
  52603. private _onReloadCallback;
  52604. private _errorCallback;
  52605. private _elementToMonitor;
  52606. private _sceneFileToLoad;
  52607. private _filesToLoad;
  52608. /**
  52609. * Creates a new FilesInput
  52610. * @param engine defines the rendering engine
  52611. * @param scene defines the hosting scene
  52612. * @param sceneLoadedCallback callback called when scene is loaded
  52613. * @param progressCallback callback called to track progress
  52614. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  52615. * @param textureLoadingCallback callback called when a texture is loading
  52616. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  52617. * @param onReloadCallback callback called when a reload is requested
  52618. * @param errorCallback callback call if an error occurs
  52619. */
  52620. 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);
  52621. private _dragEnterHandler;
  52622. private _dragOverHandler;
  52623. private _dropHandler;
  52624. /**
  52625. * Calls this function to listen to drag'n'drop events on a specific DOM element
  52626. * @param elementToMonitor defines the DOM element to track
  52627. */
  52628. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  52629. /**
  52630. * Release all associated resources
  52631. */
  52632. dispose(): void;
  52633. private renderFunction;
  52634. private drag;
  52635. private drop;
  52636. private _traverseFolder;
  52637. private _processFiles;
  52638. /**
  52639. * Load files from a drop event
  52640. * @param event defines the drop event to use as source
  52641. */
  52642. loadFiles(event: any): void;
  52643. private _processReload;
  52644. /**
  52645. * Reload the current scene from the loaded files
  52646. */
  52647. reload(): void;
  52648. }
  52649. }
  52650. declare module BABYLON {
  52651. /**
  52652. * Defines the root class used to create scene optimization to use with SceneOptimizer
  52653. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52654. */
  52655. export class SceneOptimization {
  52656. /**
  52657. * Defines the priority of this optimization (0 by default which means first in the list)
  52658. */
  52659. priority: number;
  52660. /**
  52661. * Gets a string describing the action executed by the current optimization
  52662. * @returns description string
  52663. */
  52664. getDescription(): string;
  52665. /**
  52666. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52667. * @param scene defines the current scene where to apply this optimization
  52668. * @param optimizer defines the current optimizer
  52669. * @returns true if everything that can be done was applied
  52670. */
  52671. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52672. /**
  52673. * Creates the SceneOptimization object
  52674. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52675. * @param desc defines the description associated with the optimization
  52676. */
  52677. constructor(
  52678. /**
  52679. * Defines the priority of this optimization (0 by default which means first in the list)
  52680. */
  52681. priority?: number);
  52682. }
  52683. /**
  52684. * Defines an optimization used to reduce the size of render target textures
  52685. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52686. */
  52687. export class TextureOptimization extends SceneOptimization {
  52688. /**
  52689. * Defines the priority of this optimization (0 by default which means first in the list)
  52690. */
  52691. priority: number;
  52692. /**
  52693. * 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
  52694. */
  52695. maximumSize: number;
  52696. /**
  52697. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52698. */
  52699. step: number;
  52700. /**
  52701. * Gets a string describing the action executed by the current optimization
  52702. * @returns description string
  52703. */
  52704. getDescription(): string;
  52705. /**
  52706. * Creates the TextureOptimization object
  52707. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52708. * @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
  52709. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52710. */
  52711. constructor(
  52712. /**
  52713. * Defines the priority of this optimization (0 by default which means first in the list)
  52714. */
  52715. priority?: number,
  52716. /**
  52717. * 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
  52718. */
  52719. maximumSize?: number,
  52720. /**
  52721. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52722. */
  52723. step?: number);
  52724. /**
  52725. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52726. * @param scene defines the current scene where to apply this optimization
  52727. * @param optimizer defines the current optimizer
  52728. * @returns true if everything that can be done was applied
  52729. */
  52730. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52731. }
  52732. /**
  52733. * Defines an optimization used to increase or decrease the rendering resolution
  52734. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52735. */
  52736. export class HardwareScalingOptimization extends SceneOptimization {
  52737. /**
  52738. * Defines the priority of this optimization (0 by default which means first in the list)
  52739. */
  52740. priority: number;
  52741. /**
  52742. * Defines the maximum scale to use (2 by default)
  52743. */
  52744. maximumScale: number;
  52745. /**
  52746. * Defines the step to use between two passes (0.5 by default)
  52747. */
  52748. step: number;
  52749. private _currentScale;
  52750. private _directionOffset;
  52751. /**
  52752. * Gets a string describing the action executed by the current optimization
  52753. * @return description string
  52754. */
  52755. getDescription(): string;
  52756. /**
  52757. * Creates the HardwareScalingOptimization object
  52758. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52759. * @param maximumScale defines the maximum scale to use (2 by default)
  52760. * @param step defines the step to use between two passes (0.5 by default)
  52761. */
  52762. constructor(
  52763. /**
  52764. * Defines the priority of this optimization (0 by default which means first in the list)
  52765. */
  52766. priority?: number,
  52767. /**
  52768. * Defines the maximum scale to use (2 by default)
  52769. */
  52770. maximumScale?: number,
  52771. /**
  52772. * Defines the step to use between two passes (0.5 by default)
  52773. */
  52774. step?: number);
  52775. /**
  52776. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52777. * @param scene defines the current scene where to apply this optimization
  52778. * @param optimizer defines the current optimizer
  52779. * @returns true if everything that can be done was applied
  52780. */
  52781. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52782. }
  52783. /**
  52784. * Defines an optimization used to remove shadows
  52785. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52786. */
  52787. export class ShadowsOptimization extends SceneOptimization {
  52788. /**
  52789. * Gets a string describing the action executed by the current optimization
  52790. * @return description string
  52791. */
  52792. getDescription(): string;
  52793. /**
  52794. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52795. * @param scene defines the current scene where to apply this optimization
  52796. * @param optimizer defines the current optimizer
  52797. * @returns true if everything that can be done was applied
  52798. */
  52799. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52800. }
  52801. /**
  52802. * Defines an optimization used to turn post-processes off
  52803. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52804. */
  52805. export class PostProcessesOptimization extends SceneOptimization {
  52806. /**
  52807. * Gets a string describing the action executed by the current optimization
  52808. * @return description string
  52809. */
  52810. getDescription(): string;
  52811. /**
  52812. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52813. * @param scene defines the current scene where to apply this optimization
  52814. * @param optimizer defines the current optimizer
  52815. * @returns true if everything that can be done was applied
  52816. */
  52817. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52818. }
  52819. /**
  52820. * Defines an optimization used to turn lens flares off
  52821. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52822. */
  52823. export class LensFlaresOptimization extends SceneOptimization {
  52824. /**
  52825. * Gets a string describing the action executed by the current optimization
  52826. * @return description string
  52827. */
  52828. getDescription(): string;
  52829. /**
  52830. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52831. * @param scene defines the current scene where to apply this optimization
  52832. * @param optimizer defines the current optimizer
  52833. * @returns true if everything that can be done was applied
  52834. */
  52835. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52836. }
  52837. /**
  52838. * Defines an optimization based on user defined callback.
  52839. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52840. */
  52841. export class CustomOptimization extends SceneOptimization {
  52842. /**
  52843. * Callback called to apply the custom optimization.
  52844. */
  52845. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  52846. /**
  52847. * Callback called to get custom description
  52848. */
  52849. onGetDescription: () => string;
  52850. /**
  52851. * Gets a string describing the action executed by the current optimization
  52852. * @returns description string
  52853. */
  52854. getDescription(): string;
  52855. /**
  52856. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52857. * @param scene defines the current scene where to apply this optimization
  52858. * @param optimizer defines the current optimizer
  52859. * @returns true if everything that can be done was applied
  52860. */
  52861. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52862. }
  52863. /**
  52864. * Defines an optimization used to turn particles off
  52865. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52866. */
  52867. export class ParticlesOptimization extends SceneOptimization {
  52868. /**
  52869. * Gets a string describing the action executed by the current optimization
  52870. * @return description string
  52871. */
  52872. getDescription(): string;
  52873. /**
  52874. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52875. * @param scene defines the current scene where to apply this optimization
  52876. * @param optimizer defines the current optimizer
  52877. * @returns true if everything that can be done was applied
  52878. */
  52879. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52880. }
  52881. /**
  52882. * Defines an optimization used to turn render targets off
  52883. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52884. */
  52885. export class RenderTargetsOptimization extends SceneOptimization {
  52886. /**
  52887. * Gets a string describing the action executed by the current optimization
  52888. * @return description string
  52889. */
  52890. getDescription(): string;
  52891. /**
  52892. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52893. * @param scene defines the current scene where to apply this optimization
  52894. * @param optimizer defines the current optimizer
  52895. * @returns true if everything that can be done was applied
  52896. */
  52897. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52898. }
  52899. /**
  52900. * Defines an optimization used to merge meshes with compatible materials
  52901. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52902. */
  52903. export class MergeMeshesOptimization extends SceneOptimization {
  52904. private static _UpdateSelectionTree;
  52905. /**
  52906. * Gets or sets a boolean which defines if optimization octree has to be updated
  52907. */
  52908. /**
  52909. * Gets or sets a boolean which defines if optimization octree has to be updated
  52910. */
  52911. static UpdateSelectionTree: boolean;
  52912. /**
  52913. * Gets a string describing the action executed by the current optimization
  52914. * @return description string
  52915. */
  52916. getDescription(): string;
  52917. private _canBeMerged;
  52918. /**
  52919. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52920. * @param scene defines the current scene where to apply this optimization
  52921. * @param optimizer defines the current optimizer
  52922. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  52923. * @returns true if everything that can be done was applied
  52924. */
  52925. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  52926. }
  52927. /**
  52928. * Defines a list of options used by SceneOptimizer
  52929. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52930. */
  52931. export class SceneOptimizerOptions {
  52932. /**
  52933. * Defines the target frame rate to reach (60 by default)
  52934. */
  52935. targetFrameRate: number;
  52936. /**
  52937. * Defines the interval between two checkes (2000ms by default)
  52938. */
  52939. trackerDuration: number;
  52940. /**
  52941. * Gets the list of optimizations to apply
  52942. */
  52943. optimizations: SceneOptimization[];
  52944. /**
  52945. * Creates a new list of options used by SceneOptimizer
  52946. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  52947. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  52948. */
  52949. constructor(
  52950. /**
  52951. * Defines the target frame rate to reach (60 by default)
  52952. */
  52953. targetFrameRate?: number,
  52954. /**
  52955. * Defines the interval between two checkes (2000ms by default)
  52956. */
  52957. trackerDuration?: number);
  52958. /**
  52959. * Add a new optimization
  52960. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  52961. * @returns the current SceneOptimizerOptions
  52962. */
  52963. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  52964. /**
  52965. * Add a new custom optimization
  52966. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  52967. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  52968. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52969. * @returns the current SceneOptimizerOptions
  52970. */
  52971. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  52972. /**
  52973. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  52974. * @param targetFrameRate defines the target frame rate (60 by default)
  52975. * @returns a SceneOptimizerOptions object
  52976. */
  52977. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52978. /**
  52979. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  52980. * @param targetFrameRate defines the target frame rate (60 by default)
  52981. * @returns a SceneOptimizerOptions object
  52982. */
  52983. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52984. /**
  52985. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  52986. * @param targetFrameRate defines the target frame rate (60 by default)
  52987. * @returns a SceneOptimizerOptions object
  52988. */
  52989. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52990. }
  52991. /**
  52992. * Class used to run optimizations in order to reach a target frame rate
  52993. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52994. */
  52995. export class SceneOptimizer implements IDisposable {
  52996. private _isRunning;
  52997. private _options;
  52998. private _scene;
  52999. private _currentPriorityLevel;
  53000. private _targetFrameRate;
  53001. private _trackerDuration;
  53002. private _currentFrameRate;
  53003. private _sceneDisposeObserver;
  53004. private _improvementMode;
  53005. /**
  53006. * Defines an observable called when the optimizer reaches the target frame rate
  53007. */
  53008. onSuccessObservable: Observable<SceneOptimizer>;
  53009. /**
  53010. * Defines an observable called when the optimizer enables an optimization
  53011. */
  53012. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  53013. /**
  53014. * Defines an observable called when the optimizer is not able to reach the target frame rate
  53015. */
  53016. onFailureObservable: Observable<SceneOptimizer>;
  53017. /**
  53018. * Gets a boolean indicating if the optimizer is in improvement mode
  53019. */
  53020. readonly isInImprovementMode: boolean;
  53021. /**
  53022. * Gets the current priority level (0 at start)
  53023. */
  53024. readonly currentPriorityLevel: number;
  53025. /**
  53026. * Gets the current frame rate checked by the SceneOptimizer
  53027. */
  53028. readonly currentFrameRate: number;
  53029. /**
  53030. * Gets or sets the current target frame rate (60 by default)
  53031. */
  53032. /**
  53033. * Gets or sets the current target frame rate (60 by default)
  53034. */
  53035. targetFrameRate: number;
  53036. /**
  53037. * Gets or sets the current interval between two checks (every 2000ms by default)
  53038. */
  53039. /**
  53040. * Gets or sets the current interval between two checks (every 2000ms by default)
  53041. */
  53042. trackerDuration: number;
  53043. /**
  53044. * Gets the list of active optimizations
  53045. */
  53046. readonly optimizations: SceneOptimization[];
  53047. /**
  53048. * Creates a new SceneOptimizer
  53049. * @param scene defines the scene to work on
  53050. * @param options defines the options to use with the SceneOptimizer
  53051. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  53052. * @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)
  53053. */
  53054. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  53055. /**
  53056. * Stops the current optimizer
  53057. */
  53058. stop(): void;
  53059. /**
  53060. * Reset the optimizer to initial step (current priority level = 0)
  53061. */
  53062. reset(): void;
  53063. /**
  53064. * Start the optimizer. By default it will try to reach a specific framerate
  53065. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  53066. */
  53067. start(): void;
  53068. private _checkCurrentState;
  53069. /**
  53070. * Release all resources
  53071. */
  53072. dispose(): void;
  53073. /**
  53074. * Helper function to create a SceneOptimizer with one single line of code
  53075. * @param scene defines the scene to work on
  53076. * @param options defines the options to use with the SceneOptimizer
  53077. * @param onSuccess defines a callback to call on success
  53078. * @param onFailure defines a callback to call on failure
  53079. * @returns the new SceneOptimizer object
  53080. */
  53081. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  53082. }
  53083. }
  53084. declare module BABYLON {
  53085. /**
  53086. * Class used to serialize a scene into a string
  53087. */
  53088. export class SceneSerializer {
  53089. /**
  53090. * Clear cache used by a previous serialization
  53091. */
  53092. static ClearCache(): void;
  53093. /**
  53094. * Serialize a scene into a JSON compatible object
  53095. * @param scene defines the scene to serialize
  53096. * @returns a JSON compatible object
  53097. */
  53098. static Serialize(scene: Scene): any;
  53099. /**
  53100. * Serialize a mesh into a JSON compatible object
  53101. * @param toSerialize defines the mesh to serialize
  53102. * @param withParents defines if parents must be serialized as well
  53103. * @param withChildren defines if children must be serialized as well
  53104. * @returns a JSON compatible object
  53105. */
  53106. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  53107. }
  53108. }
  53109. declare module BABYLON {
  53110. /**
  53111. * This represents the different options avilable for the video capture.
  53112. */
  53113. export interface VideoRecorderOptions {
  53114. /** Defines the mime type of the video */
  53115. mimeType: string;
  53116. /** Defines the video the video should be recorded at */
  53117. fps: number;
  53118. /** Defines the chunk size for the recording data */
  53119. recordChunckSize: number;
  53120. }
  53121. /**
  53122. * This can helps recording videos from BabylonJS.
  53123. * This is based on the available WebRTC functionalities of the browser.
  53124. *
  53125. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  53126. */
  53127. export class VideoRecorder {
  53128. private static readonly _defaultOptions;
  53129. /**
  53130. * Returns wehther or not the VideoRecorder is available in your browser.
  53131. * @param engine Defines the Babylon Engine to check the support for
  53132. * @returns true if supported otherwise false
  53133. */
  53134. static IsSupported(engine: Engine): boolean;
  53135. private readonly _options;
  53136. private _canvas;
  53137. private _mediaRecorder;
  53138. private _recordedChunks;
  53139. private _fileName;
  53140. private _resolve;
  53141. private _reject;
  53142. /**
  53143. * True wether a recording is already in progress.
  53144. */
  53145. readonly isRecording: boolean;
  53146. /**
  53147. * Create a new VideoCapture object which can help converting what you see in Babylon to
  53148. * a video file.
  53149. * @param engine Defines the BabylonJS Engine you wish to record
  53150. * @param options Defines options that can be used to customized the capture
  53151. */
  53152. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  53153. /**
  53154. * Stops the current recording before the default capture timeout passed in the startRecording
  53155. * functions.
  53156. */
  53157. stopRecording(): void;
  53158. /**
  53159. * Starts recording the canvas for a max duration specified in parameters.
  53160. * @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.
  53161. * @param maxDuration Defines the maximum recording time in seconds.
  53162. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  53163. * @return a promise callback at the end of the recording with the video data in Blob.
  53164. */
  53165. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  53166. /**
  53167. * Releases internal resources used during the recording.
  53168. */
  53169. dispose(): void;
  53170. private _handleDataAvailable;
  53171. private _handleError;
  53172. private _handleStop;
  53173. }
  53174. }
  53175. declare module BABYLON {
  53176. /**
  53177. * Helper class to push actions to a pool of workers.
  53178. */
  53179. export class WorkerPool implements IDisposable {
  53180. private _workerInfos;
  53181. private _pendingActions;
  53182. /**
  53183. * Constructor
  53184. * @param workers Array of workers to use for actions
  53185. */
  53186. constructor(workers: Array<Worker>);
  53187. /**
  53188. * Terminates all workers and clears any pending actions.
  53189. */
  53190. dispose(): void;
  53191. /**
  53192. * Pushes an action to the worker pool. If all the workers are active, the action will be
  53193. * pended until a worker has completed its action.
  53194. * @param action The action to perform. Call onComplete when the action is complete.
  53195. */
  53196. push(action: (worker: Worker, onComplete: () => void) => void): void;
  53197. private _execute;
  53198. }
  53199. }
  53200. declare module BABYLON {
  53201. /**
  53202. * Class containing a set of static utilities functions for screenshots
  53203. */
  53204. export class ScreenshotTools {
  53205. /**
  53206. * Captures a screenshot of the current rendering
  53207. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  53208. * @param engine defines the rendering engine
  53209. * @param camera defines the source camera
  53210. * @param size This parameter can be set to a single number or to an object with the
  53211. * following (optional) properties: precision, width, height. If a single number is passed,
  53212. * it will be used for both width and height. If an object is passed, the screenshot size
  53213. * will be derived from the parameters. The precision property is a multiplier allowing
  53214. * rendering at a higher or lower resolution
  53215. * @param successCallback defines the callback receives a single parameter which contains the
  53216. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  53217. * src parameter of an <img> to display it
  53218. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  53219. * Check your browser for supported MIME types
  53220. */
  53221. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  53222. /**
  53223. * Generates an image screenshot from the specified camera.
  53224. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  53225. * @param engine The engine to use for rendering
  53226. * @param camera The camera to use for rendering
  53227. * @param size This parameter can be set to a single number or to an object with the
  53228. * following (optional) properties: precision, width, height. If a single number is passed,
  53229. * it will be used for both width and height. If an object is passed, the screenshot size
  53230. * will be derived from the parameters. The precision property is a multiplier allowing
  53231. * rendering at a higher or lower resolution
  53232. * @param successCallback The callback receives a single parameter which contains the
  53233. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  53234. * src parameter of an <img> to display it
  53235. * @param mimeType The MIME type of the screenshot image (default: image/png).
  53236. * Check your browser for supported MIME types
  53237. * @param samples Texture samples (default: 1)
  53238. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  53239. * @param fileName A name for for the downloaded file.
  53240. */
  53241. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  53242. }
  53243. }
  53244. declare module BABYLON {
  53245. /**
  53246. * A cursor which tracks a point on a path
  53247. */
  53248. export class PathCursor {
  53249. private path;
  53250. /**
  53251. * Stores path cursor callbacks for when an onchange event is triggered
  53252. */
  53253. private _onchange;
  53254. /**
  53255. * The value of the path cursor
  53256. */
  53257. value: number;
  53258. /**
  53259. * The animation array of the path cursor
  53260. */
  53261. animations: Animation[];
  53262. /**
  53263. * Initializes the path cursor
  53264. * @param path The path to track
  53265. */
  53266. constructor(path: Path2);
  53267. /**
  53268. * Gets the cursor point on the path
  53269. * @returns A point on the path cursor at the cursor location
  53270. */
  53271. getPoint(): Vector3;
  53272. /**
  53273. * Moves the cursor ahead by the step amount
  53274. * @param step The amount to move the cursor forward
  53275. * @returns This path cursor
  53276. */
  53277. moveAhead(step?: number): PathCursor;
  53278. /**
  53279. * Moves the cursor behind by the step amount
  53280. * @param step The amount to move the cursor back
  53281. * @returns This path cursor
  53282. */
  53283. moveBack(step?: number): PathCursor;
  53284. /**
  53285. * Moves the cursor by the step amount
  53286. * If the step amount is greater than one, an exception is thrown
  53287. * @param step The amount to move the cursor
  53288. * @returns This path cursor
  53289. */
  53290. move(step: number): PathCursor;
  53291. /**
  53292. * Ensures that the value is limited between zero and one
  53293. * @returns This path cursor
  53294. */
  53295. private ensureLimits;
  53296. /**
  53297. * Runs onchange callbacks on change (used by the animation engine)
  53298. * @returns This path cursor
  53299. */
  53300. private raiseOnChange;
  53301. /**
  53302. * Executes a function on change
  53303. * @param f A path cursor onchange callback
  53304. * @returns This path cursor
  53305. */
  53306. onchange(f: (cursor: PathCursor) => void): PathCursor;
  53307. }
  53308. }
  53309. declare module BABYLON {
  53310. /** @hidden */
  53311. export var blurPixelShader: {
  53312. name: string;
  53313. shader: string;
  53314. };
  53315. }
  53316. declare module BABYLON {
  53317. /** @hidden */
  53318. export var bones300Declaration: {
  53319. name: string;
  53320. shader: string;
  53321. };
  53322. }
  53323. declare module BABYLON {
  53324. /** @hidden */
  53325. export var instances300Declaration: {
  53326. name: string;
  53327. shader: string;
  53328. };
  53329. }
  53330. declare module BABYLON {
  53331. /** @hidden */
  53332. export var pointCloudVertexDeclaration: {
  53333. name: string;
  53334. shader: string;
  53335. };
  53336. }
  53337. // Mixins
  53338. interface Window {
  53339. mozIndexedDB: IDBFactory;
  53340. webkitIndexedDB: IDBFactory;
  53341. msIndexedDB: IDBFactory;
  53342. webkitURL: typeof URL;
  53343. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  53344. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  53345. WebGLRenderingContext: WebGLRenderingContext;
  53346. MSGesture: MSGesture;
  53347. CANNON: any;
  53348. AudioContext: AudioContext;
  53349. webkitAudioContext: AudioContext;
  53350. PointerEvent: any;
  53351. Math: Math;
  53352. Uint8Array: Uint8ArrayConstructor;
  53353. Float32Array: Float32ArrayConstructor;
  53354. mozURL: typeof URL;
  53355. msURL: typeof URL;
  53356. VRFrameData: any; // WebVR, from specs 1.1
  53357. DracoDecoderModule: any;
  53358. setImmediate(handler: (...args: any[]) => void): number;
  53359. }
  53360. interface Document {
  53361. mozCancelFullScreen(): void;
  53362. msCancelFullScreen(): void;
  53363. webkitCancelFullScreen(): void;
  53364. requestPointerLock(): void;
  53365. exitPointerLock(): void;
  53366. mozFullScreen: boolean;
  53367. msIsFullScreen: boolean;
  53368. readonly webkitIsFullScreen: boolean;
  53369. readonly pointerLockElement: Element;
  53370. mozPointerLockElement: HTMLElement;
  53371. msPointerLockElement: HTMLElement;
  53372. webkitPointerLockElement: HTMLElement;
  53373. }
  53374. interface HTMLCanvasElement {
  53375. requestPointerLock(): void;
  53376. msRequestPointerLock?(): void;
  53377. mozRequestPointerLock?(): void;
  53378. webkitRequestPointerLock?(): void;
  53379. /** Track wether a record is in progress */
  53380. isRecording: boolean;
  53381. /** Capture Stream method defined by some browsers */
  53382. captureStream(fps?: number): MediaStream;
  53383. }
  53384. interface CanvasRenderingContext2D {
  53385. msImageSmoothingEnabled: boolean;
  53386. }
  53387. interface MouseEvent {
  53388. mozMovementX: number;
  53389. mozMovementY: number;
  53390. webkitMovementX: number;
  53391. webkitMovementY: number;
  53392. msMovementX: number;
  53393. msMovementY: number;
  53394. }
  53395. interface Navigator {
  53396. mozGetVRDevices: (any: any) => any;
  53397. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  53398. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  53399. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  53400. webkitGetGamepads(): Gamepad[];
  53401. msGetGamepads(): Gamepad[];
  53402. webkitGamepads(): Gamepad[];
  53403. }
  53404. interface HTMLVideoElement {
  53405. mozSrcObject: any;
  53406. }
  53407. interface Math {
  53408. fround(x: number): number;
  53409. imul(a: number, b: number): number;
  53410. }
  53411. interface WebGLProgram {
  53412. context?: WebGLRenderingContext;
  53413. vertexShader?: WebGLShader;
  53414. fragmentShader?: WebGLShader;
  53415. isParallelCompiled: boolean;
  53416. onCompiled?: () => void;
  53417. }
  53418. interface WebGLRenderingContext {
  53419. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  53420. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  53421. vertexAttribDivisor(index: number, divisor: number): void;
  53422. createVertexArray(): any;
  53423. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  53424. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  53425. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  53426. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  53427. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  53428. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  53429. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  53430. // Queries
  53431. createQuery(): WebGLQuery;
  53432. deleteQuery(query: WebGLQuery): void;
  53433. beginQuery(target: number, query: WebGLQuery): void;
  53434. endQuery(target: number): void;
  53435. getQueryParameter(query: WebGLQuery, pname: number): any;
  53436. getQuery(target: number, pname: number): any;
  53437. MAX_SAMPLES: number;
  53438. RGBA8: number;
  53439. READ_FRAMEBUFFER: number;
  53440. DRAW_FRAMEBUFFER: number;
  53441. UNIFORM_BUFFER: number;
  53442. HALF_FLOAT_OES: number;
  53443. RGBA16F: number;
  53444. RGBA32F: number;
  53445. R32F: number;
  53446. RG32F: number;
  53447. RGB32F: number;
  53448. R16F: number;
  53449. RG16F: number;
  53450. RGB16F: number;
  53451. RED: number;
  53452. RG: number;
  53453. R8: number;
  53454. RG8: number;
  53455. UNSIGNED_INT_24_8: number;
  53456. DEPTH24_STENCIL8: number;
  53457. /* Multiple Render Targets */
  53458. drawBuffers(buffers: number[]): void;
  53459. readBuffer(src: number): void;
  53460. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  53461. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  53462. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  53463. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  53464. // Occlusion Query
  53465. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  53466. ANY_SAMPLES_PASSED: number;
  53467. QUERY_RESULT_AVAILABLE: number;
  53468. QUERY_RESULT: number;
  53469. }
  53470. interface WebGLBuffer {
  53471. references: number;
  53472. capacity: number;
  53473. is32Bits: boolean;
  53474. }
  53475. interface WebGLProgram {
  53476. transformFeedback?: WebGLTransformFeedback | null;
  53477. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  53478. }
  53479. interface EXT_disjoint_timer_query {
  53480. QUERY_COUNTER_BITS_EXT: number;
  53481. TIME_ELAPSED_EXT: number;
  53482. TIMESTAMP_EXT: number;
  53483. GPU_DISJOINT_EXT: number;
  53484. QUERY_RESULT_EXT: number;
  53485. QUERY_RESULT_AVAILABLE_EXT: number;
  53486. queryCounterEXT(query: WebGLQuery, target: number): void;
  53487. createQueryEXT(): WebGLQuery;
  53488. beginQueryEXT(target: number, query: WebGLQuery): void;
  53489. endQueryEXT(target: number): void;
  53490. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  53491. deleteQueryEXT(query: WebGLQuery): void;
  53492. }
  53493. interface WebGLUniformLocation {
  53494. _currentState: any;
  53495. }
  53496. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  53497. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  53498. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  53499. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  53500. interface WebGLRenderingContext {
  53501. readonly RASTERIZER_DISCARD: number;
  53502. readonly DEPTH_COMPONENT24: number;
  53503. readonly TEXTURE_3D: number;
  53504. readonly TEXTURE_2D_ARRAY: number;
  53505. readonly TEXTURE_COMPARE_FUNC: number;
  53506. readonly TEXTURE_COMPARE_MODE: number;
  53507. readonly COMPARE_REF_TO_TEXTURE: number;
  53508. readonly TEXTURE_WRAP_R: number;
  53509. readonly HALF_FLOAT: number;
  53510. readonly RGB8: number;
  53511. readonly RED_INTEGER: number;
  53512. readonly RG_INTEGER: number;
  53513. readonly RGB_INTEGER: number;
  53514. readonly RGBA_INTEGER: number;
  53515. readonly R8_SNORM: number;
  53516. readonly RG8_SNORM: number;
  53517. readonly RGB8_SNORM: number;
  53518. readonly RGBA8_SNORM: number;
  53519. readonly R8I: number;
  53520. readonly RG8I: number;
  53521. readonly RGB8I: number;
  53522. readonly RGBA8I: number;
  53523. readonly R8UI: number;
  53524. readonly RG8UI: number;
  53525. readonly RGB8UI: number;
  53526. readonly RGBA8UI: number;
  53527. readonly R16I: number;
  53528. readonly RG16I: number;
  53529. readonly RGB16I: number;
  53530. readonly RGBA16I: number;
  53531. readonly R16UI: number;
  53532. readonly RG16UI: number;
  53533. readonly RGB16UI: number;
  53534. readonly RGBA16UI: number;
  53535. readonly R32I: number;
  53536. readonly RG32I: number;
  53537. readonly RGB32I: number;
  53538. readonly RGBA32I: number;
  53539. readonly R32UI: number;
  53540. readonly RG32UI: number;
  53541. readonly RGB32UI: number;
  53542. readonly RGBA32UI: number;
  53543. readonly RGB10_A2UI: number;
  53544. readonly R11F_G11F_B10F: number;
  53545. readonly RGB9_E5: number;
  53546. readonly RGB10_A2: number;
  53547. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  53548. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  53549. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  53550. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  53551. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  53552. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  53553. 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;
  53554. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  53555. readonly TRANSFORM_FEEDBACK: number;
  53556. readonly INTERLEAVED_ATTRIBS: number;
  53557. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  53558. createTransformFeedback(): WebGLTransformFeedback;
  53559. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  53560. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  53561. beginTransformFeedback(primitiveMode: number): void;
  53562. endTransformFeedback(): void;
  53563. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  53564. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  53565. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  53566. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  53567. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  53568. }
  53569. interface ImageBitmap {
  53570. readonly width: number;
  53571. readonly height: number;
  53572. close(): void;
  53573. }
  53574. interface WebGLQuery extends WebGLObject {
  53575. }
  53576. declare var WebGLQuery: {
  53577. prototype: WebGLQuery;
  53578. new(): WebGLQuery;
  53579. };
  53580. interface WebGLSampler extends WebGLObject {
  53581. }
  53582. declare var WebGLSampler: {
  53583. prototype: WebGLSampler;
  53584. new(): WebGLSampler;
  53585. };
  53586. interface WebGLSync extends WebGLObject {
  53587. }
  53588. declare var WebGLSync: {
  53589. prototype: WebGLSync;
  53590. new(): WebGLSync;
  53591. };
  53592. interface WebGLTransformFeedback extends WebGLObject {
  53593. }
  53594. declare var WebGLTransformFeedback: {
  53595. prototype: WebGLTransformFeedback;
  53596. new(): WebGLTransformFeedback;
  53597. };
  53598. interface WebGLVertexArrayObject extends WebGLObject {
  53599. }
  53600. declare var WebGLVertexArrayObject: {
  53601. prototype: WebGLVertexArrayObject;
  53602. new(): WebGLVertexArrayObject;
  53603. };
  53604. // Type definitions for WebVR API
  53605. // Project: https://w3c.github.io/webvr/
  53606. // Definitions by: six a <https://github.com/lostfictions>
  53607. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  53608. interface VRDisplay extends EventTarget {
  53609. /**
  53610. * Dictionary of capabilities describing the VRDisplay.
  53611. */
  53612. readonly capabilities: VRDisplayCapabilities;
  53613. /**
  53614. * z-depth defining the far plane of the eye view frustum
  53615. * enables mapping of values in the render target depth
  53616. * attachment to scene coordinates. Initially set to 10000.0.
  53617. */
  53618. depthFar: number;
  53619. /**
  53620. * z-depth defining the near plane of the eye view frustum
  53621. * enables mapping of values in the render target depth
  53622. * attachment to scene coordinates. Initially set to 0.01.
  53623. */
  53624. depthNear: number;
  53625. /**
  53626. * An identifier for this distinct VRDisplay. Used as an
  53627. * association point in the Gamepad API.
  53628. */
  53629. readonly displayId: number;
  53630. /**
  53631. * A display name, a user-readable name identifying it.
  53632. */
  53633. readonly displayName: string;
  53634. readonly isConnected: boolean;
  53635. readonly isPresenting: boolean;
  53636. /**
  53637. * If this VRDisplay supports room-scale experiences, the optional
  53638. * stage attribute contains details on the room-scale parameters.
  53639. */
  53640. readonly stageParameters: VRStageParameters | null;
  53641. /**
  53642. * Passing the value returned by `requestAnimationFrame` to
  53643. * `cancelAnimationFrame` will unregister the callback.
  53644. * @param handle Define the hanle of the request to cancel
  53645. */
  53646. cancelAnimationFrame(handle: number): void;
  53647. /**
  53648. * Stops presenting to the VRDisplay.
  53649. * @returns a promise to know when it stopped
  53650. */
  53651. exitPresent(): Promise<void>;
  53652. /**
  53653. * Return the current VREyeParameters for the given eye.
  53654. * @param whichEye Define the eye we want the parameter for
  53655. * @returns the eye parameters
  53656. */
  53657. getEyeParameters(whichEye: string): VREyeParameters;
  53658. /**
  53659. * Populates the passed VRFrameData with the information required to render
  53660. * the current frame.
  53661. * @param frameData Define the data structure to populate
  53662. * @returns true if ok otherwise false
  53663. */
  53664. getFrameData(frameData: VRFrameData): boolean;
  53665. /**
  53666. * Get the layers currently being presented.
  53667. * @returns the list of VR layers
  53668. */
  53669. getLayers(): VRLayer[];
  53670. /**
  53671. * Return a VRPose containing the future predicted pose of the VRDisplay
  53672. * when the current frame will be presented. The value returned will not
  53673. * change until JavaScript has returned control to the browser.
  53674. *
  53675. * The VRPose will contain the position, orientation, velocity,
  53676. * and acceleration of each of these properties.
  53677. * @returns the pose object
  53678. */
  53679. getPose(): VRPose;
  53680. /**
  53681. * Return the current instantaneous pose of the VRDisplay, with no
  53682. * prediction applied.
  53683. * @returns the current instantaneous pose
  53684. */
  53685. getImmediatePose(): VRPose;
  53686. /**
  53687. * The callback passed to `requestAnimationFrame` will be called
  53688. * any time a new frame should be rendered. When the VRDisplay is
  53689. * presenting the callback will be called at the native refresh
  53690. * rate of the HMD. When not presenting this function acts
  53691. * identically to how window.requestAnimationFrame acts. Content should
  53692. * make no assumptions of frame rate or vsync behavior as the HMD runs
  53693. * asynchronously from other displays and at differing refresh rates.
  53694. * @param callback Define the eaction to run next frame
  53695. * @returns the request handle it
  53696. */
  53697. requestAnimationFrame(callback: FrameRequestCallback): number;
  53698. /**
  53699. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  53700. * Repeat calls while already presenting will update the VRLayers being displayed.
  53701. * @param layers Define the list of layer to present
  53702. * @returns a promise to know when the request has been fulfilled
  53703. */
  53704. requestPresent(layers: VRLayer[]): Promise<void>;
  53705. /**
  53706. * Reset the pose for this display, treating its current position and
  53707. * orientation as the "origin/zero" values. VRPose.position,
  53708. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  53709. * updated when calling resetPose(). This should be called in only
  53710. * sitting-space experiences.
  53711. */
  53712. resetPose(): void;
  53713. /**
  53714. * The VRLayer provided to the VRDisplay will be captured and presented
  53715. * in the HMD. Calling this function has the same effect on the source
  53716. * canvas as any other operation that uses its source image, and canvases
  53717. * created without preserveDrawingBuffer set to true will be cleared.
  53718. * @param pose Define the pose to submit
  53719. */
  53720. submitFrame(pose?: VRPose): void;
  53721. }
  53722. declare var VRDisplay: {
  53723. prototype: VRDisplay;
  53724. new(): VRDisplay;
  53725. };
  53726. interface VRLayer {
  53727. leftBounds?: number[] | Float32Array | null;
  53728. rightBounds?: number[] | Float32Array | null;
  53729. source?: HTMLCanvasElement | null;
  53730. }
  53731. interface VRDisplayCapabilities {
  53732. readonly canPresent: boolean;
  53733. readonly hasExternalDisplay: boolean;
  53734. readonly hasOrientation: boolean;
  53735. readonly hasPosition: boolean;
  53736. readonly maxLayers: number;
  53737. }
  53738. interface VREyeParameters {
  53739. /** @deprecated */
  53740. readonly fieldOfView: VRFieldOfView;
  53741. readonly offset: Float32Array;
  53742. readonly renderHeight: number;
  53743. readonly renderWidth: number;
  53744. }
  53745. interface VRFieldOfView {
  53746. readonly downDegrees: number;
  53747. readonly leftDegrees: number;
  53748. readonly rightDegrees: number;
  53749. readonly upDegrees: number;
  53750. }
  53751. interface VRFrameData {
  53752. readonly leftProjectionMatrix: Float32Array;
  53753. readonly leftViewMatrix: Float32Array;
  53754. readonly pose: VRPose;
  53755. readonly rightProjectionMatrix: Float32Array;
  53756. readonly rightViewMatrix: Float32Array;
  53757. readonly timestamp: number;
  53758. }
  53759. interface VRPose {
  53760. readonly angularAcceleration: Float32Array | null;
  53761. readonly angularVelocity: Float32Array | null;
  53762. readonly linearAcceleration: Float32Array | null;
  53763. readonly linearVelocity: Float32Array | null;
  53764. readonly orientation: Float32Array | null;
  53765. readonly position: Float32Array | null;
  53766. readonly timestamp: number;
  53767. }
  53768. interface VRStageParameters {
  53769. sittingToStandingTransform?: Float32Array;
  53770. sizeX?: number;
  53771. sizeY?: number;
  53772. }
  53773. interface Navigator {
  53774. getVRDisplays(): Promise<VRDisplay[]>;
  53775. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  53776. }
  53777. interface Window {
  53778. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  53779. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  53780. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  53781. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  53782. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  53783. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  53784. }
  53785. interface Gamepad {
  53786. readonly displayId: number;
  53787. }
  53788. interface XRDevice {
  53789. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  53790. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  53791. }
  53792. interface XRSession {
  53793. getInputSources(): Array<any>;
  53794. baseLayer: XRWebGLLayer;
  53795. requestFrameOfReference(type: string): Promise<void>;
  53796. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  53797. end(): Promise<void>;
  53798. requestAnimationFrame: Function;
  53799. addEventListener: Function;
  53800. }
  53801. interface XRSessionCreationOptions {
  53802. outputContext?: WebGLRenderingContext | null;
  53803. immersive?: boolean;
  53804. environmentIntegration?: boolean;
  53805. }
  53806. interface XRLayer {
  53807. getViewport: Function;
  53808. framebufferWidth: number;
  53809. framebufferHeight: number;
  53810. }
  53811. interface XRView {
  53812. projectionMatrix: Float32Array;
  53813. }
  53814. interface XRFrame {
  53815. getDevicePose: Function;
  53816. getInputPose: Function;
  53817. views: Array<XRView>;
  53818. baseLayer: XRLayer;
  53819. }
  53820. interface XRFrameOfReference {
  53821. }
  53822. interface XRWebGLLayer extends XRLayer {
  53823. framebuffer: WebGLFramebuffer;
  53824. }
  53825. declare var XRWebGLLayer: {
  53826. prototype: XRWebGLLayer;
  53827. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  53828. };